-->
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.  [ 15 posts ] 
Author Message
 Post subject: Websphere and JTATransaction
PostPosted: Fri Sep 10, 2004 5:52 am 
Beginner
Beginner

Joined: Thu May 06, 2004 5:30 am
Posts: 45
Hibernate version:
2.1.4
Mapping documents:

Code between sessionFactory.openSession() and session.close():
Session session = null;
Transaction transaction = null;
List companyList = null;

session = HibernateDAOFactory.currentSession();
transaction = session.beginTransaction();
companyList = session.find ("from Company");
transaction.commit();
HibernateDAOFactory.closeSession();

Name and version of the database you are using:
IBM DB2
WEBSPHERE 5.0.2.

I want to use JTATransaction, so I specified following in my Hibernate.cfg:
<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.WebSphereTransactionManagerLookup</property>
<property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">UserTransaction</property>

But I'm getting the following exception:
JTATransactio E net.sf.hibernate.transaction.JTATransaction TRAS0014I: The following exception was logged javax.naming.NameNotFoundException: UserTransaction. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound


Can I use JTATransaction out of my EJB's???


Top
 Profile  
 
 Post subject: JTA transaction with Weblogic
PostPosted: Fri Sep 10, 2004 6:20 am 
Newbie

Joined: Fri Jul 16, 2004 2:02 am
Posts: 13
Yeah! JTA can be used out of EJB
I have done it in Weblogic !
It should be applicable to Websphere as well.
Try out by finding the JNDI name of UserTransaction in Websphere!
and supply the path
e.g. it is javax/transaction/UserTransaction in Weblogic

_________________
Kary


Top
 Profile  
 
 Post subject: Re: JTA transaction with Weblogic
PostPosted: Fri Sep 10, 2004 6:37 am 
Beginner
Beginner

Joined: Thu May 06, 2004 5:30 am
Posts: 45
krishma.bansal wrote:
Yeah! JTA can be used out of EJB
I have done it in Weblogic !
It should be applicable to Websphere as well.
Try out by finding the JNDI name of UserTransaction in Websphere!
and supply the path
e.g. it is javax/transaction/UserTransaction in Weblogic


Could you be a little more specific?
So I should use:
<property name="jta.UserTransaction">javax/transaction/UserTransaction</property>
??
Should I change something else?

Because I tried this, and it didn't work...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 10, 2004 6:41 am 
Newbie

Joined: Fri Jul 16, 2004 2:02 am
Posts: 13
This is what I did in weblogic! with Oracle



<property name="hibernate.connection.datasource" value=<Name of datasource>/>
<property name="hibernate.dialect" value="net.sf.hibernate.dialect.Oracle9Dialect"/>
<property name="hibernate.use_outer_join" value="true"/>
<property name="hibernate.max_fetch_depth" value="1"/>
<property name="hibernate.jdbc.batch_size" value="15"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.transaction.manager_lookup_class" value="net.sf.hibernate.transaction.WeblogicTransactionManagerLookup"/>
<property name="hibernate.transaction.factory_class" value="net.sf.hibernate.transaction.JTATransactionFactory"/>
<property name="jta.UserTransaction" value="javax/transaction/UserTransaction"/>
<property name="cglib.use_reflection_optimizer" value="true"/>
<property name="jdbc.use_streams_for_binary" value="true"/>


The only thing you need is to search out for the path of 'UserTransaction' class supllied by app. server(Websphere)
It is javax/transaction/UserTransaction in weblogic!
It might be different in Websphere!

_________________
Kary


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 10, 2004 6:53 am 
Beginner
Beginner

Joined: Thu May 06, 2004 5:30 am
Posts: 45
krishma.bansal wrote:
This is what I did in weblogic! with Oracle



<property name="hibernate.connection.datasource" value=<Name of datasource>/>
<property name="hibernate.dialect" value="net.sf.hibernate.dialect.Oracle9Dialect"/>
<property name="hibernate.use_outer_join" value="true"/>
<property name="hibernate.max_fetch_depth" value="1"/>
<property name="hibernate.jdbc.batch_size" value="15"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.transaction.manager_lookup_class" value="net.sf.hibernate.transaction.WeblogicTransactionManagerLookup"/>
<property name="hibernate.transaction.factory_class" value="net.sf.hibernate.transaction.JTATransactionFactory"/>
<property name="jta.UserTransaction" value="javax/transaction/UserTransaction"/>
<property name="cglib.use_reflection_optimizer" value="true"/>
<property name="jdbc.use_streams_for_binary" value="true"/>


The only thing you need is to search out for the path of 'UserTransaction' class supllied by app. server(Websphere)
It is javax/transaction/UserTransaction in weblogic!
It might be different in Websphere!

It is also javax/transaction/UserTransaction in websphere, but when I try your config (for websphere), I still get:
JTATransactio E net.sf.hibernate.transaction.JTATransaction TRAS0014I: The following exception was logged javax.naming.NameNotFoundException: javax/transaction/UserTransaction. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 10, 2004 7:33 am 
Newbie

Joined: Fri Jul 16, 2004 2:02 am
Posts: 13
Which trasaction manager are u using?

Is it like
<transactionManager type="HIBERNATE">
.....properties
</transactionManager>

_________________
Kary


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 10, 2004 7:34 am 
Newbie

Joined: Fri Jul 16, 2004 2:02 am
Posts: 13
Which transaction manager are u using?

Is it like
<transactionManager type="HIBERNATE">
.....properties
</transactionManager>

_________________
Kary


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 10, 2004 7:41 am 
Beginner
Beginner

Joined: Thu May 06, 2004 5:30 am
Posts: 45
krishma.bansal wrote:
Which transaction manager are u using?

Is it like
<transactionManager type="HIBERNATE">
.....properties
</transactionManager>

I don't use a transactionManager like that.. I just use my db2-datasource in websphere.

I'm getting desperate.. why don't it just work! :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 10, 2004 7:48 am 
Newbie

Joined: Fri Jul 16, 2004 2:02 am
Posts: 13
Ok I think ur dao.xml should look like this:

<!DOCTYPE daoConfig PUBLIC "-//iBATIS.com//DTD DAO Configuration 2.0//EN"
"http://www.ibatis.com/dtd/dao-2.dtd">
<!--<daoConfig>

<context >
<transactionManager type="JTA">
<property name="UserTransaction" value="javax/transaction/UserTransaction"/>
<property name="DBJndiContext" value="MyJNDIName"/>
<property name="class.1" value="com.mitchell.dto.UserStatusDTO"/>
</transactionManager>
<dao interface="com.mitchell.dao.UserStatusDAO" implementation="com.mitchell.dao.hibernate.ibatis.UserStatusHibernateDAO"/>
</context>
</daoConfig>
-->
<daoConfig>
<context>
<transactionManager type="HIBERNATE">
<property name="hibernate.connection.datasource" value="TlvTigerJndiPath"/>
<property name="hibernate.dialect" value="net.sf.hibernate.dialect.Oracle9Dialect"/>
<property name="hibernate.use_outer_join" value="true"/>
<property name="hibernate.max_fetch_depth" value="1"/>
<property name="hibernate.jdbc.batch_size" value="15"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.transaction.manager_lookup_class" value="net.sf.hibernate.transaction.WeblogicTransactionManagerLookup"/>
<property name="hibernate.transaction.factory_class" value="net.sf.hibernate.transaction.JTATransactionFactory"/>
<property name="jta.UserTransaction" value="javax/transaction/UserTransaction"/>
<property name="cglib.use_reflection_optimizer" value="true"/>
<property name="jdbc.use_streams_for_binary" value="true"/>


<!-- mapping file -->

<property name="class.1" value="com.mitchell.dto.UserStatusDTO"/>


</transactionManager>

<dao interface="com.mitchell.dao.UserStatusDAO" implementation="com.mitchell.dao.hibernate.ibatis.UserStatusHibernateDAO"/>
</context>
</daoConfig>

_________________
Kary


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 10, 2004 7:53 am 
Newbie

Joined: Fri Jul 16, 2004 2:02 am
Posts: 13
ok ! try using the following path for user transaction

java:comp/UserTransaction

_________________
Kary


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 10, 2004 8:01 am 
Beginner
Beginner

Joined: Thu May 06, 2004 5:30 am
Posts: 45
krishma.bansal wrote:
ok ! try using the following path for user transaction

java:comp/UserTransaction

Ok now I'm confused. I'm not using iBatis, just Hibernate.

I also tried to use: jta/usertransaction instead of javax/transaction/UserTransaction. But it didn't get me further, I got following exception:

JTATransaction TRAS0014I: The following exception was logged com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. Root exception is javax.naming.ConfigurationException

I also tried java:comp/UserTransaction, but this also gave me an exception:

JTATransactio E net.sf.hibernate.transaction.JTATransaction TRAS0014I: The following exception was logged javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".


Are you sure it is possible with JTA, without EJB's in an container-managed environment such as jboss, websphere, weblogic,...???


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 10, 2004 8:46 am 
Newbie

Joined: Fri Jul 16, 2004 2:02 am
Posts: 13
It is definitely possible through hibernate!
This functionality is not provided by ibatis but by hibernate!

The only thing is to make UserTransaction class available to JTATransactionFactory.

_________________
Kary


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 10, 2004 4:00 pm 
Newbie

Joined: Tue Jun 15, 2004 10:45 am
Posts: 18
Location: Boston, USA
Did you have to add the j2ee.jar file to your weblogic classpath to have this work. Hibernate currently throws an instanciationException when trying to instanciate the UserTransaction class using the settings you provided above.

_________________
Quinton Wall

"The most difficult thing in the world is to know how to do a thing and to watch somebody else doing it wrong,without comment" -
- T.H. White


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 11, 2004 12:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
-FoX- wrote:
krishma.bansal wrote:
ok ! try using the following path for user transaction

java:comp/UserTransaction

Ok now I'm confused. I'm not using iBatis, just Hibernate.

Huh? what would ibatis v. hibernate have to do with UserTransaction lookups? That is app server functionality, not ORM.

Why don't you just take some time and go through the websphere docs to find out where in JNDI it makes the current UserTransaction available. Does it even make it available via JNDI (some do not)? Much simplier than blind guesses :)

Quote:
Did you have to add the j2ee.jar file to your weblogic classpath to have this work.

WebLogic is a J2EE server. Why would you need to add j2ee.jar to your weblogic classpath?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 11, 2004 5:11 am 
Newbie

Joined: Tue Jun 15, 2004 10:45 am
Posts: 18
Location: Boston, USA
That was my thought too...but after adding it to the classpath life was good.

With that said, I was using the MyEclipseIDE connector to control Weblogic startup and shutdown which does not use the start scripts provided by Weblogic.

_________________
Quinton Wall

"The most difficult thing in the world is to know how to do a thing and to watch somebody else doing it wrong,without comment" -
- T.H. White


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 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.