Hi
I am using Hibernate 3.0.5 and Tomcat 5.5.9.
I wanted to enable and use treechache. I have downloaded jotm.jar and related jars and updated hibernate.cfg.xml
I have given datasource details in tomcat/conf/server.xml
I am unable to bind the hibernate session to JNDI (may be because of Tomcat's JNDI is read only)
I am also unable to get TransactionManager as I have enabled jta in my hibernate.cfg.xml
I am attaching details :
hibernate.cfg.xml
Code:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Don't forget to copy your JDBC driver to the lib/ directory! -->
<!-- Settings for a remote Oracle9/10g database. -->
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="cache.provider_class">org.hibernate.cache.TreeCacheProvider</property>
<property name="connection.datasource">java:comp/env/jdbc/kct</property>
<property name="session_factory_name">java:comp/env/hibernate/CTMSSessionFactory</property>
<property name="current_session_context_class">jta</property>
<property name="jndi.HibernateFactory">java:comp/env/hibernate/CTMSSessionFactory</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.JOTMTransactionManagerLookup</property>
<property name="jta.UserTransaction">java:comp/env/UserTransaction</property>
<property name="cache.use_query_cache">true</property>
<property name="cache.use_minimal_puts">true</property>
<property name="generate_statistics">true</property>
<property name="cglib.use_reflection_optimizer">true</property>
<property name="connection.isolation">2</property>
<property name="c3p0.min_size">3</property>
<property name="c3p0.max_size">50</property>
<property name="c3p0.timeout">1800</property>
<property name="c3p0.acquire_increment">10</property>
<property name="query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
<property name="use_sql_comments">true</property>
<property name="show_sql">true</property>
<!-- CaveatEmptor mapping files. -->
<mapping resource="blah.hbm"/>
...
...
</session-factory>
</hibernate-configuration>
server.xml
Code:
<Resource name="jdbc/kct" auth="Container"
type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="blah" password="blah"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@x.x.x.x:1521:blah"/>
HibernateUtil.java
Code:
Context initialCntx = new InitialContext();
Context envCtx = (Context) initialCntx.lookup("java:comp/env");
SessionFactory sessionFactory = (SessionFactory)envCtx.lookup("hibernate/CTMSSessionFactory");
Session hibernateSess = sessionFactory.getCurrentSession();
I am getting the following stack trace
2008-02-29 17:22:44,547 - INFO-Factory name: java:comp/env/hibernate/CTMSSessionFactory-
2008-02-29 17:22:44,547 - INFO-Factory name: java:comp/env/hibernate/CTMSSessionFactory-
2008-02-29 17:22:44,547 - INFO-JNDI InitialContext properties:{HibernateFactory=java:comp/env/hibernate/CTMSSessionFactory}-
2008-02-29 17:22:44,547 - INFO-JNDI InitialContext properties:{HibernateFactory=java:comp/env/hibernate/CTMSSessionFactory}-
2008-02-29 17:23:07,391 - WARN-Could not bind factory to JNDI-
javax.naming.NamingException: Context is read only
at org.apache.naming.NamingContext.checkWritable(NamingContext.java:902)
at org.apache.naming.NamingContext.bind(NamingContext.java:830)
at org.apache.naming.NamingContext.rebind(NamingContext.java:207)
at org.hibernate.util.NamingHelper.bind(NamingHelper.java:74)
at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:260)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at com.kenexa.ctms.db.HibernateSessionFactoryTomcatFactory.getObjectInstance(HibernateSessionFactoryTomcatFactory.java:28)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:129)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at org.apache.naming.NamingContext.lookup(NamingContext.java:792)
at org.apache.naming.NamingContext.lookup(NamingContext.java:139)
at org.apache.naming.NamingContext.lookup(NamingContext.java:780)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at com.kenexa.ctms.db.HibernateUtil.<init>(HibernateUtil.java:92)
at com.kenexa.ctms.system.KNXFWSystem.startKNXFWSystem(KNXFWSystem.java:2058)
at com.kenexa.ctms.dispatcher.servlets.KNXFWBootstrapServlet.init(KNXFWBootstrapServlet.java:494)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
2008-02-29 17:23:07,391 - WARN-Could not bind factory to JNDI-
javax.naming.NamingException: Context is read only
at org.apache.naming.NamingContext.checkWritable(NamingContext.java:902)
at org.apache.naming.NamingContext.bind(NamingContext.java:830)
at org.apache.naming.NamingContext.rebind(NamingContext.java:207)
at org.hibernate.util.NamingHelper.bind(NamingHelper.java:74)
at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:260)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at com.kenexa.ctms.db.HibernateSessionFactoryTomcatFactory.getObjectInstance(HibernateSessionFactoryTomcatFactory.java:28)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:129)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at org.apache.naming.NamingContext.lookup(NamingContext.java:792)
at org.apache.naming.NamingContext.lookup(NamingContext.java:139)
at org.apache.naming.NamingContext.lookup(NamingContext.java:780)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at com.kenexa.ctms.db.HibernateUtil.<init>(HibernateUtil.java:92)
at com.kenexa.ctms.system.KNXFWSystem.startKNXFWSystem(KNXFWSystem.java:2058)
at com.kenexa.ctms.dispatcher.servlets.KNXFWBootstrapServlet.init(KNXFWBootstrapServlet.java:494)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
2008-02-29 17:23:08,141 - INFO-starting update timestamps cache at region: org.hibernate.cache.UpdateTimestampsCache-
2008-02-29 17:23:08,141 - INFO-starting update timestamps cache at region: org.hibernate.cache.UpdateTimestampsCache-
2008-02-29 17:23:08,141 - INFO-starting query cache at region: org.hibernate.cache.StandardQueryCache-
2008-02-29 17:23:08,141 - INFO-starting query cache at region: org.hibernate.cache.StandardQueryCache-
2008-02-29 17:23:08,141 - INFO-Checking 0 named queries-
2008-02-29 17:23:08,141 - INFO-Checking 0 named queries-
org.hibernate.HibernateException: No TransactionManagerLookup specified
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:503)
at com.kenexa.ctms.db.HibernateUtil.<init>(HibernateUtil.java:93)
at com.kenexa.ctms.system.KNXFWSystem.startKNXFWSystem(KNXFWSystem.java:2058)
at com.kenexa.ctms.dispatcher.servlets.KNXFWBootstrapServlet.init(KNXFWBootstrapServlet.java:494)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
2008-02-29 17:23:08,172 - ERROR-Building SessionFactory failed.-
org.hibernate.HibernateException: No TransactionManagerLookup specified
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:503)
at com.kenexa.ctms.db.HibernateUtil.<init>(HibernateUtil.java:93)
at com.kenexa.ctms.system.KNXFWSystem.startKNXFWSystem(KNXFWSystem.java:2058)
at com.kenexa.ctms.dispatcher.servlets.KNXFWBootstrapServlet.init(KNXFWBootstrapServlet.java:494)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
2008-02-29 17:23:08,203 - ERROR-StandardWrapper.Throwable-
java.lang.ExceptionInInitializerError
at com.kenexa.ctms.db.HibernateUtil.<init>(HibernateUtil.java:111)
at com.kenexa.ctms.system.KNXFWSystem.startKNXFWSystem(KNXFWSystem.java:2058)
at com.kenexa.ctms.dispatcher.servlets.KNXFWBootstrapServlet.init(KNXFWBootstrapServlet.java:494)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.HibernateException: No TransactionManagerLookup specified
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:503)
at com.kenexa.ctms.db.HibernateUtil.<init>(HibernateUtil.java:93)
... 17 more
2008-02-29 17:23:08,203 - ERROR-Allocate exception for servlet KenexaCareerTracker-
java.lang.ExceptionInInitializerError
at com.kenexa.ctms.db.HibernateUtil.<init>(HibernateUtil.java:111)
at com.kenexa.ctms.system.KNXFWSystem.startKNXFWSystem(KNXFWSystem.java:2058)
at com.kenexa.ctms.dispatcher.servlets.KNXFWBootstrapServlet.init(KNXFWBootstrapServlet.java:494)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.HibernateException: No TransactionManagerLookup specified
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:503)
at com.kenexa.ctms.db.HibernateUtil.<init>(HibernateUtil.java:93)
... 17 more
What could be the problem?
Did I miss anything?