-->
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.  [ 7 posts ] 
Author Message
 Post subject: NullPointerException on transaction.commit()
PostPosted: Tue Apr 17, 2007 11:35 am 
Newbie

Joined: Tue Apr 17, 2007 11:25 am
Posts: 4
I'm testing my error-handling code.

When I purposely submit bad data, "transaction.commit()" throws "org.hibernate.exception.genericJDBCException". This is expected.
I re-submit the bad data. This time, NPE is thrown.
I re-submit the bad data. genericJDBCException is thrown.
I re-submit the bad data. NPE is thrown.
etc... as I repeatedly re-submit the bad data, the exception thrown alternates between genericJDBCException and NPE.

It seems obvious that something is not being properly re-set following each genericJDBCException occurrence, but what?

Psuedo-code:
try
{
Session s = factory.getSession();
s.clear();
Transaction tx = s.beginTransaction();
s.save(myObject);
tx.commit();
}
catch (Exception e)
{
e.printStackTrace();
tx.rollback();
}
finally
{
s.close();
}


The NPE stack trace:
java.lang.NullPointerException
[4/17/07 10:27:53:119 EDT] 41324132 SystemErr R at java.lang.Throwable.<init>(Throwable.java:52)
[4/17/07 10:27:53:119 EDT] 41324132 SystemErr R at java.lang.Throwable.<init>(Throwable.java:66)
[4/17/07 10:27:53:119 EDT] 41324132 SystemErr R at java.lang.NullPointerException.<init>(NullPointerException.java:63)
[4/17/07 10:27:53:119 EDT] 41324132 SystemErr R at oracle.jdbc.dbaccess.DBData.clearItem(DBData.java:431)
[4/17/07 10:27:53:119 EDT] 41324132 SystemErr R at oracle.jdbc.dbaccess.DBDataSetImpl.clearItem(DBDataSetImpl.java:3528)
[4/17/07 10:27:53:119 EDT] 41324132 SystemErr R at oracle.jdbc.driver.OraclePreparedStatement.clearParameters(OraclePreparedStatement.java:3401)
[4/17/07 10:27:53:119 EDT] 41324132 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.resetStatement(WSJdbcConnection.java:1710)
[4/17/07 10:27:53:119 EDT] 41324132 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1405)
[4/17/07 10:27:53:119 EDT] 41324132 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1368)
[4/17/07 10:27:53:119 EDT] 41324132 SystemErr R at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:396)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:76)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:69)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:150)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1839)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2200)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:46)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
[4/17/07 10:27:53:135 EDT] 41324132 SystemErr R at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)



Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 1:58 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Once you get an error when doing a commit, the Hibernate session is no longer in a usable state. It must be closed and another session opened.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 2:17 pm 
Newbie

Joined: Tue Apr 17, 2007 11:25 am
Posts: 4
The session is being closed, then another is opened. I have traced the code and am 100% sure this is the case.

I've also double-checked the object being used in the "save" command. All variables are populated properly, so it's not caused by supplying a null value for a NOT NULL column.

Finally, I've eyeballed both the transaction and session objects. There are hundreds of variables and I haven't checked every one, but there appears to be no difference when the NPE is thrown.

Any other ideas? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 2:34 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Which dialect are you using and which version of Oracle?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 3:12 pm 
Newbie

Joined: Tue Apr 17, 2007 11:25 am
Posts: 4
org.hibernate.dialect.OracleDialect

Oracle 9.2.0.6


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 3:28 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Aha. Try the org.hibernate.dialect.Oracle9Dialect.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 3:56 pm 
Newbie

Joined: Tue Apr 17, 2007 11:25 am
Posts: 4
Still no joy. Thanks for pointing out the dialect difference, though. Credit granted.

I'm going to try upgrading the Hibernate version. I don't know what version is currently installed, but know it's from mid to late 2006. Thanks.


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