Integration JMS BITRONIX in tomcat

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Integration JMS BITRONIX in tomcat

coolio971
Hi,
I try to use BTM as transaction manager with jms datasource in tomcat  like  this configuration with sql datasource

http://docs.codehaus.org/display/BTM/Tomcat13

I read this JMS configuration :
http://docs.codehaus.org/display/BTM/JmsConfiguration

which help me but I have an error:

Failed to convert property value of type [bitronix.tm.resource.jms.PoolingConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [bitronix.tm.resource.jms.PoolingConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found

My configuration :

resources.properties


resource.cf.className=org.apache.activemq.ActiveMQXAConnectionFactory
resource.cf.uniqueName=jms/AConnectionFactory
resource.cf.maxPoolSize=5
resource.cf.allowLocalTransactions=true
resource.cf.driverProperties.brokerURL=tcp://localhost:61616

context.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Transaction factory="bitronix.tm.BitronixUserTransactionObjectFactory" />
<Resource
        name="jms/AConnectionFactory"
        auth="Container"
        type="javax.jms.ConnectionFactory"
        factory="bitronix.tm.resource.ResourceObjectFactory"
        uniqueName="jms/AConnectionFactory"
        />
</Context>


web.xml

...
<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/applicationContext*.xml
        </param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

<resource-ref>
<res-ref-name>jms/AConnectionFactory</res-ref-name>
<res-type>javax.jms.ConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
...


applicationContext-services.xml

...
<jee:jndi-lookup id="jmsConnectionFactory" jndi-name="java:/comp/env/jms/AConnectionFactory" resource-ref="true" />

<bean id="destination" class="org.apache.activemq.command.ActiveMQQueue">   
        <constructor-arg index="0">         
            <value>Myqueue</value>   
        </constructor-arg>
</bean>

<bean id="myAsynchJmsListener" class="classes.MyAsynchJmsListener"/> 
         <bean id="listenerContainer"  class="org.springframework.jms.listener.DefaultMessageListenerContainer">   
        <property name="concurrentConsumers" value="1"/>   
        <property name="connectionFactory" ref="jmsConnectionFactory" />   
        <property name="destination" ref="destination" />   
        <property name="messageListener" ref="myAsynchJmsListener" />
  <property name="sessionTransacted" value="true"/>
    </bean> 

...




Could you help me please ?
Reply | Threaded
Open this post in threaded view
|

Re: Integration JMS BITRONIX in tomcat

Ludovic Orban
Administrator
Looks like a classloader issue to me. Make sure jms.jar (or whatever JAR file which contains javax.jms.*) is in Tomcat's folder next to the btm JAR file (BTM ships with geronimo-jms_1.1_spec.jar which is the Geronimo JAR containing the JMS spec classes, better use that one) and that it's not in the WEB-INF/lib folder of your web archive.
Reply | Threaded
Open this post in threaded view
|

Re: Integration JMS BITRONIX in tomcat

coolio971
Hi,
Your reply help me a lot I delete all .jar using javax.jms.* and put geronimo-jms_1.1_spec.jar instead of and it work fine.

However I have an other question about the same subject.
Indeed, i define my queue in my application so can you explain me how I can define my destination queue like my connection factory please?
Reply | Threaded
Open this post in threaded view
|

Re: Integration JMS BITRONIX in tomcat

Ludovic Orban
Administrator
In reply to this post by Ludovic Orban
Hi again,

About the JMSException problem (Session's XAResource has not been enlisted in a distributed transaction):

ActiveMQ does not support local transaction usage with its XAConnectionFactory. You have to set allowLocalTransactions to false and make sure an XA transaction is always started before you use your configured connection factory.


About the queues declaration in web.xml: sorry but this completely unrelated to JTA. This is a J2EE / Servlet / JMS / JNDI / I-don't-know-what-else configuration problem. I cannot help you on this.

Ludovic

2009/6/1 coolio971 <[hidden email]>

Hi,
Your reply help me a lot, I delete all .jar using javax.jms.* and put
geronimo-jms_1.1_spec.jar instead of and It work fine.:-D

However When my application want to receive a message I have this error :


1 juin 2009 11:39:33 bitronix.tm.resource.jms.DualSessionWrapper
stateChanged
GRAVE: error closing session
javax.jms.JMSException: Session's XAResource has not been enlisted in a
distributed transaction.
       at
org.apache.activemq.ActiveMQXASession.doStartTransaction(ActiveMQXASession.java:109)
       at
org.apache.activemq.ActiveMQMessageConsumer.acknowledge(ActiveMQMessageConsumer.java:879)
       at
org.apache.activemq.ActiveMQMessageConsumer.dispose(ActiveMQMessageConsumer.java:669)
       at org.apache.activemq.ActiveMQSession.dispose(ActiveMQSession.java:583)
       at org.apache.activemq.ActiveMQSession.close(ActiveMQSession.java:555)
       at
bitronix.tm.resource.jms.DualSessionWrapper.stateChanged(DualSessionWrapper.java:166)
       at
bitronix.tm.resource.common.AbstractXAStatefulHolder.fireStateChanged(AbstractXAStatefulHolder.java:72)
       at
bitronix.tm.resource.common.AbstractXAStatefulHolder.setState(AbstractXAStatefulHolder.java:43)
       at
bitronix.tm.resource.jms.DualSessionWrapper.stateChanged(DualSessionWrapper.java:149)
       at
bitronix.tm.resource.common.AbstractXAStatefulHolder.fireStateChanged(AbstractXAStatefulHolder.java:72)
       at
bitronix.tm.resource.common.AbstractXAStatefulHolder.setState(AbstractXAStatefulHolder.java:43)
       at
bitronix.tm.resource.common.TransactionContextHelper.requeue(TransactionContextHelper.java:116)
       at
bitronix.tm.resource.jms.DualSessionWrapper.close(DualSessionWrapper.java:132)
       at org.springframework.jms.support.JmsUtils.closeSession(JmsUtils.java:108)
       at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.clearResources(DefaultMessageListenerContainer.java:1020)
       at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:887)
       at java.lang.Thread.run(Thread.java:595)



can you help me for this error please?

Secondly I want to declare my queue like my connectionFactory

in my web.xml I wrote that :

<message-destination-ref>
 <message-destination-ref-name>
     jms/AQueue
</message-destination-ref-name>
<message-destination-type>
     javax.jms.Queue
</message-destination-type>
<message-destination-usage>
     Consumes
</message-destination-usage>
       <message-destination-link>MyQueue</message-destination-link>
</message-destination-ref>

but can you give me an exemple of what I have to put in my
resources.properties, context.xml and applicationContext-services.xml
please?














--
View this message in context: http://www.nabble.com/Integration-JMS-BITRONIX--in-tomcat-tp23783609p23811654.html
Sent from the Bitronix Transaction Manager mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email