I have been fussing for hours trying to get a simple
Hibernate / Servlet example running ....I am attempting
to connect to my database using a Datasource.
I know the Datasoruce is properly configured since a
separate ( non Hibernate ) web app connects fine using
this Datasource.
I keep getting error "No TransactionManagerLookup specified"
...I've traced through a number of Google posts w/o success.
I have also read :
http://hibernate.org/42.html
Any hints ?
Thanks,
Rod
==============================================
Hibernate version:3.1.3
JBoss version:4.0.3
Database is OracleXE on my local system
I am using java version "1.5.0_05"
My hibernate.cfg.xml file
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory name="java:comp/env/hibernate/SessionFactory">
<property name="hibernate.current_session_context_class">jta</property>
<property name="connection.username">someuser</property>
<property name="connection.password">somepassword</property>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="connection.datasource">java:/Hibernate_People</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">
org.hibernate.cache.NoCacheProvider
</property>
<!-- Class Mappings -->
<mapping resource="inAction/Eventsrod.hbm.xml" />
<mapping resource="inAction/Person.hbm.xml" />
<mapping resource="inAction/PersonEvent.hbm.xml" />
</session-factory>
</hibernate-configuration>
My JBoss Datasource definition ( OracleXE-ds.xml )
in JBoss ..server/default/deploy directory
<datasources>
<local-tx-datasource>
<jndi-name>Hibernate_People</jndi-name>
<connection-url>jdbc:oracle:thin:@localhost:1521:xe</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>someUser</user-name>
<password>somePassword</password>
<min-pool-size>2</min-pool-size>
<max-pool-size>5</max-pool-size>
...
My Servlet code ( fragment )
public class EventManagerServlet extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
try {
Session session = HibernateUtil.getSessionFactory()
.getCurrentSession();
session.beginTransaction();
My HibernateUtil code
public class HibernateUtil {
private static SessionFactory sessionFactory=null;
private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";
static {
try {
// Create the sesionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure(CONFIG_FILE_LOCATION).buildSessionFactory();
System.out.println("Loaded session factory...");
} catch(Throwable ex) {
System.err.println("Initial Hibernate sessionFactory creation failed:"+ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
Log from JBoss + Full stack trace of any exception
09:00:21,523 INFO [Environment] Hibernate 3.1.3
09:00:21,695 INFO [Environment] hibernate.properties not found
09:00:21,742 INFO [Environment] using CGLIB reflection optimizer
09:00:21,742 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
09:00:23,633 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
09:00:23,633 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
09:00:25,320 INFO [Configuration] Reading mappings from resource: inAction/Eventsrod.hbm.xml
09:00:28,149 INFO [HbmBinder] Mapping class: inAction.Eventsrod -> EVENTSROD
09:00:28,821 INFO [HbmBinder] Mapping collection: inAction.Eventsrod.participants -> PERSON_EVENT
09:00:28,899 INFO [Configuration] Reading mappings from resource: inAction/Person.hbm.xml
09:00:30,712 INFO [HbmBinder] Mapping class: inAction.Person -> PERSON
09:00:30,743 INFO [HbmBinder] Mapping collection: inAction.Person.events -> person_event
09:00:30,759 INFO [HbmBinder] Mapping collection: inAction.Person.emailAddresses -> PERSON_EMAIL_ADDR
09:00:30,774 INFO [Configuration] Reading mappings from resource: inAction/PersonEvent.hbm.xml
09:00:32,446 INFO [HbmBinder] Mapping class: inAction.PersonEvent -> PERSON_EVENT
09:00:32,462 INFO [Configuration] Configured SessionFactory: java:comp/env/hibernate/SessionFactory
09:00:34,431 INFO [NamingHelper] JNDI InitialContext properties:{}
09:00:34,524 INFO [DatasourceConnectionProvider] Using datasource: java:/Hibernate_People
09:00:35,759 INFO [SettingsFactory] RDBMS: Oracle, version: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
09:00:35,774 INFO [SettingsFactory] JDBC driver: Oracle JDBC driver, version: 10.1.0.4.0
09:00:36,446 INFO [Dialect] Using dialect: org.hibernate.dialect.Oracle9Dialect
09:00:36,649 INFO [TransactionFactoryFactory] Using default transaction strategy (direct JDBC transactions)
09:00:36,759 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
09:00:36,774 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
09:00:36,774 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
09:00:36,774 INFO [SettingsFactory] JDBC batch size: 15
09:00:36,790 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
09:00:36,837 INFO [SettingsFactory] Scrollable result sets: enabled
09:00:36,837 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
09:00:36,837 INFO [SettingsFactory] Connection release mode: auto
09:00:36,852 INFO [SettingsFactory] Default batch fetch size: 1
09:00:36,852 INFO [SettingsFactory] Generate SQL with comments: disabled
09:00:36,852 INFO [SettingsFactory] Order SQL updates by primary key: disabled
09:00:36,884 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
09:00:36,977 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
09:00:36,977 INFO [SettingsFactory] Query language substitutions: {}
09:00:36,993 INFO [SettingsFactory] Second-level cache: enabled
09:00:36,993 INFO [SettingsFactory] Query cache: disabled
09:00:36,993 INFO [SettingsFactory] Cache provider: org.hibernate.cache.NoCacheProvider
09:00:37,087 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
09:00:37,087 INFO [SettingsFactory] Structured second-level cache entries: disabled
09:00:37,306 INFO [SettingsFactory] Statistics: disabled
09:00:37,306 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
09:00:37,306 INFO [SettingsFactory] Default entity-mode: pojo
09:00:37,931 INFO [SessionFactoryImpl] building session factory
09:00:48,149 INFO [SessionFactoryObjectFactory] Factory name: java:comp/env/hibernate/SessionFactory
09:00:48,165 INFO [NamingHelper] JNDI InitialContext properties:{}
09:00:48,212 INFO [NamingHelper] Creating subcontext: hibernate
09:00:48,243 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: java:comp/env/hibernate/SessionFactory
09:00:48,243 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
09:00:48,477 INFO [STDOUT] Loaded session factory...
09:01:23,243 ERROR [[Event Manager]] Servlet.service() for servlet Event Manager threw exception
org.hibernate.HibernateException: No TransactionManagerLookup specified
at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:54)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:508)
at inAction.EventManagerServlet.doGet(EventManagerServlet.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
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.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)