-->
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: comp/UserTransaction not found in context java: on WAS6.0.2
PostPosted: Thu Aug 17, 2006 12:59 pm 
Newbie

Joined: Wed May 17, 2006 8:26 am
Posts: 8
Location: Amsterdam
Hibernate version 3.2.0.CR2:

Hello I am getting the following exception when I try to use Hibernate on WebSphere 6.0.2.9:
Code:
org.hibernate.TransactionException: Could not find UserTransaction in JNDI:
   at org.hibernate.transaction.JTATransaction.<init>(JTATransaction.java:64)
   at org.hibernate.transaction.JTATransactionFactory.createTransaction(JTATransactionFactory.java:57)
   at org.hibernate.jdbc.JDBCContext.getTransaction(JDBCContext.java:186)
   at org.hibernate.impl.SessionImpl.getTransaction(SessionImpl.java:1308)
   at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1318)
   at rootpackage.application.business.logic.ServiceAgreementSvcBean.storeServiceAgreement(ServiceAgreementSvcBean.java:832)
   ... 37 more
Caused by: javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".
   at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1094)
   at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:990)
   at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1263)
   at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:201)
   at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:142)
   at javax.naming.InitialContext.lookup(InitialContext.java:361)
   at org.hibernate.transaction.JTATransaction.<init>(JTATransaction.java:60)


My SessionFactory configuration file looks as follows:
Code:
<session-factory name="java:hibernate/RootpackageEntitySessionFactory">

    <!-- DBMS dialect: oracle. -->
    <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>

    <property name="hibernate.connection.datasource">jdbc/optimalj5</property>

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

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

    <property name="hibernate.current_session_context_class">jta</property>


    <!-- Enable or disable SQL logging information -->
    <property name="show_sql">true</property>

    <!-- Cache manager -->
    <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>

    <!-- Mapping files for entity module: -->
    ...

  </session-factory>


I am aware of the former existence of this problem in Hibernate 3.0. But it appears it has been addressed: http://opensource.atlassian.com/projects/hibernate/browse/HHH-198.

Does anybody have a clue of what might be wrong? Shall I reopen HHH-198?

Regards,
Andrei.


Top
 Profile  
 
 Post subject: comp/UserTransaction not found in context java: on WAS6.0.2
PostPosted: Thu Sep 14, 2006 11:29 am 
Newbie

Joined: Tue Sep 27, 2005 5:44 pm
Posts: 13
Try using the following:

<property name="connection.datasource">[your websphere datasource name]</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">thisNode/servers/WebSphere_Portal/jta/usertransaction</property>


Top
 Profile  
 
 Post subject: comp/UserTransaction not found in context java:
PostPosted: Thu Sep 14, 2006 7:54 pm 
Newbie

Joined: Sat Jan 15, 2005 5:45 pm
Posts: 2
BMT enterprise beans and web components can use the Java Transaction API (JTA) UserTransaction interface to define the demarcation of a global transaction. The UserTransaction interface can be obtained by a JNDI lookup of java:comp/UserTransaction or from the SessionContext object using the getUserTransaction method..

The UserTransaction is not available to the following components:

* CMT enterprise beans. Any attempt by such beans to obtain the interface results in an exception in accordance with the EJB specification.
* Client applications running outside the Web and EJB containers.

Ensure that programs that perform a JNDI lookup of the UserTransaction interface, use an InitialContext that resolves to a local implementation of the interface. Also ensure that such programs use a JNDI location appropriate for the EJB version.


Regards F.meyer


Last edited by fmcamargo on Fri Sep 15, 2006 11:53 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: comp/UserTransaction not found in context java: on WAS6.0.2
PostPosted: Fri Sep 15, 2006 11:47 am 
Newbie

Joined: Tue Sep 27, 2005 5:44 pm
Posts: 13
That's fine, but if you've tried this in websphere app portal 6, you'd see comp/UserTransaction not available. Check out the associated bug/enhancement that was made to support websphere and their (mis)handling of JTA txns.


Top
 Profile  
 
 Post subject: WebSphere 6.0.2 WAR app - Problem with UserTransaction
PostPosted: Fri Oct 06, 2006 9:02 am 
Newbie

Joined: Fri Oct 06, 2006 8:46 am
Posts: 2
Location: Bristol, UK
WebSphere WAR application has issues with finding UserTransaction


Environment: Hibernate 3.0.5, Oracle 10g, WebSphere 6.0.2, WAR application

The application is a WAR running on JBoss and WebLogic with no problems, but having issues with WebSphere.

The application is a workflow processing app, which uses Hibernate for persisting configuration and process audit information. The source of the problem is that the application needs to create and manage some threads which are therefore not managed by WebSphere (e.g. use of Quartz scheduler, enhanced queue reading), and these threads will be writing audit information. Due to the approach to safeguarding resources used by WebSphere, where access to JNDI resources may involve ThreadLocal bindings, these non-WAS-managed threads do not have access to the UserTransaction in the normal location of 'java:comp/UserTransaction'. Instead the UserTransaction is available at 'jta/usertransaction'. Unfortunately other code calls the same persistence code from within WebSphere managed threads (MDBs, servlets) and then the UserTransaction is at java:comp/UserTransaction' and not at 'jta/usertransaction'.

This is clearly a WebSphere issue rather than a Hibernate one - I raise it here to inform others of the situation and in the hope that someone might have a better workaround than me. My current solution is to use a 'negatively enhanced' copy of JTATransaction to look up in JNDI under both locations, and to use a revised copy of JTATransactionFactory to create these JTATransactions. This works so far in all situations but is deeply unpleasant, however other solutions do violence to the application architecture and so are currently undesirable.

This is tested and works on WebSphere 6.0.2, and I am on the point of testing on WebSphere 5.1.


Top
 Profile  
 
 Post subject: WAS 6 Hibernate 3.2 CR4
PostPosted: Mon Oct 09, 2006 1:33 pm 
Newbie

Joined: Tue Jul 04, 2006 3:42 am
Posts: 9
Dear all,

I have read your comments, however i really didnt understand much.

First of all, where can i find WebSPhere_Portal JNDI name which is explained In one of the solutions, that is based on the new configuration property. We are usingWepshepre 6.1 network deployment. I dont know how to construct such a JNDI (which as i understood depends on the installation of portal server)? Do we need to install a new server, can we download it, is it already included, just a configuration is neened etc..?

Finally, the last solution, talks about "negatively enhanced" transaction lookup. Can you please elaborate on it with also attaching source codes?

I appreciate your help.

Thanks you all in advance( as usual i need emergent help as anyone else).

Regards,

Siyamed


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 10, 2006 11:34 am 
Newbie

Joined: Fri Oct 06, 2006 8:46 am
Posts: 2
Location: Bristol, UK
Hi,

Sorry I should have prefixed my comments with some explanation.

I wasn't commenting directly on the previous posting, but wanted to inform anyone who was interested that I have run across a similar issue when using WebSphere, a WAR app and Hibernate inside managed and non-managed threads.

Negatively enhanced just meant using a very crap hack which however works for me for now:

JTATransaction.begin(InitialContext context, String utName):

try {
ut = (UserTransaction) context.lookup(utName);
}
catch (NamingException ne) {
try {
ut = (UserTransaction) context.lookup(WEBSPHERE_BACKUP_NAME);
}
catch (NamingException nemore) {
log.error("Could not find UserTransaction in JNDI: " + ne.getMessage() + " : " + nemore.getMessage(), nemore);
throw new TransactionException("Could not find UserTransaction in JNDI: ", nemore);
}
}


Top
 Profile  
 
 Post subject: Use jndi name "jta/usertransaction" is OK.
PostPosted: Fri Feb 06, 2009 3:47 am 
Newbie

Joined: Tue Oct 07, 2008 4:43 am
Posts: 2
Location: Guangzhou, China
hibernate.cfg.xml
<property name="jta.UserTransaction">jta/usertransaction</property>

Spring config:
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="userTransactionName"
value="jta/usertransaction" /> </bean>


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.