-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: oc4j and UserTransaction
PostPosted: Mon Jan 24, 2005 5:54 pm 
Newbie

Joined: Sun Nov 09, 2003 12:34 pm
Posts: 15
Hi,

We just switched from oc4j 9.0.4 to 10.1.2 and and now getting this wierd behaviour.

14:43:58,731 FATAL [HibernateSessionDispenser] fatal persistence error while creating hibernate session for /hibernate.cfg.xml: Could not locate TransactionManager
net.sf.hibernate.HibernateException: Could not locate TransactionManager
at net.sf.hibernate.transaction.JNDITransactionManagerLookup.getTransactionManager(JNDITransactionManagerLookup.java:26)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:204)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:750)

Caused by: javax.naming.NameNotFoundException: Only session and message-driven beans with bean-managed transaction are allowed to use UserTransaction
at com.evermind.server.ApplicationContext.lookupJavaCompRsrc(ApplicationContext.java:180)
at com.evermind.server.ApplicationContext.lookupJavaComp(ApplicationContext.java:136)
at com.evermind.server.ApplicationContext.lookup(ApplicationContext.java:306)
at com.evermind.server.ApplicationContext.lookup(ApplicationContext.java:120)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at net.sf.hibernate.transaction.JNDITransactionManagerLookup.getTransactionManager(JNDITransactionManagerLookup.java:23)
... 22 more

In the hibernate.cfg.xml we have specified OrionTransactionManagerLookup
Code:
<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.OrionTransactionManagerLookup</property >


What should we change to avoid this error?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 01, 2005 6:58 pm 
Newbie

Joined: Tue Oct 19, 2004 3:39 pm
Posts: 11
Without all the details, my suspicion (only because I just encountered a similar problem with Websphere) is that you have a CMT in which you are trying to use Hibernate Transaction API?

I think there is some differences in the interpretation of the specification, but, the latest release of both Oracle and IBM's Application Servers appear to not allow you to access the usertransation from within a CMT. Hibernate expects the UserTransaction to be available, hence the error in your stack trace.

Websphere provides an extendedJTATransaction API that allows you to tie back to the UserTransaction in a propietary fashion. Perhaps OC4J has something similar.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 12:58 pm 
Newbie

Joined: Wed Feb 04, 2004 7:12 am
Posts: 18
Location: Brasilia - Brazil
jupson_us wrote:
Without all the details, my suspicion (only because I just encountered a similar problem with Websphere) is that you have a CMT in which you are trying to use Hibernate Transaction API?

I think there is some differences in the interpretation of the specification, but, the latest release of both Oracle and IBM's Application Servers appear to not allow you to access the usertransation from within a CMT. Hibernate expects the UserTransaction to be available, hence the error in your stack trace.

Websphere provides an extendedJTATransaction API that allows you to tie back to the UserTransaction in a propietary fashion. Perhaps OC4J has something similar.


I am trying to do the same thing using hibernate 3.0.5 without success, when I try to do some transactional stuff, the folowing exception is thrown:

org.hibernate.HibernateException: Could not locate TransactionManager
at org.hibernate.transaction.JNDITransactionManagerLookup.getTransactionManager(JNDITransactionManagerLookup.java:26)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:270)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at br.com.portage.banco.frw.dao.hibernate.AbstractHibernateDAO.<clinit>(AbstractHibernateDAO.java:31)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at br.com.portage.banco.frw.dao.DAOFactory.getDAO(DAOFactory.java:69)
at br.com.portage.banco.ejb.ContaBean.novaConta(ContaBean.java:38)
at Conta_StatelessSessionBeanWrapper0.novaConta(Conta_StatelessSessionBeanWrapper0.java:100)
at br.com.portage.banco.web.NovaContaServlet.doPost(NovaContaServlet.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:810)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:534)
Caused by: javax.naming.NameNotFoundException: Only session and message-driven beans with bean-managed transaction are allowed to use UserTransaction
at com.evermind.server.ApplicationContext.lookupJavaCompRsrc(ApplicationContext.java:180)

How can I use Hibernate + OC4J + CMT?

Thanks

_________________
___________________________
[ MediaSonic (www.geleira.org) ]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 20, 2005 4:45 pm 
Newbie

Joined: Mon Jun 20, 2005 4:06 pm
Posts: 1
Hi.
I have same problem.
I use oc4j 10g (10.1.2.0.0).

My hibernate.cfg.xml:
<property name="transaction.manager_lookup_class">
org.hibernate.transaction.OrionTransactionManagerLookup
</property>
<property name="transaction.factory_class">
org.hibernate.transaction.CMTTransactionFactory
</property>

<property name="flush_before_completion">true</property>
<property name="auto_close_session">true</property>
<property name="release_mode">auto</property>

After call build session factory:
sessionFactory = new Configuration().configure().buildSessionFactory();
I will get same exception as Chotasher.

I use EJB session bean with CMT transaction type.

Where is the problem? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 3:36 pm 
Newbie

Joined: Wed Feb 04, 2004 7:12 am
Posts: 18
Location: Brasilia - Brazil
kuko wrote:
Hi.
I have same problem.
I use oc4j 10g (10.1.2.0.0).

My hibernate.cfg.xml:
<property name="transaction.manager_lookup_class">
org.hibernate.transaction.OrionTransactionManagerLookup
</property>
<property name="transaction.factory_class">
org.hibernate.transaction.CMTTransactionFactory
</property>

<property name="flush_before_completion">true</property>
<property name="auto_close_session">true</property>
<property name="release_mode">auto</property>

After call build session factory:
sessionFactory = new Configuration().configure().buildSessionFactory();
I will get same exception as Chotasher.

I use EJB session bean with CMT transaction type.

Where is the problem? Thanks.


I was reading the EJB 2.0 spec and I found one interesting thing in the section 17.6.2.10:

Handling of getUserTransaction() method
If an instance of an enterprise bean with container-managed transaction demarcation attempts to invoke
the getUserTransaction() method of the EJBContext interface, the Container must throw the
java.lang.IllegalStateException.

Is it the problem? Hibernate is doing something illegal according to the spec? Or the UserTransaction its not not taken from the Context? So where is the problem?

Thanks,

_________________
___________________________
[ MediaSonic (www.geleira.org) ]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 4:36 pm 
Newbie

Joined: Wed Feb 04, 2004 7:12 am
Posts: 18
Location: Brasilia - Brazil
MediaSonic wrote:
kuko wrote:
Hi.
I have same problem.
I use oc4j 10g (10.1.2.0.0).

My hibernate.cfg.xml:
<property name="transaction.manager_lookup_class">
org.hibernate.transaction.OrionTransactionManagerLookup
</property>
<property name="transaction.factory_class">
org.hibernate.transaction.CMTTransactionFactory
</property>

<property name="flush_before_completion">true</property>
<property name="auto_close_session">true</property>
<property name="release_mode">auto</property>

After call build session factory:
sessionFactory = new Configuration().configure().buildSessionFactory();
I will get same exception as Chotasher.

I use EJB session bean with CMT transaction type.

Where is the problem? Thanks.


I was reading the EJB 2.0 spec and I found one interesting thing in the section 17.6.2.10:

Handling of getUserTransaction() method
If an instance of an enterprise bean with container-managed transaction demarcation attempts to invoke
the getUserTransaction() method of the EJBContext interface, the Container must throw the
java.lang.IllegalStateException.

Is it the problem? Hibernate is doing something illegal according to the spec? Or the UserTransaction its not not taken from the Context? So where is the problem?

Thanks,


Ok, the solution is to use JDBCTransactionFactory and ommit hibernate.transaction.manager_lookup_class and/or jta.UserTransaction.

But doing this, you'll must flush and close Session explicity.

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory name="java:hibernate/SessionFactory">
<property name="connection.datasource">java:comp/env/jdbc/bankDS</property>
<property name="show_sql">false</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="use_outer_join">true</property>

<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

<property name="hibernate.cache.use_query_cache">true</property>

<!-- It won't work at all -->
<property name="hibernate.connection.release_mode">auto</property>
<property name="hibernate.transaction.auto_close_session">true</property>
<property name="hibernate.transaction.flush_before_completion">true</property>
<!-- /It won't work at all -->

<mapping resource="Account.hbm.xml"/>
</session-factory>
</hibernate-configuration>

_________________
___________________________
[ MediaSonic (www.geleira.org) ]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 3:18 am 
Newbie

Joined: Mon Jul 11, 2005 4:35 am
Posts: 7
If using Hibernate 3.x, try to change your

<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.OrionTransactionManagerLookup</property >

to

<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.OrionTransactionManagerLookup</property>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 04, 2005 2:27 pm 
Newbie

Joined: Wed Feb 04, 2004 7:12 am
Posts: 18
Location: Brasilia - Brazil
nishiki wrote:
If using Hibernate 3.x, try to change your

<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.OrionTransactionManagerLookup</property >

to

<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.OrionTransactionManagerLookup</property>


Hi, thank you for the answer, but it is not working yet.
Using the factory org.hibernate.transaction.JDBCTransactionFactory, it works well, but I need to flush() every time I change data on my objetct.

For performance reasons, it is desirable to flush only on transaction commit. Do you know what can I do for?

Thanks a lot.

_________________
___________________________
[ MediaSonic (www.geleira.org) ]


Top
 Profile  
 
 Post subject: OC4JTransactionManagerLookup
PostPosted: Wed Nov 02, 2005 5:26 pm 
Newbie

Joined: Wed Nov 02, 2005 5:20 pm
Posts: 9
You can use OC4JTransactionManagerLookup.java in following link to fix the exception:

http://opensource2.atlassian.com/projec ... se/HB-1529


Top
 Profile  
 
 Post subject: Re: OC4JTransactionManagerLookup
PostPosted: Wed Nov 02, 2005 5:32 pm 
Newbie

Joined: Wed Feb 04, 2004 7:12 am
Posts: 18
Location: Brasilia - Brazil
jifengl wrote:
You can use OC4JTransactionManagerLookup.java in following link to fix the exception:

http://opensource2.atlassian.com/projec ... se/HB-1529


Hi, thank you, when we solved the problem, I've changed transaction manager lookup class and now it is working. Anyway, it's nice to see we have a new version.

http://forum.hibernate.org/viewtopic.ph ... highlight=

_________________
___________________________
[ MediaSonic (www.geleira.org) ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.