Announcement Announcement Module
Collapse
No announcement yet.
IllegalStateException: Either 'userTransaction' or... must be specified Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • IllegalStateException: Either 'userTransaction' or... must be specified

    Hi,

    Apologies, this is probably a total noob question

    We have a SpringMVC webapp that runs ok under JBoss, but fails under tomcat.

    I first got this error:

    NoClassDefFoundError: javax/transaction/Synchronization

    Code:
    15:12:57,201 INFO  [XmlWebApplicationContext] Refreshing org.springframework.web.context.support.XmlWebApplicationContex
    t@153f67e: display name [Root WebApplicationContext]; startup date [Fri Aug 17 15:12:57 BST 2007]; root of context hiera
    rchy
    15:12:57,264 INFO  [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/applica
    tionContext.xml]
    15:12:57,357 INFO  [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/commonS
    pringContext.xml]
    15:12:57,436 INFO  [XmlWebApplicationContext] Bean factory for application context [org.springframework.web.context.supp
    ort.XmlWebApplicationContext@153f67e]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1cf4a2c
    15:12:57,545 INFO  [XmlWebApplicationContext] Bean 'org.springframework.aop.config.internalAutoProxyCreator' is not elig
    ible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    15:12:57,576 INFO  [DefaultListableBeanFactory] Destroying singletons in org.springframework.beans.factory.support.Defau
    ltListableBeanFactory@1cf4a2c: defining beans [transactionManager,transactionTemplate,org.springframework.aop.config.int
    ernalAutoProxyCreator,org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor,simpleJdbcTemplate,j
    dbcTemplate,namedParameterJdbcTemplate,systemUserDao,mithrasCacheDao,referenceDataDao,instrumentDao,portfolioDao,sophisC
    ommonDao,requestHandler,instrumentDaoMithras,greeksDao,utilitiesDao,systemVersionDaoMithras,systemUserManager,templateDa
    o,tradeDao,mithrasInstrumentManager,mithrasGreeksManager,mithrasUtilitiesManager,instrumentManager,templateManager,signo
    nInterceptor,systemVersionManager,startup,messageSource,viewResolver,urlMapping,exceptionResolver,changeResult,applicati
    onProperties,instrumentPricer,entityManagerFactory,dataSource]; root of factory hierarchy
    15:12:57,576 ERROR [ContextLoader] Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.
    interceptor.TransactionAttributeSourceAdvisor': Cannot create inner bean '(inner bean)' of type [org.springframework.tra
    nsaction.interceptor.TransactionInterceptor] while setting bean property 'transactionInterceptor'; nested exception is o
    rg.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve ref
    erence to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springfram
    ework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext
    resource [/WEB-INF/commonSpringContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/Synchronization
    Caused by:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve re
    ference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springfra
    mework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext
     resource [/WEB-INF/commonSpringContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoun
    dError: javax/transaction/Synchronization
    Caused by:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in S
    ervletContext resource [/WEB-INF/commonSpringContext.xml]: Instantiation of bean failed; nested exception is java.lang.N
    oClassDefFoundError: javax/transaction/Synchronization
    Caused by:
    java.lang.NoClassDefFoundError: javax/transaction/Synchronization
            at java.lang.Class.getDeclaredConstructors0(Native Method)
    Which I fixed by putting the jta.jar into the common/lib directory, but then get this error:

    IllegalStateException: Either 'userTransaction' or 'userTransactionName' or 'transactionManager' or 'transacti
    onManagerName' must be specified


    Code:
    15:14:22,951 INFO  [XmlWebApplicationContext] Refreshing org.springframework.web.context.support.XmlWebApplicationContex
    t@153f67e: display name [Root WebApplicationContext]; startup date [Fri Aug 17 15:14:22 BST 2007]; root of context hiera
    rchy
    15:14:23,014 INFO  [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/applica
    tionContext.xml]
    15:14:23,107 INFO  [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/commonS
    pringContext.xml]
    15:14:23,186 INFO  [XmlWebApplicationContext] Bean factory for application context [org.springframework.web.context.supp
    ort.XmlWebApplicationContext@153f67e]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1cf4a2c
    15:14:23,295 INFO  [XmlWebApplicationContext] Bean 'org.springframework.aop.config.internalAutoProxyCreator' is not elig
    ible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    15:14:23,342 INFO  [DefaultListableBeanFactory] Destroying singletons in org.springframework.beans.factory.support.Defau
    ltListableBeanFactory@1cf4a2c: defining beans [transactionManager,transactionTemplate,org.springframework.aop.config.int
    ernalAutoProxyCreator,org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor,simpleJdbcTemplate,j
    dbcTemplate,namedParameterJdbcTemplate,systemUserDao,mithrasCacheDao,referenceDataDao,instrumentDao,portfolioDao,sophisC
    ommonDao,requestHandler,instrumentDaoMithras,greeksDao,utilitiesDao,systemVersionDaoMithras,systemUserManager,templateDa
    o,tradeDao,mithrasInstrumentManager,mithrasGreeksManager,mithrasUtilitiesManager,instrumentManager,templateManager,signo
    nInterceptor,systemVersionManager,startup,messageSource,viewResolver,urlMapping,exceptionResolver,changeResult,applicati
    onProperties,instrumentPricer,entityManagerFactory,dataSource]; root of factory hierarchy
    15:14:23,342 ERROR [ContextLoader] Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.
    interceptor.TransactionAttributeSourceAdvisor': Cannot create inner bean '(inner bean)' of type [org.springframework.tra
    nsaction.interceptor.TransactionInterceptor] while setting bean property 'transactionInterceptor'; nested exception is o
    rg.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve ref
    erence to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springfram
    ework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext
    resource [/WEB-INF/commonSpringContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStat
    eException: Either 'userTransaction' or 'userTransactionName' or 'transactionManager' or 'transactionManagerName' must b
    e specified
    Caused by:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve re
    ference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springfra
    mework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext
     resource [/WEB-INF/commonSpringContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalSta
    teException: Either 'userTransaction' or 'userTransactionName' or 'transactionManager' or 'transactionManagerName' must
    be specified
    Caused by:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in S
    ervletContext resource [/WEB-INF/commonSpringContext.xml]: Invocation of init method failed; nested exception is java.la
    ng.IllegalStateException: Either 'userTransaction' or 'userTransactionName' or 'transactionManager' or 'transactionManag
    erName' must be specified
    Caused by:
    java.lang.IllegalStateException: Either 'userTransaction' or 'userTransactionName' or 'transactionManager' or 'transacti
    onManagerName' must be specified
            at org.springframework.transaction.jta.JtaTransactionManager.initUserTransactionAndTransactionManager(JtaTransac
    tionManager.java:458)
            at org.springframework.transaction.jta.JtaTransactionManager.afterPropertiesSet(JtaTransactionManager.java:407)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowi
    reCapableBeanFactory.java:1201)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireC
    apableBeanFactory.java:1171)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapab
    leBeanFactory.java:425)
    Which was an error we were getting with the JBoss version, until I removed the jta.jar from the webapp - seems like it clashed with the JBoss version.

    Any tips on getting it to run with tomcat.

    Thanks in advance,
    Chris

  • #2
    You use JTA so re-introducte the jta.jar when running on Tomcat. As you correctly mentioned, JTA is provided by JBoss out-of-the-box (which is has to because it is a a full J2EE server), tomcat otoh doesn't provide that because it is merely a JSP/Servlet container. (This is the part you already fixed).

    Tomcat also doesn't provide anything for distributed transaction, you will need to introduce something yourself, the are standalone JTA providers/manager available wich work perfectly well with Tomcat).

    Comment


    • #3
      Hi,

      Thanks for the quick reply.

      If I understand you correctly, it seems I need to add a standalone JTA provider to tomcat in order to use this webapp under tomcat?

      Thanks,
      Chris

      Comment


      • #4
        Originally posted by kimptoc View Post
        If I understand you correctly, it seems I need to add a standalone JTA provider to tomcat in order to use this webapp under tomcat?
        Exactly. There are at least Jencks, JOTM and Atomikos.

        Joerg

        Comment


        • #5
          Hi,

          Thanks - I am now trying to use JOTM but spring is failing to find the bound datasource - my context looks like this

          Code:
          <?xml version="1.0" encoding="UTF-8"?>
          <Context path="/mw" docBase="C:\rbidev\" >
          
           <Resource name="jdbc/m2" auth="Container" type="javax.sql.DataSource"
                  factory="org.objectweb.jndi.DataSourceFactory"
                  driverClassName="oracle.jdbc.driver.OracleDriver"
                  username="???" password="???" url="jdbc:oracle:thin:@172.17.44.29:9501:SOPHI2DV"/>
          
              <Transaction factory="org.objectweb.jotm.UserTransactionFactory"
                 jotm.timeout="60"/>
                                    
          </Context>
          But I get this error:

          Code:
          12:53:03,024 INFO  [jotm] JOTM started with a local transaction factory which is not bound.
          12:53:03,024 INFO  [jotm] CAROL initialization
          12:53:03,118 INFO  [jta] JOTM 2.0.10
          12:53:03,149 INFO  [[/mw]] Initializing Spring root WebApplicationContext
          12:53:03,149 INFO  [ContextLoader] Root WebApplicationContext: initialization started
          12:53:03,180 INFO  [XmlWebApplicationContext] Refreshing org.springframework.web.context.support.XmlWebApplicationContex
          t@ad8659: display name [Root WebApplicationContext]; startup date [Sat Aug 18 12:53:03 BST 2007]; root of context hierarchy
          12:53:03,242 INFO  [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
          12:53:03,336 INFO  [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/commonSpringContext.xml]
          12:53:03,399 INFO  [XmlWebApplicationContext] Bean factory for application context [[email protected]ad8659]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1d3cdaa
          12:53:03,523 INFO  [XmlWebApplicationContext] Bean 'org.springframework.aop.config.internalAutoProxyCreator' is not elig
          ible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
          12:53:03,555 INFO  [JtaTransactionManager] Using JTA UserTransaction: org.objectweb.jotm.Current@136a43c
          12:53:03,555 INFO  [JtaTransactionManager] Using JTA TransactionManager: org.objectweb.jotm.Current@136a43c
          12:53:03,586 INFO  [DefaultListableBeanFactory] Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1d3cdaa: defining beans [transactionManager,transactionTemplate,org.springframework.aop.config.int
          ernalAutoProxyCreator,org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor,simpleJdbcTemplate,jdbcTemplate,namedParameterJdbcTemplate,systemUserDao,mithrasCacheDao,referenceDataDao,instrumentDao,portfolioDao,sophisC
          ommonDao,requestHandler,instrumentDaoMithras,greeksDao,utilitiesDao,systemVersionDaoMithras,systemUserManager,templateDao,tradeDao,mithrasInstrumentManager,mithrasGreeksManager,mithrasUtilitiesManager,instrumentManager,templateManager,signonInterceptor,systemVersionManager,startup,messageSource,viewResolver,urlMapping,exceptionResolver,changeResult,applicati
          onProperties,instrumentPricer,entityManagerFactory,dataSource]; root of factory hierarchy
          12:53:03,586 ERROR [ContextLoader] Context initialization failed
          org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'startup' defined in ServletContext resource [/WEB-INF/commonSpringContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean propert
          y 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is
          not bound in this Context
          Caused by:
          org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init
          method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
          Caused by:
          javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
                  at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
                  at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
                  at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
                  at javax.naming.InitialContext.lookup(InitialContext.java:392)
          Is this an issue local transaction factory which is not bound.

          The data source entry in the spring config is this:

          Code:
              <jee:jndi-lookup id="dataSource" jndi-name="java:jdbc/m2" />
          Thanks in advance for any tips.

          Regards,
          Chris

          Comment


          • #6
            I don't know how you have to set it up with JOTM, I only know Jencks. With Jencks I started with a blog post by Thierry Templier (the link used to work, but seems not at the moment). With Jencks 2.0 it is supposed to be even simpler.

            Joerg

            Comment

            Working...
            X