Foros de discusión

Problems integrating JMS

thumbnail
Pierpaolo Cira, modificado hace 10 años.

Problems integrating JMS

Regular Member Mensajes: 141 Fecha de incorporación: 26/02/10 Mensajes recientes
Hi all,
there is an external application that have to send messages on my LR 6.1GA2 installation, by a JMS queue (broker is Apache ActiveMQ).
The main idea is to use Spring-jms... so I wrote a standalone sample code and everithing works fine, but when I try to integrate the consumer code inside LR I get many problems.

I just defined the following beans inside ext-sping.xml of my portlet:

<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
	<property name="brokerURL" value="tcp://localhost:61616" />
	</bean>
	
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
	<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>


But in LR i get this exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsTemplate' defined in ServletContext resource [/WEB-INF/classes/META-INF/ext-spring.xml]: Initialization of bean failed;
nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.apache.activemq.ActiveMQConnectionFactory' to required type 'javax.jms.ConnectionFactory' for property 'connectionFactory';
nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.apache.activemq.ActiveMQConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found


It wonders me, because the same code in a standalone project (using the same version of spring-jms) works fine.... and org.apache.activemq.ActiveMQConnectionFactory implements javax.jms.ConnectionFactory!!!

So in my mind LR uses a "strange" JMS version or it is overriding some Spring default behaviour...

Do you have any idea or suggestion about?
It'll be very appreciated.

Thank you
thumbnail
Pierpaolo Cira, modificado hace 10 años.

RE: Problems integrating JMS

Regular Member Mensajes: 141 Fecha de incorporación: 26/02/10 Mensajes recientes
UPDATE

I see that the client library for my queue-broker (Apache ActiveMQ) contains the javax.jms package.
So, instead to use activemq-all.jar library, I used activemq-client.jar which not contains that package.

But the problem is the same.
So my idea is that there is a conflict (or a kind of problem) between ActiveMQ and Liferay jms.jar (located inside tomcat/lib/ext folder).

Do you have any idea about the version of jms.jar included in LR?
Do you think that I can replace the LR jms provided library?
Do you think my portlet can "override" the LR provided jms library (only for itself)?

Thank you for any suggestion.

Bye
Umair Saleem, modificado hace 9 años.

RE: Problems integrating JMS

New Member Mensajes: 3 Fecha de incorporación: 10/02/15 Mensajes recientes
Dear have you find any solution? I am also facing this issue. Your help is needed. Thanks.
thumbnail
David H Nebinger, modificado hace 9 años.

RE: Problems integrating JMS

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
It's a class loader thing. The global loader has the packages from the global jms jar and your project has other dependencies locally.

Clean up your class loader issues and you should be fine.
thumbnail
Pierpaolo Cira, modificado hace 9 años.

RE: Problems integrating JMS

Regular Member Mensajes: 141 Fecha de incorporación: 26/02/10 Mensajes recientes
Umair Saleem:
Dear have you find any solution? I am also facing this issue. Your help is needed. Thanks.


Yes, I found a solution. I don't know if it's the "formally perfect" solution, but it works and it was enough for our needs.... emoticon

In my mind there was a class loading issue trying to use Liferay Spring Context and Apache ActiveMQ (due to what I spoke)... so I declared another Spring context for my application just for messaging purposes.
Then I included it in my portlet.xml declaration

		<init-param>
			<name>contextConfigLocation</name>
			<value>/WEB-INF/classes/messaging-spring.xml</value>
		</init-param>


I hope it can be useful for you.