I am using Hibernate on Websphere 5.1.3 with Container Managed JTA Transcations in facade Session Beans.
hibernate.transaction.factory_class=org.hibernate.transaction.CMTTransactionFactory
hibernate.transaction.manager_lookup_class=org.hibernate.transaction.WebSphereTransactionManagerLookup
The facade Session Beans are invoked remotely from Cactus Tests in a seperate EAR. I have been getting a NullPointerException while before_completion synchronization operation.
Any suggestions would be appreciated.
Hibernate version: 3.0.5
Mapping documents:
This is a abridged version. The table has more than 200 columns.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="com.mycom.ejb.msf628.MSF628Rec"
table="MSF628">
<composite-id
name="primaryKey"
class="com.mycom.ejb.msf628.MSF628Key">
<key-property
name="dstrctCode"
type="java.lang.String"
column="DSTRCT_CODE" />
<key-property
name="workOrder"
type="java.lang.String"
column="WORK_ORDER" />
<key-property
name="actionDate"
type="java.lang.String"
column="ACTION_DATE" />
<key-property
name="actionTime"
type="java.lang.String"
column="ACTION_TIME" />
</composite-id>
<property
name="rsNoticeId"
type="java.lang.String"
update="true"
insert="true"
column="RS_NOTICE_ID" />
<property
name="actionTaken"
type="java.lang.String"
update="true"
insert="true"
column="ACTION_TAKEN" />
<property
name="noticeType"
type="java.lang.String"
update="true"
insert="true"
column="NOTICE_TYPE" />
...........
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():This method requires a J2EE Container managed transaction.
Code:
/**
* Create Method
* @ejb.interface-method view-type="remote"
*/
public Object create(Object rec) throws CreateException, NamingException, EDOIApplicationException {
MSF628Rec value = MSF628Helper.validateVO((MSF628Rec) rec);
try {
Session session = HibernateUtil.getSession();
session.save(value);
}
catch (ConstraintViolationException e){
throw new DuplicateKeyException(e.getMessage());
}
catch (HibernateException e){
throw new CreateException(e.getMessage());
}catch (Exception ex){
ex.printStackTrace();
}
return value;
}
HibernateUtil.javaCode:
public class HibernateUtil {
private static SessionFactory sessionFactory;
static {
try {
Configuration cfg = new Configuration();
cfg.setProperties(EDOIProperties.getProperties());
EDOILogger.trace.debug("Hibernate Config setup with values from Edoi Properties File");
cfg.addResource("com/mycom/ejb/msf628/MSF628Rec.hbm.xml");
cfg.buildSessionFactory();
} catch (EDOIApplicationException ex) {
EDOILogger.exception.fatal("Initial SessionFactory creation failed.");
throw new ExceptionInInitializerError(ex.getMessage());
} catch (Throwable ex) {
EDOILogger.exception.fatal("Initial SessionFactory creation failed.");
throw new ExceptionInInitializerError(ex.getMessage());
}
}
public static SessionFactory getSessionFactory() throws NamingException {
SessionFactory sessions = null;
Context ctx = new InitialContext();
String jndiName = "com/mycom/common/HibernateUtil";
sessions = (SessionFactory) ctx.lookup(jndiName);
return sessions;
}
public static Session getSession() throws EDOIApplicationException{
Session s;
try {
s= getSessionFactory().getCurrentSession();
} catch (HibernateException ex) {
throw new EDOIApplicationException(ex.getMessage());
} catch (NamingException ex) {
throw new EDOIApplicationException(ex.getMessage());
}
return s;
}
}
Full stack trace of any exception that occurs:Code:
[3/10/05 16:00:20:416 EST] 46a6641c RegisteredSyn E WTRN0074E: Exception caught from before_completion synchronization operation: java.lang.NullPointerException
at oracle.jdbc.dbaccess.DBData.clearItem(DBData.java:431)
at oracle.jdbc.dbaccess.DBDataSetImpl.clearItem(DBDataSetImpl.java:3528)
at oracle.jdbc.driver.OraclePreparedStatement.clearParameters(OraclePreparedStatement.java:3401)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.resetStatement(WSJdbcConnection.java:1842)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1524)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1487)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:396)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:76)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:69)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:150)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1839)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2200)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:46)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:58)
at com.ibm.ws.Transaction.JTA.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:135)
at com.ibm.ws.Transaction.JTA.TransactionImpl.internalPrepare(TransactionImpl.java:1230)
at com.ibm.ws.Transaction.JTA.TransactionImpl.commit(TransactionImpl.java:979)
at com.ibm.ws.Transaction.JTA.TranManagerImpl.commit(TranManagerImpl.java:150)
at com.ibm.ws.Transaction.JTA.TranManagerSet.commit(TranManagerSet.java:177)
at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:712)
at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:167)
at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:565)
at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3068)
at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:2946)
at com.mycom.ejb.msf628.EJSRemoteStatelessMSF628Facade_0ecaade7.create(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at com.ibm.rmi.util.ProxyUtil$4.run(ProxyUtil.java:726)
at java.security.AccessController.doPrivileged1(Native Method)
at java.security.AccessController.doPrivileged(AccessController.java:351)
at com.ibm.rmi.util.ProxyUtil.invokeWithClassLoaders(ProxyUtil.java:724)
at com.ibm.CORBA.iiop.ClientDelegate.invoke(ClientDelegate.java:1121)
at $Proxy3.create(Unknown Source)
at com.mycom.ejb.msf628._MSF628Facade_Stub.create(_MSF628Facade_Stub.java:325)
at com.mycom.ejb.msf628.test.MSF628Test.standardCreate(MSF628Test.java:225)
at com.mycom.ejb.msf628.test.MSF628Test.testMSF628Create(MSF628Test.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)
at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:224)
at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:224)
at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:224)
at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:1049)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:600)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:201)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:125)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:286)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:624)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:448)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:912)
Name and version of the database you are using: Oracle 9
Debug level Hibernate log excerpt:Code:
[3/10/05 16:00:17:338 EST] 46a6641c Environment I org.hibernate.cfg.Environment Hibernate 3.0.5
[3/10/05 16:00:17:338 EST] 46a6641c Environment I org.hibernate.cfg.Environment hibernate.properties not found
[3/10/05 16:00:17:353 EST] 46a6641c Environment I org.hibernate.cfg.Environment using CGLIB reflection optimizer
[3/10/05 16:00:17:353 EST] 46a6641c Environment I org.hibernate.cfg.Environment using JDK 1.4 java.sql.Timestamp handling
[3/10/05 16:00:17:744 EST] 46a6641c Configuration I org.hibernate.cfg.Configuration Mapping resource: com/mycom/ejb/msf628/MSF628Rec.hbm.xml
[3/10/05 16:00:18:150 EST] 46a6641c HbmBinder I org.hibernate.cfg.HbmBinder Mapping class: com.mycom.ejb.msf628.MSF628Rec -> MSF628
[3/10/05 16:00:18:244 EST] 46a6641c Configuration I org.hibernate.cfg.Configuration processing extends queue
[3/10/05 16:00:18:244 EST] 46a6641c Configuration I org.hibernate.cfg.Configuration processing collection mappings
[3/10/05 16:00:18:244 EST] 46a6641c Configuration I org.hibernate.cfg.Configuration processing association property references
[3/10/05 16:00:18:244 EST] 46a6641c Configuration I org.hibernate.cfg.Configuration processing foreign key constraints
[3/10/05 16:00:19:025 EST] 46a6641c NamingHelper I org.hibernate.util.NamingHelper JNDI InitialContext properties:{}
[3/10/05 16:00:19:025 EST] 46a6641c DatasourceCon I org.hibernate.connection.DatasourceConnectionProvider Using datasource: jdbc/EllipseDatasource
[3/10/05 16:00:19:041 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory RDBMS: Oracle, version: Oracle9i Release 9.2.0.1.0 - Production
JServer Release 9.2.0.1.0 - Production
[3/10/05 16:00:19:041 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory JDBC driver: Oracle JDBC driver, version: 9.2.0.1.0
[3/10/05 16:00:19:103 EST] 46a6641c Dialect I org.hibernate.dialect.Dialect Using dialect: org.hibernate.dialect.OracleDialect
[3/10/05 16:00:19:134 EST] 46a6641c TransactionFa I org.hibernate.transaction.TransactionFactoryFactory Transaction strategy: org.hibernate.transaction.CMTTransactionFactory
[3/10/05 16:00:19:134 EST] 46a6641c TransactionMa I org.hibernate.transaction.TransactionManagerLookupFactory instantiating TransactionManagerLookup: org.hibernate.transaction.WebSphereTransactionManagerLookup
[3/10/05 16:00:19:150 EST] 46a6641c TransactionMa I org.hibernate.transaction.TransactionManagerLookupFactory instantiated TransactionManagerLookup
[3/10/05 16:00:19:150 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Automatic flush during beforeCompletion(): enabled
[3/10/05 16:00:19:150 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Automatic session close at end of transaction: disabled
[3/10/05 16:00:19:150 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory JDBC batch size: 15
[3/10/05 16:00:19:150 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory JDBC batch updates for versioned data: disabled
[3/10/05 16:00:19:150 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Scrollable result sets: enabled
[3/10/05 16:00:19:150 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory JDBC3 getGeneratedKeys(): disabled
[3/10/05 16:00:19:150 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Connection release mode: null
[3/10/05 16:00:19:150 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Default batch fetch size: 1
[3/10/05 16:00:19:150 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Generate SQL with comments: disabled
[3/10/05 16:00:19:150 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Order SQL updates by primary key: disabled
[3/10/05 16:00:19:150 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[3/10/05 16:00:19:166 EST] 46a6641c ASTQueryTrans I org.hibernate.hql.ast.ASTQueryTranslatorFactory Using ASTQueryTranslatorFactory
[3/10/05 16:00:19:166 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Query language substitutions: {}
[3/10/05 16:00:19:166 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Second-level cache: enabled
[3/10/05 16:00:19:166 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Query cache: disabled
[3/10/05 16:00:19:166 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Cache provider: org.hibernate.cache.EhCacheProvider
[3/10/05 16:00:19:181 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Optimize cache for minimal puts: disabled
[3/10/05 16:00:19:197 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Structured second-level cache entries: disabled
[3/10/05 16:00:19:228 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Statistics: disabled
[3/10/05 16:00:19:228 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Deleted entity synthetic identifier rollback: disabled
[3/10/05 16:00:19:228 EST] 46a6641c SettingsFacto I org.hibernate.cfg.SettingsFactory Default entity-mode: pojo
[3/10/05 16:00:19:306 EST] 46a6641c SessionFactor I org.hibernate.impl.SessionFactoryImpl building session factory
[3/10/05 16:00:19:322 EST] 46a6641c Configurator W net.sf.ehcache.config.Configurator No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: wsjar:file:/D:/Program Files/WebSphere/AppServer/installedApps/A018426/edoi-8541WIP.ear/APP-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
[3/10/05 16:00:20:228 EST] 46a6641c SessionFactor I org.hibernate.impl.SessionFactoryObjectFactory Factory name: com/mycom/common/HibernateUtil
[3/10/05 16:00:20:228 EST] 46a6641c NamingHelper I org.hibernate.util.NamingHelper JNDI InitialContext properties:{}
[3/10/05 16:00:20:244 EST] 46a6641c SessionFactor I org.hibernate.impl.SessionFactoryObjectFactory Bound factory to JNDI name: com/mycom/common/HibernateUtil
[3/10/05 16:00:20:244 EST] 46a6641c SessionFactor W org.hibernate.impl.SessionFactoryObjectFactory InitialContext did not implement EventContext
[3/10/05 16:00:20:244 EST] 46a6641c WebSphereTran I org.hibernate.transaction.WebSphereTransactionManagerLookup WebSphere 5.1
[3/10/05 16:00:20:244 EST] 46a6641c SessionFactor I org.hibernate.impl.SessionFactoryImpl Checking 0 named queries