Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.1.2
Mapping documents: hibernate.cfg
Code:
<?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.connection.datasource">myds</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JOTMTransactionManagerLookup</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<property name="hibernate.session_factory_name">myProjectFactoryName</property>
<property name="show_sql">true</property>
<mapping resource="com/comp/proj/gateway/transactions/Transaction.hbm.xml" />
<mapping resource="com/comp/proj/gateway/transactionalmedia/TransactionalMedia.hbm.xml" />
</session-factory>
</hibernate-configuration>
Code between sessionFactory.openSession() and session.close():the problem is in the getCurrentSession() call.
Code:
Configuration config = new Configuration().configure();
Session session = config.buildSessionFactory().getCurrentSession();
Full stack trace of any exception that occurs:Code:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: RuntimeException thrown by an enterprise Bean; nested exception is:
org.hibernate.HibernateException: Unable to locate current JTA transaction
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
at org.objectweb.carol.rmi.jrmp.server.JUnicastServerRef.dispatch(JUnicastServerRef.java:143)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at org.objectweb.carol.rmi.jrmp.server.JRemoteCall.executeCall(JRemoteCall.java:89)
at org.objectweb.carol.rmi.jrmp.server.JUnicastRef.invoke(JUnicastRef.java:161)
at org.objectweb.jonas_gen.com.comp.proj.gateway.j2ee.JOnASRequestHandler1270556417Remote_Stub.syncExcecute(Unknown Source)
at com.comp.proj.gateway.j2ee.tests.RequestHandlerTest.testExcecute(RequestHandlerTest.java:62)
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:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.rmi.RemoteException: RuntimeException thrown by an enterprise Bean; nested exception is:
org.hibernate.HibernateException: Unable to locate current JTA transaction
at org.objectweb.jonas_gen.com.comp.proj.gateway.j2ee.JOnASRequestHandler1270556417Remote.syncExcecute(JOnASRequestHandler1270556417Remote.java:122)
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:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at org.objectweb.carol.rmi.jrmp.server.JUnicastServerRef.dispatch(JUnicastServerRef.java:143)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
Caused by: 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:507)
at com.comp.proj.gateway.j2ee.RequestHandlerBean.save(Unknown Source)
at com.comp.proj.gateway.j2ee.RequestHandlerBean.syncExcecute(Unknown Source)
at org.objectweb.jonas_gen.com.comp.proj.gateway.j2ee.JOnASRequestHandler1270556417Remote.syncExcecute(JOnASRequestHandler1270556417Remote.java:114)
... 12 more
Name and version of the database you are using:SQLServer 2000[/code]