Summary:
I have an application that uses the following technologies:
Databses: Oracle 9i, Sybase
Application Servers: Weblogic, JBoss, WebSphere
Hibernate 2.1.8
I am using CMT. I also have code that explicitly begins and commits transactions as shown in the fragment below.
Transaction code is :
public void insertOrUpdate(ProcessInstance pi) throws HibernateException {
Session s = HibernateUtil.openSession();
Transaction tx = s.beginTransaction();
try {
s.saveOrUpdate(pi);
if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("Inserted or updated processInstance" + pi.getProcessInstanceId() );
tx.commit();
} catch (HibernateException he) {
...
}
finally {
HibernateUtil.closeSession(s);
}
Above code works fine with JBoss and Weblogic, but throws an exception with WebSphere-
(net.sf.hibernate.transaction.JTATransaction Could not find UserTransaction in JNDI )
Requirement:
I want to make my code portable across several application servers like JBoss, Weblogic and Websphere and across several databases like Oracle, Sybase, UDB etc.
Issues:
1. This code does not work with Websphere. There are known issues with hibernate and Websphere 5.x. Hibernate forum suggest that there was problem till 2.1.6 but it get fixed in 2.1.8.
http://forum.hibernate.org/viewtopic.ph ... 10#2230010
http://opensource.atlassian.com/project ... se/HB-1354
Has anyone verified whether the fix resolves the issue [ hibernate 2.1.8 and Websphere5.1 (getting NameNotFoundException). ] Any ideas to resolve this issue.
2. We are using CMT, so we should not explicitly begin and end transaction. But we are.
Then why things work properly with JBOSS and Weblogic but not with WebSphere?
3. We have multiple inserts and updates in one transaction. There is a possibility of deadlock under multiple threads. Can hibernate take care of session synchronization?
4. Should we provide synchronization at application level to make it portable?
5. What changes would be required to support transactions ?
One option can be:
• Not open a new session if there is already a session open for this thread HibernateUtil)
• Provide a method to register a synchronization that looks up the appropriate transaction manager and transaction (HibernateUtil)
• Implement Synchronizer interface and register synchronization, so we can get an afterCompletion callback
• Close session
Refer the link for this
http://forum.hibernate.org/viewtopic.php?p=2207904.
What other alternatives are possible?
What solution will allow us to support WebSphere, and resolve the deadlock issue?
I would appreciate opinions/suggestions to address above issues.