[Need Help]bitronix.tm.BitronixTransactionManager cannot be cast to javax.transaction.UserTransaction

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

[Need Help]bitronix.tm.BitronixTransactionManager cannot be cast to javax.transaction.UserTransaction

James Yu
Hi all,
 
I follow the following URL
http://docs.codehaus.org/display/BTM/Tomcat
 
and I have the {CATALINA_HOME}\webapps\{MY_APP}\META-INF\context.xml configured like this:
<Context>
    <Resource name="jdbc/testDS" auth="Container" type="javax.sql.DataSource"
        factory="bitronix.tm.resource.
ResourceObjectFactory" uniqueName="jdbc/testDS" />
</Context>
 
I can deploy {MY_APP} to tomcat and startup tomcat successfully, but got exception when running the servlet.
Any idea ?
 
The exception I got is:
java.lang.ClassCastException: bitronix.tm.BitronixTransactionManager cannot be cast to javax.transaction.UserTransaction
    org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:131)
    org.drools.persistence.jta.JtaTransactionManager.<init>(JtaTransactionManager.java:79)
    org.drools.persistence.SingleSessionCommandService.initTransactionManager(SingleSessionCommandService.java:298)
    org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:90)
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:150)
    org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newKieSession(KnowledgeStoreServiceImpl.java:70)
    org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newKieSession(KnowledgeStoreServiceImpl.java:39)
    com.fet.sdp.poc.bpm.BPMService01.startCCDeductProcess(BPMService01.java:135)
    com.fet.sdp.poc.xmlrest.service.services.POCService.get01(POCService.java:36)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
    org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:165)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:92)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
    java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    java.util.concurrent.FutureTask.run(FutureTask.java:262)
    org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
    org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)
    org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:209)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:152)
    org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:113)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

This is a UTF-8 formatted mail
-----------------------------------------------
James C.-C.Yu
+886988713275
Reply | Threaded
Open this post in threaded view
|

Re: [Need Help]bitronix.tm.BitronixTransactionManager cannot be cast to javax.transaction.UserTransaction

Brett Wooldridge-2
This error message seems to imply to me that there are two jars providing the class javax.transaction.UserTransaction.  Likely there is a jar in the tomcat lib as well as the war.  Remove one of them.  Better to keep the one in the same classloader as Bitronix.

On Fri, Sep 19, 2014 at 2:26 PM, James Yu <[hidden email]> wrote:
Hi all,
 
I follow the following URL
http://docs.codehaus.org/display/BTM/Tomcat
 
and I have the {CATALINA_HOME}\webapps\{MY_APP}\META-INF\context.xml configured like this:
<Context>
    <Resource name="jdbc/testDS" auth="Container" type="javax.sql.DataSource"
        factory="bitronix.tm.resource.
ResourceObjectFactory" uniqueName="jdbc/testDS" />
</Context>
 
I can deploy {MY_APP} to tomcat and startup tomcat successfully, but got exception when running the servlet.
Any idea ?
 
The exception I got is:
java.lang.ClassCastException: bitronix.tm.BitronixTransactionManager cannot be cast to javax.transaction.UserTransaction
    org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:131)
    org.drools.persistence.jta.JtaTransactionManager.<init>(JtaTransactionManager.java:79)
    org.drools.persistence.SingleSessionCommandService.initTransactionManager(SingleSessionCommandService.java:298)
    org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:90)
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:150)
    org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newKieSession(KnowledgeStoreServiceImpl.java:70)
    org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newKieSession(KnowledgeStoreServiceImpl.java:39)
    com.fet.sdp.poc.bpm.BPMService01.startCCDeductProcess(BPMService01.java:135)
    com.fet.sdp.poc.xmlrest.service.services.POCService.get01(POCService.java:36)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
    org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:165)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:92)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
    java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    java.util.concurrent.FutureTask.run(FutureTask.java:262)
    org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
    org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)
    org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:209)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:152)
    org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:113)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

This is a UTF-8 formatted mail
-----------------------------------------------
James C.-C.Yu
<a href="tel:%2B886988713275" value="+886988713275" target="_blank">+886988713275

Reply | Threaded
Open this post in threaded view
|

Re: [Need Help]bitronix.tm.BitronixTransactionManager cannot be cast to javax.transaction.UserTransaction

Ludovic Orban-2
Since you followed the Tomcat integration guide, BTM is at the heart
of Tomcat so you should NOT include it in any of your web apps. All
you need to do in your WAR files is add the datasource refs in
META-INF/context.xml and web.xml and you should be good to go.

Always make sure btm.jar and jta.jar do not end up in your WEB-INF/lib
folder if BTM has been configured in Tomcat.

On Fri, Sep 19, 2014 at 11:59 AM, Brett Wooldridge
<[hidden email]> wrote:

> This error message seems to imply to me that there are two jars providing
> the class javax.transaction.UserTransaction.  Likely there is a jar in the
> tomcat lib as well as the war.  Remove one of them.  Better to keep the one
> in the same classloader as Bitronix.
>
> On Fri, Sep 19, 2014 at 2:26 PM, James Yu <[hidden email]> wrote:
>>
>> Hi all,
>>
>> I follow the following URL
>> http://docs.codehaus.org/display/BTM/Tomcat
>>
>> and I have the {CATALINA_HOME}\webapps\{MY_APP}\META-INF\context.xml
>> configured like this:
>> <Context>
>>     <Resource name="jdbc/testDS" auth="Container"
>> type="javax.sql.DataSource"
>>         factory="bitronix.tm.resource.
>> ResourceObjectFactory" uniqueName="jdbc/testDS" />
>> </Context>
>>
>> I can deploy {MY_APP} to tomcat and startup tomcat successfully, but got
>> exception when running the servlet.
>> Any idea ?
>>
>> The exception I got is:
>> java.lang.ClassCastException: bitronix.tm.BitronixTransactionManager
>> cannot be cast to javax.transaction.UserTransaction
>>
>> org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:131)
>>
>> org.drools.persistence.jta.JtaTransactionManager.<init>(JtaTransactionManager.java:79)
>>
>> org.drools.persistence.SingleSessionCommandService.initTransactionManager(SingleSessionCommandService.java:298)
>>
>> org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:90)
>>     sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>>
>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
>>
>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>>     java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>>
>> org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:150)
>>
>> org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newKieSession(KnowledgeStoreServiceImpl.java:70)
>>
>> org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newKieSession(KnowledgeStoreServiceImpl.java:39)
>>
>> com.fet.sdp.poc.bpm.BPMService01.startCCDeductProcess(BPMService01.java:135)
>>
>> com.fet.sdp.poc.xmlrest.service.services.POCService.get01(POCService.java:36)
>>     sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>     java.lang.reflect.Method.invoke(Method.java:606)
>>
>> org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
>>
>> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
>>     org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:165)
>>     org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:92)
>>
>> org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
>>
>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>>     java.util.concurrent.FutureTask.run(FutureTask.java:262)
>>
>> org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
>>
>> org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
>>
>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
>>
>> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
>>
>> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)
>>
>> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:209)
>>
>> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:152)
>>
>> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)
>>
>> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185)
>>
>> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:113)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
>>
>> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164)
>>     org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
>>
>> This is a UTF-8 formatted mail
>> -----------------------------------------------
>> James C.-C.Yu
>> +886988713275
>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: [Need Help]bitronix.tm.BitronixTransactionManager cannot be cast to javax.transaction.UserTransaction

James Yu
Hi Brett, Ludovic

I just did {jar -tf xxx | findstr "javax.transaction.UserTransaction"} on all jar files and found out there is a "jboss-transaction-api_1.1_spec-1.0.1.Final.jar" that contains "javax/transaction/UserTransaction.class".

After removing this file, everything works out just fine.
Thank you so much for the tips!

This is a UTF-8 formatted mail
-----------------------------------------------
James C.-C.Yu
+886988713275

On 19 September 2014 18:25, Ludovic Orban <[hidden email]> wrote:
Since you followed the Tomcat integration guide, BTM is at the heart
of Tomcat so you should NOT include it in any of your web apps. All
you need to do in your WAR files is add the datasource refs in
META-INF/context.xml and web.xml and you should be good to go.

Always make sure btm.jar and jta.jar do not end up in your WEB-INF/lib
folder if BTM has been configured in Tomcat.

On Fri, Sep 19, 2014 at 11:59 AM, Brett Wooldridge
<[hidden email]> wrote:
> This error message seems to imply to me that there are two jars providing
> the class javax.transaction.UserTransaction.  Likely there is a jar in the
> tomcat lib as well as the war.  Remove one of them.  Better to keep the one
> in the same classloader as Bitronix.
>
> On Fri, Sep 19, 2014 at 2:26 PM, James Yu <[hidden email]> wrote:
>>
>> Hi all,
>>
>> I follow the following URL
>> http://docs.codehaus.org/display/BTM/Tomcat
>>
>> and I have the {CATALINA_HOME}\webapps\{MY_APP}\META-INF\context.xml
>> configured like this:
>> <Context>
>>     <Resource name="jdbc/testDS" auth="Container"
>> type="javax.sql.DataSource"
>>         factory="bitronix.tm.resource.
>> ResourceObjectFactory" uniqueName="jdbc/testDS" />
>> </Context>
>>
>> I can deploy {MY_APP} to tomcat and startup tomcat successfully, but got
>> exception when running the servlet.
>> Any idea ?
>>
>> The exception I got is:
>> java.lang.ClassCastException: bitronix.tm.BitronixTransactionManager
>> cannot be cast to javax.transaction.UserTransaction
>>
>> org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:131)
>>
>> org.drools.persistence.jta.JtaTransactionManager.<init>(JtaTransactionManager.java:79)
>>
>> org.drools.persistence.SingleSessionCommandService.initTransactionManager(SingleSessionCommandService.java:298)
>>
>> org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:90)
>>     sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>>
>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
>>
>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>>     java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>>
>> org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:150)
>>
>> org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newKieSession(KnowledgeStoreServiceImpl.java:70)
>>
>> org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newKieSession(KnowledgeStoreServiceImpl.java:39)
>>
>> com.fet.sdp.poc.bpm.BPMService01.startCCDeductProcess(BPMService01.java:135)
>>
>> com.fet.sdp.poc.xmlrest.service.services.POCService.get01(POCService.java:36)
>>     sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>     java.lang.reflect.Method.invoke(Method.java:606)
>>
>> org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
>>
>> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
>>     org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:165)
>>     org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:92)
>>
>> org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
>>
>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>>     java.util.concurrent.FutureTask.run(FutureTask.java:262)
>>
>> org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
>>
>> org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
>>
>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
>>
>> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
>>
>> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)
>>
>> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:209)
>>
>> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:152)
>>
>> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)
>>
>> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185)
>>
>> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:113)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
>>
>> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164)
>>     org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
>>
>> This is a UTF-8 formatted mail
>> -----------------------------------------------
>> James C.-C.Yu
>> +886988713275
>
>

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

    http://xircles.codehaus.org/manage_email