IntelliJ Java IDE
The moose likes Object Relational Mapping and the fly likes Problem with Hibernate3 on WAS 5.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Problem with Hibernate3 on WAS 5.1" Watch "Problem with Hibernate3 on WAS 5.1" New topic
Author

Problem with Hibernate3 on WAS 5.1

markus lehrhuber
Greenhorn

Joined: Jul 06, 2007
Posts: 6
I have a problem running Hibernate 3 on Websphere 5.1. I always get the following error when building the hibernate sessionfactory
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();

org.hibernate.HibernateException: Unable to locate current JTA transaction

My config file looks like follows:

<?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">
<hibernate-configuration>
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.session_factory_name">HibernateSessionFactory</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.connection.datasource">jdbc/MyDataSource</property>
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</property>
<property name="hibernate.transaction.manager_lookup_class">
org.hibernate.transaction.WebSphereTransactionManagerLookup
</property>
<property name="hibernate.jndi.class">
com.ibm.websphere.naming.WsnInitialContextFactory
</property >
<property name="hibernate.current_session_context_class">jta</property>

<mapping resource="User.hbm.xml" />

</session-factory>
</hibernate-configuration>

Can anyone help me? Thanks!
Jaikiran Pai
Saloon Keeper

Joined: Jul 20, 2005
Posts: 6718

Hello "muck"

Welcome to JavaRanch

We are glad to have you here. We have a naming policy at JavaRanch. Your displayed name must consist of a first name (or an initial), a space, and a family name (in that order) and not be obviously fictitious. Please take a moment to change it, which you can do right here.


[My Blog] [JavaRanch Journal]
Jaikiran Pai
Saloon Keeper

Joined: Jul 20, 2005
Posts: 6718

As for the exception that you are seeing, can you post the entire exception stacktrace?
markus lehrhuber
Greenhorn

Joined: Jul 06, 2007
Posts: 6
Here is my stacktrace:

[07.07.07 15:14:13:328 CEST] 38deb49a SystemErr R org.hibernate.HibernateException: Unable to locate current JTA transaction
at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:61)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:544)
at de.dcfs.quest.model.daos.LoggingDao.listLoggingsWithQGNameAndUserName(LoggingDao.java:44)
at de.dcfs.quest.it.database.logging.LoggingDAO.getLoggingTO(LoggingDAO.java:87)
at de.dcfs.quest.it.database.logging.LoggingDAO.getLoggingTOStringBuffer(LoggingDAO.java:64)
at de.dcfs.quest.it.database.logging.LoggingDAO.getLoggingTOBytes(LoggingDAO.java:60)
at de.dcfs.quest.pt.admin.LogDataFileDownloadServlet.doPost(LogDataFileDownloadServlet.java:22)
at de.dcfs.quest.pt.admin.LogDataFileDownloadServlet.doGet(LogDataFileDownloadServlet.java:16)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:1171)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:676)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:203)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:1171)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:676)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:203)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:125)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:286)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:652)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:448)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
Jaikiran Pai
Saloon Keeper

Joined: Jul 20, 2005
Posts: 6718

Markus, thanks for changing your display name

[07.07.07 15:14:13:328 CEST] 38deb49a SystemErr R org.hibernate.HibernateException: Unable to locate current JTA transaction
at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:61)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:544)
at de.dcfs.quest.model.daos.LoggingDao.listLoggingsWithQGNameAndUserName(LoggingDao.java:44)


So the exception is occuring when you are calling the getCurrentSession method and not while building the session factory. Is your listLoggingsWithQGNameAndUserName part of a transaction?
[ July 09, 2007: Message edited by: Jaikiran Pai ]
markus lehrhuber
Greenhorn

Joined: Jul 06, 2007
Posts: 6
oh yes you are right - I got several stackraces because I tried a lot of different configurations.

But now it seems to work - it seems that the same WAS-Datasource was used by another Application which prevented hibernate caused this error.
 
IntelliJ Java IDE
 
subject: Problem with Hibernate3 on WAS 5.1
 
Threads others viewed
Could not parse hibernate.cfg.xml
NullPointerException on SessionFactory sessionFactory = new Configuration().configure().buildSession
Hibernate generate select while storing object.
glassfish vs. Hibernate: JNDI configuration
Migration from Hibernate 2 to Hibernate 3.2.2
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com