Finding a JTA UserTransaction

Last time we had an issue where at deploy time, our .war project couldn’t find a JTA UserTransaction.  Let’s see if we can get to the bottom of that.

Just now, I tried changing around the bean-loading in my startup service so that the applicationContext.xml is the explicit parent of the spring-SimplePersonDAO.xml (see yesterdays’ post, the “Explicitly specify the parent?” section).  Result: same error, still no JTA UserTransaction available.

Now it doesn’t work with just JMS either

Yesterday afternoon before I went home I also tried disabling all the Hibernate stuff in my project to see if the XA transaction containing only a JMS transaction still worked.  I got the same error — no JTA UserTransaction available.

And now that I think of it, I’m not seeing those two lines we used to see in the JBoss console:

08:09:27,205 INFO  [JtaTransactionManager] Using JTA UserTransaction: org.jboss.tm.usertx.client.ServerVMClientUserTransaction@1906773
08:09:27,221 INFO  [JtaTransactionManager] Using JTA TransactionManager: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@1d008ff

I wonder why those lines went away?  Before, just adding something like unto this in my Spring bean file made those lines show up:

<tx:jta-transaction-manager />

So why is it no longer having that effect?

Could it be duplicate-deployed classes in my .war file, AGAIN?

I did a search with JarSearch for classes containing “Jta”, and didn’t find any duplicates.  (I also searched for duplicate classes of any name using jcFind, but maybe I’ll write that up later.)  So let’s try a different approach.

Last Known Good version still works

I checked out the last version of my .war project that I had committed, to a new, separate project — I checked it over and there was no Hibernate stuff in it, just JMS and XA stuff.  I built-n-deployed this, and the Using JTA UserTransaction/Using JTA TransactionManager messages are there again.  So, it looks like it was something between then and now that made the JTA stuff stop working.  I guess I’ll comment all the Hibernate stuff out in my current version of the project (true, it didn’t work when I tried it yesterday but it was at about 4:45pm and I was tired) to see if I can get the JMS stuff working again.

Still blows up without the Hibernate beans file

I modified my Startup service class to only load applicationContext.xml and to ignore the spring-SimplePersonDAO.xml beans file, redeployed, and I get the same error.

But by taking out the dependencies from the pom file…

Next I commented out the additional dependencies I had added to the project pom file.  I also had to comment out the guts of my SimplePersonDAO class since it could no longer tell what a Hibernate SessionFactory  was (I now remember that I stopped short of this yesterday).  I deployed the result and… my .war project finds the JTA UserTransaction and TransactionManager again, like in the good old days!

Let’s start adding those dependencies back in, and see where we see the problem again:

Hibernate + cglib-nodep and the error returns!

I added the following back into my pom file:

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.6.ga</version>
<exclusions>
<exclusion>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
</dependency>

And now when I deploy, I get the same JTA availability errors as before.

Spring-orm + spring-jdbc dependencies appear ok

If I comment those dependencies out again and uncomment the remaining ones I added:

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${springFramework.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${springFramework.version}</version>
</dependency>
…then when I deploy, I *don’t* get the JTA errors.

I additionally enable our cglib-nodep dependency, and still no JTA errors.

Looks like the Hibernate dependency is the causing the issue

But now when we enable the dependency on Hibernate, we get the error again (even when the cglib-nodep dependency is not enabled).  So it really does look like the problem is with something the Hibernate dependency brings in.

Tracking Down the Hibernate Transitive Dependency

Looking in my local Maven repository for the hibernate artifact, I see a hibernate-3.2.6.ga.pom.  Let’s look in there and see if there are any suspicious-looking dependencies that seem like they might be causing this issue.

First guess: jta artifact

I see a javax.transaction|jta artifact:

<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.0.1B</version>
</dependency>
Seems like that could be gumming up the works, if there was already javax.transaction stuff out there and Hibernate brought in some more… but JarSearch doesn’t show any javax.transaction classes in the .war file other than in that jar.

[Update 10/8/2008: This was in fact the issue.  See the solution and the discussion of why we missed the solution the first time ]

Other dependencies:

asm-attrs 1.5.3…

Taking a look at asm-attrs

Hmm, JarSearching for attrs in the JBoss server\default\deploy directory, I see asm.attrs classes in two different places, asm-attrs-1.5.3.jar and cglib-nodep-2.1_3.jar.  I wonder if Hibernate’s dependency on asm-attrs is bringing in the wrong version of those classes.  It seems to me that Keith said something about JBoss itself relying on a certain version of some these classes, and that’s why we needed to rely on cglib-nodep instead of the regular cglib.

Forcing asm-attrs to be version 2.2.3. ain’t enough

Maybe as a start, I’ll add asm-attrs to the dependencyManagement section of my pom file with a version of 2.2.3.  (That’s the version that’s in the parent pom file we’re using elsewhere in the system, and my guess is Keith had a reason for putting that in there.)

Ok, how about if we say asm-attrs will be provided?

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.6.ga</version>
<exclusions>
<exclusion>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</exclusion>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm-attrs</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>asm</groupId>
<artifactId>asm-attrs</artifactId>
<scope>provided</scope>
</dependency>

Nope, same error.

Using the Maven dependency plugin

When I run the maven dependency:tree goal, I get output like this:

[INFO] [dependency:tree]
[INFO] com.example.research.xa:xa-example:war:1-SNAPSHOT
[INFO] +- org.apache.cxf:cxf-rt-core:jar:2.1:compile
[INFO] |  +- org.apache.cxf:cxf-api:jar:2.1:compile
[INFO] |  |  +- org.apache.geronimo.specs:geronimo-activation_1.1_spec:jar:1.0.2:compile
[INFO] |  |  +- org.apache.cxf:cxf-common-utilities:jar:2.1:compile
[INFO] |  |  |  +- org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:compile
[INFO] |  |  |  +- wsdl4j:wsdl4j:jar:1.6.1:compile
[INFO] |  |  |  +- xml-resolver:xml-resolver:jar:1.2:compile
[INFO] |  |  |  \- commons-lang:commons-lang:jar:2.4:compile
[INFO] |  |  +- org.apache.geronimo.specs:geronimo-annotation_1.0_spec:jar:1.1.1:compile
[INFO] |  |  +- org.codehaus.woodstox:wstx-asl:jar:3.2.4:compile
[INFO] |  |  +- org.apache.neethi:neethi:jar:2.0.4:compile
[INFO] |  |  \- org.apache.cxf:cxf-common-schemas:jar:2.1:compile
[INFO] |  +- com.sun.xml.bind:jaxb-impl:jar:2.1.6:compile
[INFO] |  +- org.apache.ws.commons.schema:XmlSchema:jar:1.4.2:compile
[INFO] |  +- org.springframework:spring-core:jar:2.5.5:compile
[INFO] |  +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.3:compile
[INFO] |  \- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.2:compile
[INFO] +- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.1:compile
[INFO] |  +- javax.xml.ws:jaxws-api:jar:2.1-1:compile
[INFO] |  +- asm:asm:jar:2.2.3:compile
[INFO] |  +- org.apache.cxf:cxf-rt-bindings-soap:jar:2.1:compile
[INFO] |  |  +- org.apache.cxf:cxf-tools-common:jar:2.1:compile
[INFO] |  |  |  +- velocity:velocity:jar:1.4:compile
[INFO] |  |  |  |  \- velocity:velocity-dep:jar:1.4:runtime
[INFO] |  |  |  +- com.sun.xml.bind:jaxb-xjc:jar:2.1.6:compile
[INFO] |  |  |  \- org.apache.geronimo.specs:geronimo-ws-metadata_2.0_spec:jar:1.1.2:compile
[INFO] |  |  +- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.1:compile
[INFO] |  |  \- javax.xml.bind:jaxb-api:jar:2.1:compile
[INFO] |  +- org.apache.cxf:cxf-rt-bindings-xml:jar:2.1:compile
[INFO] |  +- org.apache.cxf:cxf-rt-frontend-simple:jar:2.1:compile
[INFO] |  +- org.apache.cxf:cxf-rt-ws-addr:jar:2.1:compile
[INFO] |  +- javax.xml.soap:saaj-api:jar:1.3:compile
[INFO] |  \- com.sun.xml.messaging.saaj:saaj-impl:jar:1.3:compile
[INFO] +- org.apache.cxf:cxf-rt-transports-http:jar:2.1:compile
[INFO] |  \- org.springframework:spring-web:jar:2.5.5:compile (version managed from 2.0.8)
[INFO] +- javax.servlet:servlet-api:jar:2.3:provided
[INFO] +- org.apache.xbean:xbean-spring:jar:3.3:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.0.3:compile
[INFO] +- log4j:log4j:jar:1.2.15:provided
[INFO] +- org.apache.activemq:activemq-core:jar:5.1.0:provided
[INFO] |  +- commons-logging:commons-logging-api:jar:1.1:provided
[INFO] |  +- org.apache.camel:camel-core:jar:1.3.0:provided
[INFO] |  +- org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.0:provided (version managed from 1.1.1)
[INFO] |  \- org.apache.geronimo.specs:geronimo-j2ee-management_1.0_spec:jar:1.0:provided
[INFO] +- org.springframework:spring-tx:jar:2.5.5:compile
[INFO] |  +- org.springframework:spring-beans:jar:2.5.5:compile
[INFO] |  \- org.springframework:spring-context:jar:2.5.5:compile
[INFO] +- org.springframework:spring-jms:jar:2.5.5:compile
[INFO] |  +- commons-pool:commons-pool:jar:1.3:compile
[INFO] |  \- org.springframework:spring-context-support:jar:2.5.5:compile
[INFO] +- org.springframework:spring-aop:jar:2.5.5:compile
[INFO] |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-aspects:jar:2.5.5:compile
[INFO] |  +- org.aspectj:aspectjrt:jar:1.6.0:compile
[INFO] |  \- org.aspectj:aspectjweaver:jar:1.6.0:compile
[INFO] +- org.hibernate:hibernate:jar:3.2.6.ga:compile
[INFO] |  +- net.sf.ehcache:ehcache:jar:1.2.3:compile
[INFO] |  +- javax.transaction:jta:jar:1.0.1B:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  \- commons-collections:commons-collections:jar:2.1.1:compile
[INFO] +- cglib:cglib-nodep:jar:2.1_3:compile
[INFO] +- asm:asm-attrs:jar:2.2.3:provided
[INFO] +- org.springframework:spring-orm:jar:2.5.5:compile
[INFO] \- org.springframework:spring-jdbc:jar:2.5.5:compile

Notice how at the base level, asm-attrs is marked “provided”, but it’s also marked as a dependency of cxf-rt-frontend-jaxws?

One last failed attempt for the day

Just in case the asm jar file is causing problems, let’s do this:

  • Added this to the dependencyManagement section:

<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>2.2.3</version>
</dependency>

  • Added this to the cxf-rt-frontend-jaxws dependency in the dependencies section:

<exclusions>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>

  • Added this to the dependencies section:

<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<scope>provided</scope>
</dependency>

Same issue though.  Well, that’s all we have time for today!  Tune in next time

Advertisements

, , ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s