Cannot obtain BTM transaction manager instance on tomcat with hibernate and spring

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

Cannot obtain BTM transaction manager instance on tomcat with hibernate and spring

Travers Snyman

I am trying to use BTM as jta transaction manager in my Hibernate, Spring based application running on Tomcat.

I believe my BTM setup on Tomcat is correct as I can see the following on Tomcat startup:

26 Nov 2012 12:43:27 PM bitronix.tm.integration.tomcat55.BTMLifecycleListener lifecycleEvent
INFO: Starting Bitronix Transaction Manager
26 Nov 2012 12:43:27 PM bitronix.tm.BitronixTransactionManager logVersion
INFO: Bitronix Transaction Manager version 2.1.3
26 Nov 2012 12:43:27 PM bitronix.tm.Configuration buildServerIdArray
INFO: JVM unique ID: <tomcat7-btm-node0 >
26 Nov 2012 12:43:27 PM bitronix.tm.resource.ResourceLoader init
INFO: reading resources configuration from C:\devtools\apache-tomcat-7.0.2/conf/btm-resources.properties
26 Nov 2012 12:43:27 PM bitronix.tm.recovery.Recoverer run
INFO: recovery committed 0 dangling transaction(s) and rolled back 0 aborted transaction(s) on 1 resource(s) [jdbc/jbpm-ds] (restricted to serverId 'tomcat7-btm-node0 ')
26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.2

The problem is however that I get an exception when the BTM transaction manager is called:

bitronix.tm.BitronixTransactionManager cannot be cast to javax.transaction.TransactionManager

This is thrown from org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(Properties props)


This is called due to the following setting in my persistence.xml
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" /> 



All searches for the specific class cast exception, indicates that the problem is because there is a jta jar in the projects /WEB-INF/lib directory, but I have made sure that the jta jar is only in the Tomcat lib and I still get the error.

My related versions are

in Tomcat/lib
btm-2.1.3.jar
btm-tomcat55-lifecycle-2.1.3.jar
geronimo-jta_1.1_spec-1.1.1.jar
slf4j-api-1.6.4.jar
slf4j-jdk14-1.6.4.jar

Spring version is 3.0.5 RELEASE
Hibernate 3.6.1.Final

Tomcat 7.02








Reply | Threaded
Open this post in threaded view
|

Re: Cannot obtain BTM transaction manager instance on tomcat with hibernate and spring

Ludovic Orban-2
Is the geronimo-jta_1.1_spec-1.1.1.jar in your WEB-INF/lib folder? It basically is Geronimo's equivalent of Oracle's jta.jar so it contains the exact same classes, only with a more permissive license.

You should only have one of jta.jar or geronimo-jta.jar in your Tomcat lib folder and none of those in your WEB-INF/lib folder.

--
Ludovic

On Mon, Nov 26, 2012 at 12:05 PM, Travers Snyman <[hidden email]> wrote:


I am trying to use BTM as jta transaction manager in my Hibernate, Spring
based application running on Tomcat.

I believe my BTM setup on Tomcat is correct as I can see the following on
Tomcat startup:

26 Nov 2012 12:43:27 PM
bitronix.tm.integration.tomcat55.BTMLifecycleListener lifecycleEvent
INFO: Starting Bitronix Transaction Manager
26 Nov 2012 12:43:27 PM bitronix.tm.BitronixTransactionManager logVersion
INFO: Bitronix Transaction Manager version 2.1.3
26 Nov 2012 12:43:27 PM bitronix.tm.Configuration buildServerIdArray
INFO: JVM unique ID: <tomcat7-btm-node0 >
26 Nov 2012 12:43:27 PM bitronix.tm.resource.ResourceLoader init
INFO: reading resources configuration from
C:\devtools\apache-tomcat-7.0.2/conf/btm-resources.properties
26 Nov 2012 12:43:27 PM bitronix.tm.recovery.Recoverer run
INFO: recovery committed 0 dangling transaction(s) and rolled back 0 aborted
transaction(s) on 1 resource(s) [jdbc/jbpm-ds] (restricted to serverId
'tomcat7-btm-node0 ')
26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardService
startInternal
INFO: Starting service Catalina
26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardEngine
startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.2

The problem is however that I get an exception when the BTM transaction
manager is called:

bitronix.tm.BitronixTransactionManager cannot be cast to
javax.transaction.TransactionManager

This is thrown from
org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(Properties
props)


This is called due to the following setting in my persistence.xml
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.BTMTransactionManagerLookup" />



All searches for the specific class cast exception, indicates that the
problem is because there is a jta jar in the projects /WEB-INF/lib
directory, but I have made sure that the jta jar is only in the Tomcat lib
and I still get the error.

My related versions are

in Tomcat/lib
btm-2.1.3.jar
btm-tomcat55-lifecycle-2.1.3.jar
geronimo-jta_1.1_spec-1.1.1.jar
slf4j-api-1.6.4.jar
slf4j-jdk14-1.6.4.jar

Spring version is 3.0.5 RELEASE
Hibernate 3.6.1.Final

Tomcat 7.02









--
View this message in context: http://old.nabble.com/Cannot-obtain-BTM-transaction-manager-instance-on-tomcat-with-hibernate-and-spring-tp34722153p34722153.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



Reply | Threaded
Open this post in threaded view
|

Re: Cannot obtain BTM transaction manager instance on tomcat with hibernate and spring

Travers Snyman
Thanks for the reply,

Yes   geronimo-jta_1.1_spec-1.1.1.jar is only in the Tomcat lib directory. There are no jta jars in my WEB-INF/lib directory

Travers

Ludovic Orban-2 wrote
Is the geronimo-jta_1.1_spec-1.1.1.jar in your WEB-INF/lib folder? It
basically is Geronimo's equivalent of Oracle's jta.jar so it contains the
exact same classes, only with a more permissive license.

You should only have one of jta.jar or geronimo-jta.jar in your Tomcat lib
folder and none of those in your WEB-INF/lib folder.

--
Ludovic

On Mon, Nov 26, 2012 at 12:05 PM, Travers Snyman
<travers.snyman@epiuse.com>wrote:

>
>
> I am trying to use BTM as jta transaction manager in my Hibernate, Spring
> based application running on Tomcat.
>
> I believe my BTM setup on Tomcat is correct as I can see the following on
> Tomcat startup:
>
> 26 Nov 2012 12:43:27 PM
> bitronix.tm.integration.tomcat55.BTMLifecycleListener lifecycleEvent
> INFO: Starting Bitronix Transaction Manager
> 26 Nov 2012 12:43:27 PM bitronix.tm.BitronixTransactionManager logVersion
> INFO: Bitronix Transaction Manager version 2.1.3
> 26 Nov 2012 12:43:27 PM bitronix.tm.Configuration buildServerIdArray
> INFO: JVM unique ID: <tomcat7-btm-node0 >
> 26 Nov 2012 12:43:27 PM bitronix.tm.resource.ResourceLoader init
> INFO: reading resources configuration from
> C:\devtools\apache-tomcat-7.0.2/conf/btm-resources.properties
> 26 Nov 2012 12:43:27 PM bitronix.tm.recovery.Recoverer run
> INFO: recovery committed 0 dangling transaction(s) and rolled back 0
> aborted
> transaction(s) on 1 resource(s) [jdbc/jbpm-ds] (restricted to serverId
> 'tomcat7-btm-node0 ')
> 26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardService
> startInternal
> INFO: Starting service Catalina
> 26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardEngine
> startInternal
> INFO: Starting Servlet Engine: Apache Tomcat/7.0.2
>
> The problem is however that I get an exception when the BTM transaction
> manager is called:
>
> bitronix.tm.BitronixTransactionManager cannot be cast to
> javax.transaction.TransactionManager
>
> This is thrown from
>
> org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(Properties
> props)
>
>
> This is called due to the following setting in my persistence.xml
> <property name="hibernate.transaction.manager_lookup_class"
> value="org.hibernate.transaction.BTMTransactionManagerLookup" />
>
>
>
> All searches for the specific class cast exception, indicates that the
> problem is because there is a jta jar in the projects /WEB-INF/lib
> directory, but I have made sure that the jta jar is only in the Tomcat lib
> and I still get the error.
>
> My related versions are
>
> in Tomcat/lib
> btm-2.1.3.jar
> btm-tomcat55-lifecycle-2.1.3.jar
> geronimo-jta_1.1_spec-1.1.1.jar
> slf4j-api-1.6.4.jar
> slf4j-jdk14-1.6.4.jar
>
> Spring version is 3.0.5 RELEASE
> Hibernate 3.6.1.Final
>
> Tomcat 7.02
>
>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://old.nabble.com/Cannot-obtain-BTM-transaction-manager-instance-on-tomcat-with-hibernate-and-spring-tp34722153p34722153.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
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Cannot obtain BTM transaction manager instance on tomcat with hibernate and spring

Travers Snyman
I am really stuck with this problem at the moment. What I found if I put a breakpoint in the class
BTMTransactionManager and inspect the variables in the getTransactionManager, the invoked object
is in fact a BitronixTransactionManager, but cannot be cast to javax.transaction.TransactionManager

                        return (TransactionManager) clazz.getMethod("getTransactionManager",

throws the class cast ecxeption


Travers Snyman wrote
Thanks for the reply,

Yes   geronimo-jta_1.1_spec-1.1.1.jar is only in the Tomcat lib directory. There are no jta jars in my WEB-INF/lib directory

Travers

Ludovic Orban-2 wrote
Is the geronimo-jta_1.1_spec-1.1.1.jar in your WEB-INF/lib folder? It
basically is Geronimo's equivalent of Oracle's jta.jar so it contains the
exact same classes, only with a more permissive license.

You should only have one of jta.jar or geronimo-jta.jar in your Tomcat lib
folder and none of those in your WEB-INF/lib folder.

--
Ludovic

On Mon, Nov 26, 2012 at 12:05 PM, Travers Snyman
<travers.snyman@epiuse.com>wrote:

>
>
> I am trying to use BTM as jta transaction manager in my Hibernate, Spring
> based application running on Tomcat.
>
> I believe my BTM setup on Tomcat is correct as I can see the following on
> Tomcat startup:
>
> 26 Nov 2012 12:43:27 PM
> bitronix.tm.integration.tomcat55.BTMLifecycleListener lifecycleEvent
> INFO: Starting Bitronix Transaction Manager
> 26 Nov 2012 12:43:27 PM bitronix.tm.BitronixTransactionManager logVersion
> INFO: Bitronix Transaction Manager version 2.1.3
> 26 Nov 2012 12:43:27 PM bitronix.tm.Configuration buildServerIdArray
> INFO: JVM unique ID: <tomcat7-btm-node0 >
> 26 Nov 2012 12:43:27 PM bitronix.tm.resource.ResourceLoader init
> INFO: reading resources configuration from
> C:\devtools\apache-tomcat-7.0.2/conf/btm-resources.properties
> 26 Nov 2012 12:43:27 PM bitronix.tm.recovery.Recoverer run
> INFO: recovery committed 0 dangling transaction(s) and rolled back 0
> aborted
> transaction(s) on 1 resource(s) [jdbc/jbpm-ds] (restricted to serverId
> 'tomcat7-btm-node0 ')
> 26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardService
> startInternal
> INFO: Starting service Catalina
> 26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardEngine
> startInternal
> INFO: Starting Servlet Engine: Apache Tomcat/7.0.2
>
> The problem is however that I get an exception when the BTM transaction
> manager is called:
>
> bitronix.tm.BitronixTransactionManager cannot be cast to
> javax.transaction.TransactionManager
>
> This is thrown from
>
> org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(Properties
> props)
>
>
> This is called due to the following setting in my persistence.xml
> <property name="hibernate.transaction.manager_lookup_class"
> value="org.hibernate.transaction.BTMTransactionManagerLookup" />
>
>
>
> All searches for the specific class cast exception, indicates that the
> problem is because there is a jta jar in the projects /WEB-INF/lib
> directory, but I have made sure that the jta jar is only in the Tomcat lib
> and I still get the error.
>
> My related versions are
>
> in Tomcat/lib
> btm-2.1.3.jar
> btm-tomcat55-lifecycle-2.1.3.jar
> geronimo-jta_1.1_spec-1.1.1.jar
> slf4j-api-1.6.4.jar
> slf4j-jdk14-1.6.4.jar
>
> Spring version is 3.0.5 RELEASE
> Hibernate 3.6.1.Final
>
> Tomcat 7.02
>
>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://old.nabble.com/Cannot-obtain-BTM-transaction-manager-instance-on-tomcat-with-hibernate-and-spring-tp34722153p34722153.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
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Cannot obtain BTM transaction manager instance on tomcat with hibernate and spring

Ludovic Orban-2
I'm convinced this problem is caused by two related ClassLoaders loading different jta jars, this is the direction you should investigate first.

Here's a trick you can try in your debugging session:

 * Set a breakpoint in BTMTransactionManager again
 * Inspect the object returned by getTransactionManager(), it should be a BitronixTransactionManager
 * Call getClass() on that object, and getInterfaces() on the resulting class
 * Choose the javax.transaction.TransactionManager interface object, then call getClassLoader() on it
 * Cast the resulting object to URLClassLoader, and call getURLs() on it.
 * Display the URL(s), this should tell you where the JAR containing the javax.transaction.TransactionManager used by BTM is on disk. Write that down.
 * Call javax.transaction.TransactionManager.class.getClassLoader() from your debugger
 * Cast the resulting object to URLClassLoader, and call getURLs() on it.
 * Display the URL(s), this should tell you where the JAR containing the javax.transaction.TransactionManager used by BTM is on disk. Write that down too.

Normally, this should clearly show you from where the two different classes are loaded from.

I hope this helps.
Ludovic

On Mon, Nov 26, 2012 at 2:36 PM, Travers Snyman <[hidden email]> wrote:

I am really stuck with this problem at the moment. What I found if I put a
breakpoint in the class
BTMTransactionManager and inspect the variables in the
getTransactionManager, the invoked object
is in fact a BitronixTransactionManager, but cannot be cast to
javax.transaction.TransactionManager

                        return (TransactionManager) clazz.getMethod("getTransactionManager",

throws the class cast ecxeption



Travers Snyman wrote:
>
> Thanks for the reply,
>
> Yes   geronimo-jta_1.1_spec-1.1.1.jar is only in the Tomcat lib directory.
> There are no jta jars in my WEB-INF/lib directory
>
> Travers
>
>
> Ludovic Orban-2 wrote:
>>
>> Is the geronimo-jta_1.1_spec-1.1.1.jar in your WEB-INF/lib folder? It
>> basically is Geronimo's equivalent of Oracle's jta.jar so it contains the
>> exact same classes, only with a more permissive license.
>>
>> You should only have one of jta.jar or geronimo-jta.jar in your Tomcat
>> lib
>> folder and none of those in your WEB-INF/lib folder.
>>
>> --
>> Ludovic
>>
>> On Mon, Nov 26, 2012 at 12:05 PM, Travers Snyman
>> <[hidden email]>wrote:
>>
>>>
>>>
>>> I am trying to use BTM as jta transaction manager in my Hibernate,
>>> Spring
>>> based application running on Tomcat.
>>>
>>> I believe my BTM setup on Tomcat is correct as I can see the following
>>> on
>>> Tomcat startup:
>>>
>>> 26 Nov 2012 12:43:27 PM
>>> bitronix.tm.integration.tomcat55.BTMLifecycleListener lifecycleEvent
>>> INFO: Starting Bitronix Transaction Manager
>>> 26 Nov 2012 12:43:27 PM bitronix.tm.BitronixTransactionManager
>>> logVersion
>>> INFO: Bitronix Transaction Manager version 2.1.3
>>> 26 Nov 2012 12:43:27 PM bitronix.tm.Configuration buildServerIdArray
>>> INFO: JVM unique ID: <tomcat7-btm-node0 >
>>> 26 Nov 2012 12:43:27 PM bitronix.tm.resource.ResourceLoader init
>>> INFO: reading resources configuration from
>>> C:\devtools\apache-tomcat-7.0.2/conf/btm-resources.properties
>>> 26 Nov 2012 12:43:27 PM bitronix.tm.recovery.Recoverer run
>>> INFO: recovery committed 0 dangling transaction(s) and rolled back 0
>>> aborted
>>> transaction(s) on 1 resource(s) [jdbc/jbpm-ds] (restricted to serverId
>>> 'tomcat7-btm-node0 ')
>>> 26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardService
>>> startInternal
>>> INFO: Starting service Catalina
>>> 26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardEngine
>>> startInternal
>>> INFO: Starting Servlet Engine: Apache Tomcat/7.0.2
>>>
>>> The problem is however that I get an exception when the BTM transaction
>>> manager is called:
>>>
>>> bitronix.tm.BitronixTransactionManager cannot be cast to
>>> javax.transaction.TransactionManager
>>>
>>> This is thrown from
>>>
>>> org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(Properties
>>> props)
>>>
>>>
>>> This is called due to the following setting in my persistence.xml
>>> <property name="hibernate.transaction.manager_lookup_class"
>>> value="org.hibernate.transaction.BTMTransactionManagerLookup" />
>>>
>>>
>>>
>>> All searches for the specific class cast exception, indicates that the
>>> problem is because there is a jta jar in the projects /WEB-INF/lib
>>> directory, but I have made sure that the jta jar is only in the Tomcat
>>> lib
>>> and I still get the error.
>>>
>>> My related versions are
>>>
>>> in Tomcat/lib
>>> btm-2.1.3.jar
>>> btm-tomcat55-lifecycle-2.1.3.jar
>>> geronimo-jta_1.1_spec-1.1.1.jar
>>> slf4j-api-1.6.4.jar
>>> slf4j-jdk14-1.6.4.jar
>>>
>>> Spring version is 3.0.5 RELEASE
>>> Hibernate 3.6.1.Final
>>>
>>> Tomcat 7.02
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Cannot-obtain-BTM-transaction-manager-instance-on-tomcat-with-hibernate-and-spring-tp34722153p34722153.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
>>>
>>>
>>>
>>
>>
>
>

--
View this message in context: http://old.nabble.com/Cannot-obtain-BTM-transaction-manager-instance-on-tomcat-with-hibernate-and-spring-tp34722153p34722687.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



Reply | Threaded
Open this post in threaded view
|

Re: Cannot obtain BTM transaction manager instance on tomcat with hibernate and spring

Travers Snyman
Many thanks for the assistance.

I was thinking in the same lines and actually checked all my jars in WEB-INF/lib for the package javax.transaction.TransactionManager and found the potential culprit to be activemq-all-5.3.2.jar.

I am using an embedded activemq broker in the project and this jar is pulled by the maven dependency.

I could not pinpoint activemq to be the culprit with your trick below all the urls point to the jars in the tomcat lib directory of which only geronimo-jta_1.1_spec-1.1.1.jar contains javax.transaction.TransactionManager

If it is indeed the activemq jar, I don't know how to resolve the problem, but I can test by removing the javax package manually from the jar to see




Ludovic Orban-2 wrote
I'm convinced this problem is caused by two related ClassLoaders loading
different jta jars, this is the direction you should investigate first.

Here's a trick you can try in your debugging session:

 * Set a breakpoint in BTMTransactionManager again
 * Inspect the object returned by getTransactionManager(), it should be a
BitronixTransactionManager
 * Call getClass() on that object, and getInterfaces() on the resulting
class
 * Choose the javax.transaction.TransactionManager interface object, then
call getClassLoader() on it
 * Cast the resulting object to URLClassLoader, and call getURLs() on it.
 * Display the URL(s), this should tell you where the JAR containing the
javax.transaction.TransactionManager used by BTM is on disk. Write that
down.
 * Call javax.transaction.TransactionManager.class.getClassLoader() from
your debugger
 * Cast the resulting object to URLClassLoader, and call getURLs() on it.
 * Display the URL(s), this should tell you where the JAR containing the
javax.transaction.TransactionManager used by BTM is on disk. Write that
down too.

Normally, this should clearly show you from where the two different classes
are loaded from.

I hope this helps.
Ludovic

On Mon, Nov 26, 2012 at 2:36 PM, Travers Snyman
<travers.snyman@epiuse.com>wrote:

>
> I am really stuck with this problem at the moment. What I found if I put a
> breakpoint in the class
> BTMTransactionManager and inspect the variables in the
> getTransactionManager, the invoked object
> is in fact a BitronixTransactionManager, but cannot be cast to
> javax.transaction.TransactionManager
>
>                         return (TransactionManager)
> clazz.getMethod("getTransactionManager",
>
> throws the class cast ecxeption
>
>
>
> Travers Snyman wrote:
> >
> > Thanks for the reply,
> >
> > Yes   geronimo-jta_1.1_spec-1.1.1.jar is only in the Tomcat lib
> directory.
> > There are no jta jars in my WEB-INF/lib directory
> >
> > Travers
> >
> >
> > Ludovic Orban-2 wrote:
> >>
> >> Is the geronimo-jta_1.1_spec-1.1.1.jar in your WEB-INF/lib folder? It
> >> basically is Geronimo's equivalent of Oracle's jta.jar so it contains
> the
> >> exact same classes, only with a more permissive license.
> >>
> >> You should only have one of jta.jar or geronimo-jta.jar in your Tomcat
> >> lib
> >> folder and none of those in your WEB-INF/lib folder.
> >>
> >> --
> >> Ludovic
> >>
> >> On Mon, Nov 26, 2012 at 12:05 PM, Travers Snyman
> >> <travers.snyman@epiuse.com>wrote:
> >>
> >>>
> >>>
> >>> I am trying to use BTM as jta transaction manager in my Hibernate,
> >>> Spring
> >>> based application running on Tomcat.
> >>>
> >>> I believe my BTM setup on Tomcat is correct as I can see the following
> >>> on
> >>> Tomcat startup:
> >>>
> >>> 26 Nov 2012 12:43:27 PM
> >>> bitronix.tm.integration.tomcat55.BTMLifecycleListener lifecycleEvent
> >>> INFO: Starting Bitronix Transaction Manager
> >>> 26 Nov 2012 12:43:27 PM bitronix.tm.BitronixTransactionManager
> >>> logVersion
> >>> INFO: Bitronix Transaction Manager version 2.1.3
> >>> 26 Nov 2012 12:43:27 PM bitronix.tm.Configuration buildServerIdArray
> >>> INFO: JVM unique ID: <tomcat7-btm-node0 >
> >>> 26 Nov 2012 12:43:27 PM bitronix.tm.resource.ResourceLoader init
> >>> INFO: reading resources configuration from
> >>> C:\devtools\apache-tomcat-7.0.2/conf/btm-resources.properties
> >>> 26 Nov 2012 12:43:27 PM bitronix.tm.recovery.Recoverer run
> >>> INFO: recovery committed 0 dangling transaction(s) and rolled back 0
> >>> aborted
> >>> transaction(s) on 1 resource(s) [jdbc/jbpm-ds] (restricted to serverId
> >>> 'tomcat7-btm-node0 ')
> >>> 26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardService
> >>> startInternal
> >>> INFO: Starting service Catalina
> >>> 26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardEngine
> >>> startInternal
> >>> INFO: Starting Servlet Engine: Apache Tomcat/7.0.2
> >>>
> >>> The problem is however that I get an exception when the BTM transaction
> >>> manager is called:
> >>>
> >>> bitronix.tm.BitronixTransactionManager cannot be cast to
> >>> javax.transaction.TransactionManager
> >>>
> >>> This is thrown from
> >>>
> >>>
> org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(Properties
> >>> props)
> >>>
> >>>
> >>> This is called due to the following setting in my persistence.xml
> >>> <property name="hibernate.transaction.manager_lookup_class"
> >>> value="org.hibernate.transaction.BTMTransactionManagerLookup" />
> >>>
> >>>
> >>>
> >>> All searches for the specific class cast exception, indicates that the
> >>> problem is because there is a jta jar in the projects /WEB-INF/lib
> >>> directory, but I have made sure that the jta jar is only in the Tomcat
> >>> lib
> >>> and I still get the error.
> >>>
> >>> My related versions are
> >>>
> >>> in Tomcat/lib
> >>> btm-2.1.3.jar
> >>> btm-tomcat55-lifecycle-2.1.3.jar
> >>> geronimo-jta_1.1_spec-1.1.1.jar
> >>> slf4j-api-1.6.4.jar
> >>> slf4j-jdk14-1.6.4.jar
> >>>
> >>> Spring version is 3.0.5 RELEASE
> >>> Hibernate 3.6.1.Final
> >>>
> >>> Tomcat 7.02
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> --
> >>> View this message in context:
> >>>
> http://old.nabble.com/Cannot-obtain-BTM-transaction-manager-instance-on-tomcat-with-hibernate-and-spring-tp34722153p34722153.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
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/Cannot-obtain-BTM-transaction-manager-instance-on-tomcat-with-hibernate-and-spring-tp34722153p34722687.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
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Cannot obtain BTM transaction manager instance on tomcat with hibernate and spring

Travers Snyman
That was the problem,
By manually removing the package javax.transaction from the activemq jar resolved the issue. I must now just find a clean way of implementing it.


Travers Snyman wrote
Many thanks for the assistance.

I was thinking in the same lines and actually checked all my jars in WEB-INF/lib for the package javax.transaction.TransactionManager and found the potential culprit to be activemq-all-5.3.2.jar.

I am using an embedded activemq broker in the project and this jar is pulled by the maven dependency.

I could not pinpoint activemq to be the culprit with your trick below all the urls point to the jars in the tomcat lib directory of which only geronimo-jta_1.1_spec-1.1.1.jar contains javax.transaction.TransactionManager

If it is indeed the activemq jar, I don't know how to resolve the problem, but I can test by removing the javax package manually from the jar to see




Ludovic Orban-2 wrote
I'm convinced this problem is caused by two related ClassLoaders loading
different jta jars, this is the direction you should investigate first.

Here's a trick you can try in your debugging session:

 * Set a breakpoint in BTMTransactionManager again
 * Inspect the object returned by getTransactionManager(), it should be a
BitronixTransactionManager
 * Call getClass() on that object, and getInterfaces() on the resulting
class
 * Choose the javax.transaction.TransactionManager interface object, then
call getClassLoader() on it
 * Cast the resulting object to URLClassLoader, and call getURLs() on it.
 * Display the URL(s), this should tell you where the JAR containing the
javax.transaction.TransactionManager used by BTM is on disk. Write that
down.
 * Call javax.transaction.TransactionManager.class.getClassLoader() from
your debugger
 * Cast the resulting object to URLClassLoader, and call getURLs() on it.
 * Display the URL(s), this should tell you where the JAR containing the
javax.transaction.TransactionManager used by BTM is on disk. Write that
down too.

Normally, this should clearly show you from where the two different classes
are loaded from.

I hope this helps.
Ludovic

On Mon, Nov 26, 2012 at 2:36 PM, Travers Snyman
<travers.snyman@epiuse.com>wrote:

>
> I am really stuck with this problem at the moment. What I found if I put a
> breakpoint in the class
> BTMTransactionManager and inspect the variables in the
> getTransactionManager, the invoked object
> is in fact a BitronixTransactionManager, but cannot be cast to
> javax.transaction.TransactionManager
>
>                         return (TransactionManager)
> clazz.getMethod("getTransactionManager",
>
> throws the class cast ecxeption
>
>
>
> Travers Snyman wrote:
> >
> > Thanks for the reply,
> >
> > Yes   geronimo-jta_1.1_spec-1.1.1.jar is only in the Tomcat lib
> directory.
> > There are no jta jars in my WEB-INF/lib directory
> >
> > Travers
> >
> >
> > Ludovic Orban-2 wrote:
> >>
> >> Is the geronimo-jta_1.1_spec-1.1.1.jar in your WEB-INF/lib folder? It
> >> basically is Geronimo's equivalent of Oracle's jta.jar so it contains
> the
> >> exact same classes, only with a more permissive license.
> >>
> >> You should only have one of jta.jar or geronimo-jta.jar in your Tomcat
> >> lib
> >> folder and none of those in your WEB-INF/lib folder.
> >>
> >> --
> >> Ludovic
> >>
> >> On Mon, Nov 26, 2012 at 12:05 PM, Travers Snyman
> >> <travers.snyman@epiuse.com>wrote:
> >>
> >>>
> >>>
> >>> I am trying to use BTM as jta transaction manager in my Hibernate,
> >>> Spring
> >>> based application running on Tomcat.
> >>>
> >>> I believe my BTM setup on Tomcat is correct as I can see the following
> >>> on
> >>> Tomcat startup:
> >>>
> >>> 26 Nov 2012 12:43:27 PM
> >>> bitronix.tm.integration.tomcat55.BTMLifecycleListener lifecycleEvent
> >>> INFO: Starting Bitronix Transaction Manager
> >>> 26 Nov 2012 12:43:27 PM bitronix.tm.BitronixTransactionManager
> >>> logVersion
> >>> INFO: Bitronix Transaction Manager version 2.1.3
> >>> 26 Nov 2012 12:43:27 PM bitronix.tm.Configuration buildServerIdArray
> >>> INFO: JVM unique ID: <tomcat7-btm-node0 >
> >>> 26 Nov 2012 12:43:27 PM bitronix.tm.resource.ResourceLoader init
> >>> INFO: reading resources configuration from
> >>> C:\devtools\apache-tomcat-7.0.2/conf/btm-resources.properties
> >>> 26 Nov 2012 12:43:27 PM bitronix.tm.recovery.Recoverer run
> >>> INFO: recovery committed 0 dangling transaction(s) and rolled back 0
> >>> aborted
> >>> transaction(s) on 1 resource(s) [jdbc/jbpm-ds] (restricted to serverId
> >>> 'tomcat7-btm-node0 ')
> >>> 26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardService
> >>> startInternal
> >>> INFO: Starting service Catalina
> >>> 26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardEngine
> >>> startInternal
> >>> INFO: Starting Servlet Engine: Apache Tomcat/7.0.2
> >>>
> >>> The problem is however that I get an exception when the BTM transaction
> >>> manager is called:
> >>>
> >>> bitronix.tm.BitronixTransactionManager cannot be cast to
> >>> javax.transaction.TransactionManager
> >>>
> >>> This is thrown from
> >>>
> >>>
> org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(Properties
> >>> props)
> >>>
> >>>
> >>> This is called due to the following setting in my persistence.xml
> >>> <property name="hibernate.transaction.manager_lookup_class"
> >>> value="org.hibernate.transaction.BTMTransactionManagerLookup" />
> >>>
> >>>
> >>>
> >>> All searches for the specific class cast exception, indicates that the
> >>> problem is because there is a jta jar in the projects /WEB-INF/lib
> >>> directory, but I have made sure that the jta jar is only in the Tomcat
> >>> lib
> >>> and I still get the error.
> >>>
> >>> My related versions are
> >>>
> >>> in Tomcat/lib
> >>> btm-2.1.3.jar
> >>> btm-tomcat55-lifecycle-2.1.3.jar
> >>> geronimo-jta_1.1_spec-1.1.1.jar
> >>> slf4j-api-1.6.4.jar
> >>> slf4j-jdk14-1.6.4.jar
> >>>
> >>> Spring version is 3.0.5 RELEASE
> >>> Hibernate 3.6.1.Final
> >>>
> >>> Tomcat 7.02
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> --
> >>> View this message in context:
> >>>
> http://old.nabble.com/Cannot-obtain-BTM-transaction-manager-instance-on-tomcat-with-hibernate-and-spring-tp34722153p34722153.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
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/Cannot-obtain-BTM-transaction-manager-instance-on-tomcat-with-hibernate-and-spring-tp34722153p34722687.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
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Cannot obtain BTM transaction manager instance on tomcat with hibernate and spring

Brett Wooldridge-2
If the activemq jar is always going to be present, you can just eliminate the geronimo jar, right?

Sent from my iPhone

On Nov 27, 2012, at 12:20 AM, Travers Snyman <[hidden email]> wrote:

>
> That was the problem,
> By manually removing the package javax.transaction from the activemq jar
> resolved the issue. I must now just find a clean way of implementing it.
>
>
>
> Travers Snyman wrote:
>>
>> Many thanks for the assistance.
>>
>> I was thinking in the same lines and actually checked all my jars in
>> WEB-INF/lib for the package javax.transaction.TransactionManager and found
>> the potential culprit to be activemq-all-5.3.2.jar.
>>
>> I am using an embedded activemq broker in the project and this jar is
>> pulled by the maven dependency.
>>
>> I could not pinpoint activemq to be the culprit with your trick below all
>> the urls point to the jars in the tomcat lib directory of which only
>> geronimo-jta_1.1_spec-1.1.1.jar contains
>> javax.transaction.TransactionManager
>>
>> If it is indeed the activemq jar, I don't know how to resolve the problem,
>> but I can test by removing the javax package manually from the jar to see
>>
>>
>>
>>
>>
>> Ludovic Orban-2 wrote:
>>>
>>> I'm convinced this problem is caused by two related ClassLoaders loading
>>> different jta jars, this is the direction you should investigate first.
>>>
>>> Here's a trick you can try in your debugging session:
>>>
>>> * Set a breakpoint in BTMTransactionManager again
>>> * Inspect the object returned by getTransactionManager(), it should be a
>>> BitronixTransactionManager
>>> * Call getClass() on that object, and getInterfaces() on the resulting
>>> class
>>> * Choose the javax.transaction.TransactionManager interface object, then
>>> call getClassLoader() on it
>>> * Cast the resulting object to URLClassLoader, and call getURLs() on it.
>>> * Display the URL(s), this should tell you where the JAR containing the
>>> javax.transaction.TransactionManager used by BTM is on disk. Write that
>>> down.
>>> * Call javax.transaction.TransactionManager.class.getClassLoader() from
>>> your debugger
>>> * Cast the resulting object to URLClassLoader, and call getURLs() on it.
>>> * Display the URL(s), this should tell you where the JAR containing the
>>> javax.transaction.TransactionManager used by BTM is on disk. Write that
>>> down too.
>>>
>>> Normally, this should clearly show you from where the two different
>>> classes
>>> are loaded from.
>>>
>>> I hope this helps.
>>> Ludovic
>>>
>>> On Mon, Nov 26, 2012 at 2:36 PM, Travers Snyman
>>> <[hidden email]>wrote:
>>>
>>>>
>>>> I am really stuck with this problem at the moment. What I found if I put
>>>> a
>>>> breakpoint in the class
>>>> BTMTransactionManager and inspect the variables in the
>>>> getTransactionManager, the invoked object
>>>> is in fact a BitronixTransactionManager, but cannot be cast to
>>>> javax.transaction.TransactionManager
>>>>
>>>>                        return (TransactionManager)
>>>> clazz.getMethod("getTransactionManager",
>>>>
>>>> throws the class cast ecxeption
>>>>
>>>>
>>>>
>>>> Travers Snyman wrote:
>>>>>
>>>>> Thanks for the reply,
>>>>>
>>>>> Yes   geronimo-jta_1.1_spec-1.1.1.jar is only in the Tomcat lib
>>>> directory.
>>>>> There are no jta jars in my WEB-INF/lib directory
>>>>>
>>>>> Travers
>>>>>
>>>>>
>>>>> Ludovic Orban-2 wrote:
>>>>>>
>>>>>> Is the geronimo-jta_1.1_spec-1.1.1.jar in your WEB-INF/lib folder? It
>>>>>> basically is Geronimo's equivalent of Oracle's jta.jar so it contains
>>>> the
>>>>>> exact same classes, only with a more permissive license.
>>>>>>
>>>>>> You should only have one of jta.jar or geronimo-jta.jar in your
>>>> Tomcat
>>>>>> lib
>>>>>> folder and none of those in your WEB-INF/lib folder.
>>>>>>
>>>>>> --
>>>>>> Ludovic
>>>>>>
>>>>>> On Mon, Nov 26, 2012 at 12:05 PM, Travers Snyman
>>>>>> <[hidden email]>wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> I am trying to use BTM as jta transaction manager in my Hibernate,
>>>>>>> Spring
>>>>>>> based application running on Tomcat.
>>>>>>>
>>>>>>> I believe my BTM setup on Tomcat is correct as I can see the
>>>> following
>>>>>>> on
>>>>>>> Tomcat startup:
>>>>>>>
>>>>>>> 26 Nov 2012 12:43:27 PM
>>>>>>> bitronix.tm.integration.tomcat55.BTMLifecycleListener lifecycleEvent
>>>>>>> INFO: Starting Bitronix Transaction Manager
>>>>>>> 26 Nov 2012 12:43:27 PM bitronix.tm.BitronixTransactionManager
>>>>>>> logVersion
>>>>>>> INFO: Bitronix Transaction Manager version 2.1.3
>>>>>>> 26 Nov 2012 12:43:27 PM bitronix.tm.Configuration buildServerIdArray
>>>>>>> INFO: JVM unique ID: <tomcat7-btm-node0 >
>>>>>>> 26 Nov 2012 12:43:27 PM bitronix.tm.resource.ResourceLoader init
>>>>>>> INFO: reading resources configuration from
>>>>>>> C:\devtools\apache-tomcat-7.0.2/conf/btm-resources.properties
>>>>>>> 26 Nov 2012 12:43:27 PM bitronix.tm.recovery.Recoverer run
>>>>>>> INFO: recovery committed 0 dangling transaction(s) and rolled back 0
>>>>>>> aborted
>>>>>>> transaction(s) on 1 resource(s) [jdbc/jbpm-ds] (restricted to
>>>> serverId
>>>>>>> 'tomcat7-btm-node0 ')
>>>>>>> 26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardService
>>>>>>> startInternal
>>>>>>> INFO: Starting service Catalina
>>>>>>> 26 Nov 2012 12:43:27 PM org.apache.catalina.core.StandardEngine
>>>>>>> startInternal
>>>>>>> INFO: Starting Servlet Engine: Apache Tomcat/7.0.2
>>>>>>>
>>>>>>> The problem is however that I get an exception when the BTM
>>>> transaction
>>>>>>> manager is called:
>>>>>>>
>>>>>>> bitronix.tm.BitronixTransactionManager cannot be cast to
>>>>>>> javax.transaction.TransactionManager
>>>>>>>
>>>>>>> This is thrown from
>>>> org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(Properties
>>>>>>> props)
>>>>>>>
>>>>>>>
>>>>>>> This is called due to the following setting in my persistence.xml
>>>>>>> <property name="hibernate.transaction.manager_lookup_class"
>>>>>>> value="org.hibernate.transaction.BTMTransactionManagerLookup" />
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> All searches for the specific class cast exception, indicates that
>>>> the
>>>>>>> problem is because there is a jta jar in the projects /WEB-INF/lib
>>>>>>> directory, but I have made sure that the jta jar is only in the
>>>> Tomcat
>>>>>>> lib
>>>>>>> and I still get the error.
>>>>>>>
>>>>>>> My related versions are
>>>>>>>
>>>>>>> in Tomcat/lib
>>>>>>> btm-2.1.3.jar
>>>>>>> btm-tomcat55-lifecycle-2.1.3.jar
>>>>>>> geronimo-jta_1.1_spec-1.1.1.jar
>>>>>>> slf4j-api-1.6.4.jar
>>>>>>> slf4j-jdk14-1.6.4.jar
>>>>>>>
>>>>>>> Spring version is 3.0.5 RELEASE
>>>>>>> Hibernate 3.6.1.Final
>>>>>>>
>>>>>>> Tomcat 7.02
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>> http://old.nabble.com/Cannot-obtain-BTM-transaction-manager-instance-on-tomcat-with-hibernate-and-spring-tp34722153p34722153.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
>>>>
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/Cannot-obtain-BTM-transaction-manager-instance-on-tomcat-with-hibernate-and-spring-tp34722153p34722687.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
>
> --
> View this message in context: http://old.nabble.com/Cannot-obtain-BTM-transaction-manager-instance-on-tomcat-with-hibernate-and-spring-tp34722153p34723230.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
>
>

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

    http://xircles.codehaus.org/manage_email