3 Replies Latest reply on Feb 14, 2007 2:31 PM by Gavin King

    Configuring for @Transactional

    Mike Quilleash Newbie

      Hi there,

      I'm trying to get Seam managed transactions working. I've read Chap8 and looked at the hibernate example. I think I've done most of the configuration but this last piece is tripping me up. I'm running with Tomcat 6 and Hibernate 3 (no J2EE container).

      The stack trace I get is this.

      org.hibernate.HibernateException: Could not locate TransactionManager
       at org.hibernate.transaction.JNDITransactionManagerLookup.getTransactionManager(JNDITransactionManagerLookup.java:26)
       at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:325)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
       at com.azure.spark.database.hibernate.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:1029)
       at com.azure.spark.database.hibernate.util.HibernateSession.initialise(HibernateSession.java:75)
       at com.azure.spark.common.initialise.InitialiseHelper.initialiseReference(InitialiseHelper.java:82)
       at com.azure.spark.common.initialise.InitialiseHelper.initialiseReference(InitialiseHelper.java:52)
       at com.azure.spark.web.servlet.InitialisationListener.contextInitialized(InitialisationListener.java:19)
       at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4336)
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
       at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
       at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
       at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
       at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
       at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
       at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
       at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
       at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
       at org.apache.catalina.core.StandardService.start(StandardService.java:451)
       at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
       at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
       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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
       at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
      Caused by: javax.naming.NameNotFoundException: Name TransactionManager 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:351)
       at org.hibernate.transaction.JNDITransactionManagerLookup.getTransactionManager(JNDITransactionManagerLookup.java:23)
       ... 31 more
      


      Here's my hibernate.cfg.xml

      <!DOCTYPE hibernate-configuration PUBLIC
       "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
       "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
      
      <hibernate-configuration>
       <session-factory>
      
       <property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
       <property name="hibernate.connection.url">jdbc:jtds:sqlserver://QUANTZ/certo;Instance=QUANTZ_SQL;PrepareSQL=0</property>
       <property name="hibernate.connection.username">sa</property>
       <property name="hibernate.connection.password">welcome</property>
      
       <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
      
       <property name="hibernate.query.substitutions">false='N', true='Y'</property>
      
       <property name="show_sql">true</property>
      
       <property name="transaction.flush_before_completion">true</property>
       <property name="connection.release_mode">after_transaction</property>
       <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
       <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
      
       </session-factory>
      </hibernate-configuration>
      



      And I have TransactionalSeamPhaseListener configured in faces-config.

      It looks like hibernate can't find the TransactionManager specified by the JBossTransactionManagerLookup. Should I be using a different lookup or am I missing some crucial piece? I confess to not really understanding how the JNDI stuff gets bootstrapped and configured.

      I don't have the microcontainer enabled (should I?) because it looked like the hibernate example disabled this for a war build.

      Thanks.

      Mike.