Results 1 to 4 of 4

Thread: Problem with <tx:annotation-driven/> and JPA with Spring 2 RC3

  1. #1
    Join Date
    Jul 2006
    Location
    Germany, Hamburg
    Posts
    8

    Default Problem with <tx:annotation-driven/> and JPA with Spring 2 RC3

    Dear all,

    I transferred my working code from Spring 2.0 RC2 to RC3 and yield problems by using <tx:annotation-driven /> in conjunction with a LocalContainerEntityManagerFactoryBean. This was the error:

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor': Instantiation of bean failed; nested exception is java.lang.NullPointerException
    Caused by: java.lang.NullPointerException
    	at org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor$TransactionAttributeSourcePointcut.getTransactionAttributeSource(TransactionAttributeSourceAdvisor.java:102)
    	at org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor$TransactionAttributeSourcePointcut.hashCode(TransactionAttributeSourceAdvisor.java:121)
    	at java.lang.Object.toString(Object.java:209)
    	at java.lang.String.valueOf(String.java:2577)
    	at java.lang.StringBuffer.append(StringBuffer.java:220)
    	at org.springframework.aop.support.AbstractPointcutAdvisor.toString(AbstractPointcutAdvisor.java:71)
    	at java.lang.String.valueOf(String.java:2577)
    	at java.lang.StringBuffer.append(StringBuffer.java:220)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:383)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:242)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:239)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:155)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:303)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:68)
    	at de.oc.test.AppContextTest.testname(AppContextTest.java:23)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at junit.framework.TestCase.runTest(TestCase.java:154)
    	at junit.framework.TestCase.runBare(TestCase.java:127)
    	at junit.framework.TestResult$1.protect(TestResult.java:106)
    	at junit.framework.TestResult.runProtected(TestResult.java:124)
    	at junit.framework.TestResult.run(TestResult.java:109)
    	at junit.framework.TestCase.run(TestCase.java:118)
    	at junit.framework.TestSuite.runTest(TestSuite.java:208)
    	at junit.framework.TestSuite.run(TestSuite.java:203)
    	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
    	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Do I miss some additional configurations which may be added by RC3 or is this a bug?

    Thanking in advance
    Oliver-Arne

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Can you please raise an issue on JIRA - seems to be a bug (even if you are missing something you shouldn't get a NPE)?
    Thanks!.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Jul 2006
    Location
    Germany, Hamburg
    Posts
    8

  4. #4
    Join Date
    Aug 2006
    Posts
    26

    Default

    in the mean time ... you can get around it by creating the TransactionAttributeSourceAdvisor with its constructor.

    replace <tx:annotation-driven /> with

    Code:
        <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>    
        
        <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
            <property name="transactionManager" ref="transactionManager" />
            <property name="transactionAttributeSource">
                <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource" />
            </property>
        </bean>
    
        <bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
            <constructor-arg index="0" ref="transactionInterceptor"/>
        </bean>
    and it should work

    Its also been fixed after RC-3, I've commented the Jira.
    Last edited by Blair; Aug 31st, 2006 at 10:38 PM.

Posting Permissions

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