Announcement Announcement Module
Collapse
No announcement yet.
JotmFactoryBean in Spring 3 RC1? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JotmFactoryBean in Spring 3 RC1?

    Hi!

    I'm upgrading my JPA project from Spring 2.x to Spring 3.0.0.RC1. It would appear that the class used to construct the JotmFactory has been removed... specifically the error I'm getting is:

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'itemInstanceDAO': Injection of persistence methods failed; nested exception is org.springframework.beans.factory.CannotLoadBeanCl assException: Cannot find class [org.springframework.transaction.jta.JotmFactoryBea n] for bean with name 'jotm' defined in class path resource [applicationContext_hibernate.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.transaction.jta.JotmFactoryBea n
    at org.springframework.orm.jpa.support.PersistenceAnn otationBeanPostProcessor.postProcessPropertyValues (PersistenceAnnotationBeanPostProcessor.java:323)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1049)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:511)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:450)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 89)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:286 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:188)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:543)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:730)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:387)
    at com.mtvnet.vworlds.springsupport.GlobalAppContext. getApplicationContext(GlobalAppContext.java:122)
    at com.mtvnet.vworlds.springsupport.GlobalAppContext. getBean(GlobalAppContext.java:133)
    at com.mtvnet.vworlds.ppp.itemInstances.ItemInstanceH ibDAOTest.getItemInstanceDAO(ItemInstanceHibDAOTes t.java:207)
    at com.mtvnet.vworlds.ppp.itemInstances.ItemInstanceH ibDAOTest.setUp(ItemInstanceHibDAOTest.java:199)
    at junit.framework.TestCase.runBare(TestCase.java:132 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:110)
    at junit.framework.TestResult.runProtected(TestResult .java:128)
    at junit.framework.TestResult.run(TestResult.java:113 )
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 32)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at org.junit.internal.runners.JUnit38ClassRunner.run( JUnit38ClassRunner.java:79)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:46)
    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)
    Caused by: org.springframework.beans.factory.CannotLoadBeanCl assException: Cannot find class [org.springframework.transaction.jta.JotmFactoryBea n] for bean with name 'jotm' defined in class path resource [applicationContext_hibernate.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.transaction.jta.JotmFactoryBea n
    at org.springframework.beans.factory.support.Abstract BeanFactory.resolveBeanClass(AbstractBeanFactory.j ava:1217)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.predictBeanType(Abstrac tAutowireCapableBeanFactory.java:568)
    at org.springframework.beans.factory.support.Abstract BeanFactory.isFactoryBean(AbstractBeanFactory.java :1287)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanNamesForType(DefaultList ableBeanFactory.java:285)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanNamesForType(DefaultList ableBeanFactory.java:266)
    at org.springframework.beans.factory.BeanFactoryUtils .beanNamesForTypeIncludingAncestors(BeanFactoryUti ls.java:142)
    at org.springframework.orm.jpa.support.PersistenceAnn otationBeanPostProcessor.findDefaultEntityManagerF actory(PersistenceAnnotationBeanPostProcessor.java :503)
    at org.springframework.orm.jpa.support.PersistenceAnn otationBeanPostProcessor.findEntityManagerFactory( PersistenceAnnotationBeanPostProcessor.java:472)
    at org.springframework.orm.jpa.support.PersistenceAnn otationBeanPostProcessor$PersistenceElement.resolv eEntityManager(PersistenceAnnotationBeanPostProces sor.java:597)
    at org.springframework.orm.jpa.support.PersistenceAnn otationBeanPostProcessor$PersistenceElement.getRes ourceToInject(PersistenceAnnotationBeanPostProcess or.java:570)
    at org.springframework.beans.factory.annotation.Injec tionMetadata$InjectedElement.inject(InjectionMetad ata.java:192)
    at org.springframework.beans.factory.annotation.Injec tionMetadata.injectMethods(InjectionMetadata.java: 117)
    at org.springframework.orm.jpa.support.PersistenceAnn otationBeanPostProcessor.postProcessPropertyValues (PersistenceAnnotationBeanPostProcessor.java:320)
    ... 28 more
    Caused by: java.lang.ClassNotFoundException: org.springframework.transaction.jta.JotmFactoryBea n
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
    at org.springframework.util.ClassUtils.forName(ClassU tils.java:255)
    at org.springframework.beans.factory.support.Abstract BeanDefinition.resolveBeanClass(AbstractBeanDefini tion.java:397)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doResolveBeanClass(AbstractBeanFactory .java:1239)
    at org.springframework.beans.factory.support.Abstract BeanFactory.resolveBeanClass(AbstractBeanFactory.j ava:1209)
    ... 40 more
    I can see that it used to be there, but is absent in the 3.0.0.RC1, and I can't find any mention of it's replacement, or how to get the JOTM transaction manager in. Was this intentional? What's the suggested fix?

    Thanks in advance!

    -Travis Savo <[email protected]>

  • #2
    JOTM and XAPool support is dropped in Spring 3.0.x (it has been droppen on 28-november-2008 so for quite some time now). There is however no JIRA issue attached to the commit.

    Comment


    • #3
      JOTM and XAPool support is dropped in Spring 3.0.x
      I see! How are @Transactions done in Spring 3.0.x now? Any documentation on the subject would be greatly appreciated.

      Comment


      • #4
        What has the JotmFactoryBean to do with the fact how @Transactional is done?! The handling of transactions in general or @Transactional specificly hasn't changed.

        Comment


        • #5
          My apologies. Allow me to elaborate.

          I'm using Spring to configure my JPA/Hibernate.

          My Spring configuration is as follows:

          <bean
          class="org.springframework.beans.factory.annotatio n.RequiredAnnotationBeanPostProcessor" />

          <!--
          enables interpretation of the @PersistenceUnit/@PersistenceContext
          annotations providing convenient access to
          EntityManagerFactory/EntityManager
          -->
          <bean
          class="org.springframework.orm.jpa.support.Persist enceAnnotationBeanPostProcessor" />

          <!--
          enables interpretation of the @Transactional annotation for
          declarative transaction management using the specified
          JpaTransactionManager
          -->
          <tx:annotation-driven transaction-manager="jtaTransactionManager"
          proxy-target-class="false" />

          <!--
          required cos the standalone JOTM transaction manager is not
          autodetected by the JtaTransactionManager cos it requires a static
          accessor method
          -->
          <bean id="jotm" class="org.springframework.transaction.jta.JotmFac toryBean" />

          <!--
          supplying the JotmFactoryBean merely to the userTransaction property
          cos JtaTransactionManager autodetects that the object returned by the
          JotmFactoryBean implements both the UserTransaction and the
          TransactionManager interface
          -->
          <bean id="jtaTransactionManager"
          class="org.springframework.transaction.jta.JtaTran sactionManager">
          <property name="userTransaction" ref="jotm" />
          <property name="allowCustomIsolationLevels" value="true" />
          </bean>

          <bean id="dataSourcePrimary" class="org.enhydra.jdbc.standard.StandardXADataSou rce">
          <property name="transactionManager" ref="jotm" />
          <property name="driverName" value="org.hsqldb.jdbcDriver" />
          <property name="url" value="jdbc:hsqldb:memrimary" />
          <property name="user" value="sa" />
          <property name="password" value="" />
          </bean>

          <bean id="dataSourceSecondary" class="org.enhydra.jdbc.standard.StandardXADataSou rce">
          <property name="transactionManager" ref="jotm" />
          <property name="driverName" value="org.hsqldb.jdbcDriver" />
          <property name="url" value="jdbc:hsqldb:mem:secondary" />
          <property name="user" value="sa" />
          <property name="password" value="" />
          </bean>

          <!-- first XA data source pool -->
          <bean id="dataSourcePrimaryPool" class="org.enhydra.jdbc.pool.StandardXAPoolDataSou rce">
          <property name="transactionManager" ref="jotm" />
          <property name="dataSource" ref="dataSourcePrimary" />
          <property name="user" value="sa" />
          <property name="password" value="" />
          <property name="maxSize" value="4" />
          </bean>

          <!-- Second XA data source pool -->
          <bean id="dataSourceSecondaryPool" class="org.enhydra.jdbc.pool.StandardXAPoolDataSou rce">
          <property name="transactionManager" ref="jotm" />
          <property name="dataSource" ref="dataSourceSecondary" />
          <property name="user" value="sa" />
          <property name="password" value="" />
          <property name="maxSize" value="6" />
          </bean>

          <bean id="entityManagerFactoryPrimary"
          class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
          <property name="persistenceXmlLocation" value="classpath*ersistencePrimary.xml" />
          <property name="dataSource" ref="dataSourcePrimaryPool" />
          <property name="jpaVendorAdapter">
          <bean class="org.springframework.orm.jpa.vendor.Hibernat eJpaVendorAdapter">
          <property name="databasePlatform" value="org.hibernate.dialect.HSQLDialect" />
          <property name="showSql" value="true" />
          <property name="generateDdl" value="true" />
          </bean>
          </property>
          <!--
          configure Hibernate to participate in JTA transactions using the JOTM
          transaction manager and specify further Hibernate specific
          configuration properties
          -->
          <property name="jpaPropertyMap">
          <map>
          <entry key="hibernate.transaction.manager_lookup_class"
          value="org.hibernate.transaction.JOTMTransactionMa nagerLookup" />
          <entry key="hibernate.transaction.flush_before_completion "
          value="true" />
          <entry key="hibernate.transaction.auto_close_session" value="false" />
          <entry key="hibernate.current_session_context_class" value="jta" />
          <entry key="hibernate.connection.release_mode" value="auto" />
          </map>
          </property>
          <!--
          specify that the Hibernate JPA dialect should be used, probably not
          necessary since HibernateJpaVendorAdapter will most likely set this
          property
          -->
          <property name="jpaDialect">
          <bean class="org.springframework.orm.jpa.vendor.Hibernat eJpaDialect" />
          </property>
          <!--
          custom implementation to enrich the PersistenceUnitInfo read from the
          persistence.xml JPA configuration file with the JTA datasource.
          specifying the JTA datasource directly in the Spring configuration
          file has the advantage that we can use a direct reference to the
          datasource instead of using a JNDI name as requied by the
          jta-data-source setting in the persistence.xml file
          -->
          <property name="persistenceUnitPostProcessors">
          <bean class="com.mtvnet.vworlds.jta.core.JtaPersistenceU nitPostProcessor">
          <property name="jtaDataSource" ref="dataSourcePrimaryPool" />
          </bean>
          </property>

          </bean>

          Unforunately this fails because of the line:

          <bean id="jotm" class="org.springframework.transaction.jta.JotmFac toryBean" />
          which gives me a:

          org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'itemInstanceDAO': Injection of persistence methods failed; nested exception is org.springframework.beans.factory.CannotLoadBeanCl assException: Cannot find class [org.springframework.transaction.jta.JotmFactoryBea n] for bean with name 'jotm' defined in class path resource [applicationContext_hibernate.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.transaction.jta.JotmFactoryBea n
          at org.springframework.orm.jpa.support.PersistenceAnn otationBeanPostProcessor.postProcessPropertyValues (PersistenceAnnotationBeanPostProcessor.java:323)
          at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1049)
          at ...
          When upgrading to Spring 3.0.0.RC1.

          Is there a suggested fix for this case, where we are trying to annotate our DAO objects with the @Transactional annotation and need to configure a transaction manager with Spring?

          Thanks in advance.

          Comment


          • #6
            Your question has nothing to do with @Transactional, the only question yhou want answered is how to configure Jotm in spring 3.

            1) Copy the code from 2.5.6 (JotmFactoryBean) to your own project and use that implementation
            2) Simply instantiate your orn Jotm instance and use that instead of the factory bean
            3) Use something else instead of Jotm

            Either 3 will solve your problem.

            Comment

            Working...
            X