-->
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.  [ 1 post ] 
Author Message
 Post subject: WebSphere throws IllegalResourceIn2PCTransactionException
PostPosted: Mon Aug 27, 2007 1:21 pm 
Newbie

Joined: Sat May 19, 2007 5:02 pm
Posts: 5
My problem is a simple one to describe, and hopefully a simple one to fix.

I am running WebSphere Application Server 6.1.0.5 and trying to use Hibernate
3.2.4SP1 to replace the CMP entity layer in our application. I have already
performed the same surgery on the JBoss deployment of the same application, but
I am running into some problems with the way WebSphere/Hibernate are handling
resource access (I think!)

Here's the process that takes place (which is a bit too complex to slip into a
code sample, below):

1. Stateless session EJB call begins.
2. Hibernate Session manager class (ours) constructs a session factory using
our configuration (see the "Initializing" exception, below). This is
done lazily, and therefore certainly within the EJB method's transaction.
3. The current session is retrieved from the session factory.
4. A call to the get() method (or save(), doesn't matter, this happens either
way) and the second ("Accessing", below) exception is thrown.
5. Everything fails :)

I can find little documentation on the specific exception I'm receiving, so
what I'd like is either someone's anecdotes on how they got
Hibernate+WebSphere to work, or step-by-step instructions on what changes I
need to make to my build, deployment, or installation process to make this
work. I should note, we do not use the IBM RAD tool for development; our build
process is ant-driven using standard tools such as xdoclet and so forth. We
try to minimize the container-specific footprint on our application, but we
will happily make such changes where appropriate.

I realize that this won't automagically spur responses, but I am a bit
desparate here; I've sold my boss on the idea of replacing our CMP with
Hibernate, and now I'm on the hook for making it work, ASAP. I'd like not to
disappoint him just before performance evaluations :)

Hibernate version: 3.2.4 SP1

Mapping documents:
I don't believe that these are relevant.

Code between sessionFactory.openSession() and session.close():
For what it's worth:

Code:
Session session = sessionFactory.getCurrentSession ();
DsmDocumentValue document = session.get (DsmDocumentValue.class, documentId);


Full stack trace of any exception that occurs:
There are two situations where the exception is occurring; one is when I attempt to initialize the session factory itself (first exception trace) and the other is when I attempt to _use_ the session factory (second trace).

Initializing:
Code:
------Start of DE processing------ = [8/27/07 8:39:41:440 GMT-07:00] , key = com.ibm.ws.Transaction.IllegalResourceIn2PCTransactionException com.ibm.ws.Transaction.JTA.TransactionImpl.enlistResource 1858
Exception = com.ibm.ws.Transaction.IllegalResourceIn2PCTransactionException
Source = com.ibm.ws.Transaction.JTA.TransactionImpl.enlistResource
probeid = 1858
Stack Dump = com.ibm.ws.Transaction.IllegalResourceIn2PCTransactionException: Illegal attempt to enlist multiple 1PC XAResources
   at com.ibm.ws.Transaction.JTA.RegisteredResources.enlistResource(RegisteredResources.java:398)
   at com.ibm.ws.Transaction.JTA.TransactionImpl.enlistResource(TransactionImpl.java:3090)
   at com.ibm.ws.Transaction.JTA.TranManagerSet.enlistOnePhase(TranManagerSet.java:438)
   at com.ibm.ejs.j2c.LocalTransactionWrapper.enlist(LocalTransactionWrapper.java:585)
   at com.ibm.ejs.j2c.ConnectionManager.lazyEnlist(ConnectionManager.java:1747)
   at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.lazyEnlist(WSRdbManagedConnectionImpl.java:2116)
   at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdbcConnection.java:600)
   at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.getMetaData(WSJdbcConnection.java:1533)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:86)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
   at com.aciworldwide.ecourier.utility.hibernate.HibernateCfgSessionFactoryProvider.createNewSessionFactory(HibernateCfgSessionFactoryProvider.java:95)
   at com.aciworldwide.ecourier.utility.hibernate.HibernateSessionManager.getSessionFactory(HibernateSessionManager.java:136)
   at com.aciworldwide.ecourier.utility.hibernate.HibernateSessionManager.getCurrentSession(HibernateSessionManager.java:89)
   at com.aciworldwide.ecourier.utility.ejb.AbstractSessionBean.getCurrentSession(AbstractSessionBean.java:719)
   at com.aciworldwide.ecourier.management.ejb.OperationsManagerSessionBean.createUser(OperationsManagerSessionBean.java:1118)
   at com.aciworldwide.ecourier.management.ejb.remote.EJSRemoteStatelessOperationsManager_096eb77f.createUser(Unknown Source)
   at com.aciworldwide.ecourier.management.ejb.remote._EJSRemoteStatelessOperationsManager_096eb77f_Tie.createUser(_EJSRemoteStatelessOperationsManager_096eb77f_Tie.java:406)
   at com.aciworldwide.ecourier.management.ejb.remote._EJSRemoteStatelessOperationsManager_096eb77f_Tie._invoke(_EJSRemoteStatelessOperationsManager_096eb77f_Tie.java:98)
   at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:613)
   at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:466)
   at com.ibm.rmi.iiop.ORB.process(ORB.java:503)
   at com.ibm.CORBA.iiop.ORB.process(ORB.java:1552)
   at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2673)
   at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2551)
   at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:62)
   at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
   at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)


Accessing:
Code:
[8/27/07 9:38:01:651 GMT-07:00] 00000043 ExceptionUtil E   CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "addTrackingEvent" on bean "BeanId(cralphaiss_e-Courier#ecasServerEjb.jar#DocumentManager, null)". Exception data: org.hibernate.exception.GenericJDBCException: could not load an entity: [com.aciworldwide.ecourier.dsmv2.data.DsmDocumentValue#1157da53-7a59-4a96-a749-a02f535c058a]
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.loader.Loader.loadEntity(Loader.java:1874)
   at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
   at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
   at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
   at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
   at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
   at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
   at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
   at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
   at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
   at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
   at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
   at com.aciworldwide.ecourier.dsmv2.manager.DocumentManager.findByDocumentId(DocumentManager.java:209)
   at com.aciworldwide.ecourier.dsmv2.manager.DocumentManager.addTrackingEvent(DocumentManager.java:272)
   at com.aciworldwide.ecourier.management.ejb.DocumentManagerSessionBean.addTrackingEvent(DocumentManagerSessionBean.java:730)
   at com.aciworldwide.ecourier.management.ejb.remote.EJSRemoteStatelessDocumentManager_dff32e35.addTrackingEvent(Unknown Source)
   at com.aciworldwide.ecourier.management.ejb.remote._EJSRemoteStatelessDocumentManager_dff32e35_Tie.addTrackingEvent(_EJSRemoteStatelessDocumentManager_dff32e35_Tie.java:228)
   at com.aciworldwide.ecourier.management.ejb.remote._EJSRemoteStatelessDocumentManager_dff32e35_Tie._invoke(_EJSRemoteStatelessDocumentManager_dff32e35_Tie.java:119)
   at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:613)
   at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:466)
   at com.ibm.rmi.iiop.ORB.process(ORB.java:503)
   at com.ibm.CORBA.iiop.ORB.process(ORB.java:1552)
   at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2673)
   at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2551)
   at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:62)
   at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
   at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)
Caused by: java.sql.SQLException: enlist: caught Exception
   at com.ibm.ws.rsadapter.AdapterUtil.toSQLException(AdapterUtil.java:1247)
   at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdbcConnection.java:654)
   at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:2016)
   at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1971)
   at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:505)
   at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
   at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
   at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
   at org.hibernate.loader.Loader.doQuery(Loader.java:673)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
   ... 26 more
Caused by: javax.resource.ResourceException: enlist: caught Exception
   at com.ibm.ejs.j2c.LocalTransactionWrapper.enlist(LocalTransactionWrapper.java:688)
   at com.ibm.ejs.j2c.ConnectionManager.lazyEnlist(ConnectionManager.java:1747)
   at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.lazyEnlist(WSRdbManagedConnectionImpl.java:2116)
   at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdbcConnection.java:600)
   ... 35 more
Caused by: com.ibm.ws.Transaction.IllegalResourceIn2PCTransactionException: Illegal attempt to enlist multiple 1PC XAResources
   at com.ibm.ws.Transaction.JTA.RegisteredResources.enlistResource(RegisteredResources.java:398)
   at com.ibm.ws.Transaction.JTA.TransactionImpl.enlistResource(TransactionImpl.java:3090)
   at com.ibm.ws.Transaction.JTA.TranManagerSet.enlistOnePhase(TranManagerSet.java:438)
   at com.ibm.ejs.j2c.LocalTransactionWrapper.enlist(LocalTransactionWrapper.java:585)
   ... 38 more


Name and version of the database you are using:
Oracle 9i

The generated SQL (show_sql=true):
Not relevant

Debug level Hibernate log excerpt:
I can provide this if it turns out to be necessary, but the stack traces appear to be sufficient.

Quote:
Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


I have read it :)

_________________
Chris R


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

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.