-->
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.  [ 8 posts ] 
Author Message
 Post subject: Getting javax.transaction.TransactionManager
PostPosted: Tue Dec 23, 2003 10:32 am 
Hi,
Can anyone provide me some example code , to how to get the object of javax.transaction.TransactionManager using hibernate apis (or any alternate means) in Websphere Appserver. From TxManager , I need to get the javax.transaction.Transaction object. The thing is the TxManager invokes call back beforeCompletion and afterCompletion methods. For this , we need to implement the interface javax.transaction.Synchronization interface and override beforeCompletion and afterCompletion methods. The class that implements Synchronization interface has to be registered by passing the object to Transaction.registerSynchronization method. Since I am not getting TransactionManager object , the above functionality is failing in my application. This works fine in Weblogic , problem is with Websphere only. Can anyone tell me any alternate means of getting the TranactionManager object.
thanks

--------------------


Top
  
 
 Post subject:
PostPosted: Tue Dec 23, 2003 3:25 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
try to find manager in JNDI, but
you can use stateful bean as Synchronization interface implementation,
too.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 24, 2003 7:31 am 
baliukas wrote:
try to find manager in JNDI, but
you can use stateful bean as Synchronization interface implementation,
too.
.

thanks,
I am using the jndi for looking up. Looks like the Websphere does not support looking up of TransactionManager object(since this is container managed).

AND we are not using EJBs in our application . SO is there any other alternate solutions for making container to invoke the afterCompletion method.

I have one more doubt, the net.sf.transaction.WebsphereTransactionManagerLookup has one method getTransactionManager method. The hibernate apis uses this internally.
Since I was not able to lookup TranscactionManager oject at all, how hibernate api is able to get the Transaction Manager. Infact in the latest of websphere 5.1 , even this code is failing.


Top
  
 
 Post subject:
PostPosted: Wed Dec 24, 2003 9:20 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
try JCA if Websphere supports it. Looks like Websphere has some static method ( name depends on Websphere version ).
Try http://www.google.com, it can find answers almost to all questions.
It was found by google in ojb arhive:
http://www.mail-archive.com/ojb-user@db ... 05254.html


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 25, 2003 3:41 am 
baliukas wrote:
try JCA if Websphere supports it. Looks like Websphere has some static method ( name depends on Websphere version ).
Try http://www.google.com, it can find answers almost to all questions.
It was found by google in ojb arhive:
http://www.mail-archive.com/ojb-user@db ... 05254.html



The fact is IBM does not support lookup of TransactionManager. This was told by IBM Product group itself. Since hibernate has apis , I am not sure how it is able to lookup the TransactionManager object.

BTW, what is JCA. I am sorry, I have not heard this JCA.


Top
  
 
 Post subject:
PostPosted: Fri Dec 26, 2003 10:09 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
I was talking about J2EE Connector Architecture
http://java.sun.com/j2ee/connector/refe ... index.html.
Read section "Resource Adapter", It can be a good way to integrate hibernate and app server. Some of app servers support pluggable resource adapters, but I am not sure about IBM.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 30, 2003 3:46 am 
baliukas wrote:
I was talking about J2EE Connector Architecture
http://java.sun.com/j2ee/connector/refe ... index.html.
Read section "Resource Adapter", It can be a good way to integrate hibernate and app server. Some of app servers support pluggable resource adapters, but I am not sure about IBM.


I wanted one more thing. IBM says , it does not support jndi lookup of TransactionManager object. Even we explicitly try to create using WebsphereTransactionManagerFactory, the object is empty. Since hibernate has apis in class net.sf.hbernate.transaction.WebsphereTransactionManagerLookup, how it is able to access the TransactionManager object from its apis, which the IBM does not even support. Can anyone provide me the clear answer. I am totally confused.
Or can anyone tell me how do I contact the hibernate support team to clarify the above question.


Top
  
 
 Post subject:
PostPosted: Tue Dec 30, 2003 6:16 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Have a look at the sources, best place to find correct answers.
Code:
   public TransactionManager getTransactionManager(Properties props) throws HibernateException {
      try {
         Class clazz;
         try {
            clazz = Class.forName("com.ibm.ejs.jts.jta.TransactionManagerFactory");
            version = 5;
            log.info("WebSphere 5");
         }
         catch (Exception e) {
            clazz = Class.forName("com.ibm.ejs.jts.jta.JTSXA");
            version = 4;
            log.info("WebSphere 4");
         }
         
         return (TransactionManager) clazz.getMethod("getTransactionManager", null).invoke(null, null);
      }
      catch (Exception e) {
         throw new HibernateException( "Could not obtain WebSphere JTSXA instance", e );
      }
   }
   
   public String getUserTransactionName() {
      return version==5 ?
         "java:comp/UserTransaction":
         "jta/usertransaction";
   }


If you need active commercial support for Hibernate, click the support link http://www.hibernate.org/Support/CommercialSupportForHibernate

_________________
Emmanuel


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