Announcement Announcement Module
Collapse
No announcement yet.
getting JPA to work with tx aspects Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • getting JPA to work with tx aspects

    I've tried various versions of Spring 2.5.0 - 2.5.5 and I always seem to get ...

    Code:
    java.lang.NoSuchMethodError: org.springframework.orm.jpa.JpaTransactionManager.determineTimeout(Lorg/springframework/transaction/TransactionDefinition;)I
    at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:334)
    is it something wrong with my configuration?

    Code:
            <tx:annotation-driven/>
    
            <bean id="dataSource"
                    class="org.apache.commons.dbcp.BasicDataSource"
                    destroy-method="close">
                <property name="driverClassName" value="org.hibernate.dialect.PostgreSQLDialect" />
                <property name="url" value="jdbc:postgresql://localhost:5432:youthdb" />
                <property name="username" value="postgres" />
                <property name="password" value="postgres" />
            </bean>
    
    	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
                <property name="dataSource" ref="dataSource"/>
    	    <property name="entityManagerFactory" ref="entityManagerFactory"/>
    	</bean>
    
            <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
                <property name="dataSource" ref="dataSource"/>
                <property name="persistenceXmlLocation" value="persistence.xml"/>
                <property name="jpaVendorAdapter">
                    <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                       <property name="showSql" value="true" />
                       <property name="generateDdl" value="true" />
                       <property name="databasePlatform" value="org.hibernate.dialect.HSQLDialect" />
                    </bean>
                </property>
            </bean>
    
    
            <bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/>
            <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
            <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>        
    
    
            <!-- transaction aspects -->
            <aop:config>
                <aop:pointcut id="daoMethods" expression="execution(* com.wdig.wdyp.dao.*.*(..))"/>
                <aop:advisor advice-ref="txAdvice" pointcut-ref="daoMethods"/>
            </aop:config>
    
            <tx:advice id="txAdvice" transaction-manager="transactionManager">
                <tx:attributes>
                    <tx:method name="*" propagation="REQUIRED"/>
                </tx:attributes>
            </tx:advice>
    
    
    	<bean id="addressDao" class="com.wdig.wdyp.dao.jpa.JpaAddressDao"/>
    fairly empty pu in persistence.xml
    Code:
        <persistence-unit name="YouthProgramPU" transaction-type="RESOURCE_LOCAL"/>

  • #2
    Hi,

    Can you perhaps show us the chunk of code/service method that does the transaction bit?

    Cheers,
    Nathan.

    Comment


    • #3
      I figured it out. Despite the JPA stuff being included in the ORM package, it just does not seem to work. I removed ORM and just used the JPA package and it was happy as a clam. woohoo!

      Code:
              <!--
              <dependency groupId="org.springframework"
                          artifactId="spring-orm"
                          version="2.5.5"/>
              -->
              <dependency groupId="org.springframework"
                          artifactId="spring-jpa"
                          version="2.0"/>

      Comment

      Working...
      X