Results 1 to 7 of 7

Thread: JtaTransactionManager depends on aopalliance.jar?

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    San Diego, CA
    Posts
    49

    Default JtaTransactionManager depends on aopalliance.jar?

    Not really a problem, I was just suprised to get the following error when using JtaTransactionManager programmatically with the following bean defintion (I only had spring.jar in my classpath):

    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTran sactionManager" />

    The error was:
    Code:
    org.springframework.beans.factory.BeanDefinitionStoreException&#58; Error registering bean with name 'transactionManager' defined in class path resource &#91;com/somepackage/ApplicationContext.xml&#93;&#58; Class that bean class &#91;org.springframework.transaction.jta.JtaTransactionManager&#93; depends on not found; nested exception is java.lang.NoClassDefFoundError&#58; org/aopalliance/aop/AspectException
    java.lang.NoClassDefFoundError&#58; org/aopalliance/aop/AspectException
            at java.lang.Class.forName0&#40;Native Method&#41;
            at java.lang.Class.forName&#40;Class.java&#58;219&#41;
            at org.springframework.beans.factory.support.BeanDefinitionReaderUtils.createBeanDefinition&#40;BeanDefinitionReaderUtils.java&#58;50&#41;
    ...
    I added aopalliance.jar to my classpath and it took care of the problem. Is it expected that this is a required dependency? Is it generally accepted that we should add all the supporting libs to the classpath, or just add them piecemeal as dependencies show themselves through errors like this?

    Cheers,

    Tim

  2. #2
    Join Date
    Aug 2004
    Posts
    218

    Default

    I pretty much add them as needed due to the fact that we don't implement the whole spring framework. Like you, I needed to add the aopalliance.jar to use the interceptors, but that's been it so far.

    Best,
    Lou

  3. #3
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    Loumeister & Loumeister,

    To implement Transaction using AOP, TransactionProxyFactoryBean uses internaly a TransactionInterceptor. the later extends TransactionAspectSupport that has a method readObject used for serialization.
    Code:
    	private void readObject&#40;ObjectInputStream ois&#41; throws IOException &#123;
    		// Rely on default serialization, just initialize state after deserialization
    		try &#123;
    			ois.defaultReadObject&#40;&#41;;
    		&#125;
    		catch &#40;ClassNotFoundException ex&#41; &#123;
    			throw new AspectException&#40;"Failed to deserialize Spring AOP transaction aspect&#58;" +
    					"Check that Spring AOP libraries are available on the client side", ex&#41;;
    		&#125;
    		
    		// Initialize transient fields
    		this.logger = LogFactory.getLog&#40;getClass&#40;&#41;&#41;;
    	&#125;
    Throwing a AspectException makes transaction management in Spring depends on aopalliance.jar.
    I think this should be documented somewhere in Spring documentation and readme.txt (spring libraries dependencies)
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  4. #4
    Join Date
    Aug 2004
    Location
    Linz, Austria
    Posts
    391

    Default

    In general, you need aopalliance.jar when working with Spring's AOP framework, whether directly or indirectly. However, JtaTransactionManager shouldn't depend on AOP Alliance: That has to be considered a bug. I've just fixed it: It was just an accidental use of the AOP Alliance AspectException that was straightforward to be replace.

    Juergen

  5. #5
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    Oups, I am sorry for the confusion, I was looking at two many classes in the same times.
    indeed, JtaTransactionManager has a readObject method:
    Code:
    	private void readObject&#40;ObjectInputStream ois&#41; throws IOException &#123;
    		// rely on default serialization, just initialize state after deserialization
    		try &#123;
    			ois.defaultReadObject&#40;&#41;;
    		&#125;
    		catch &#40;ClassNotFoundException ex&#41; &#123;
    			throw new AspectException&#40;"Failed to deserialize JtaTransactionManager&#58; " +
    																"Check that JTA and Spring transaction libraries are available on the client side", ex&#41;;
    		&#125;
    		// do client-side JNDI lookup
    		this.jndiTemplate = new JndiTemplate&#40;&#41;;
    		// run lookup code for UserTransaction
    		this.userTransaction = lookupUserTransaction&#40;this.userTransactionName&#41;;
    	&#125;
    that depends on aopapplicane.jar
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  6. #6
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Sorry--my fault. Juergen's now fixed it for 1.1 final. Thanks for the feedback!
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  7. #7
    Join Date
    Sep 2004
    Location
    San Diego, CA
    Posts
    49

    Default

    Now that's great service!

    Cheers,

    Tim

Similar Threads

  1. Why depends spring on hibernate 2.1?
    By hiberman in forum Data
    Replies: 2
    Last Post: Aug 23rd, 2005, 02:15 PM
  2. Does Spring 1.1 depends on Xerces ?
    By antonypaul in forum Container
    Replies: 7
    Last Post: Jun 3rd, 2005, 07:30 AM
  3. A depends on B depends on A
    By Edward Kenworthy in forum Container
    Replies: 4
    Last Post: Jan 23rd, 2005, 06:56 AM
  4. PropertyResourceConfigurer depends on another
    By ketan in forum Container
    Replies: 3
    Last Post: Dec 23rd, 2004, 07:20 PM
  5. aopalliance.jar license.
    By ajoseph in forum AOP
    Replies: 6
    Last Post: Sep 29th, 2004, 09:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •