Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

UserTransaction question  RSS feed

 
Joe Joseph
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for asking this relatively dumb question, the answer for which i could have figured out myself. MY RAD has crashed & hence i am unable to test.

What would happen if i do the below in a BMT:
UserTransaction objUserTansaction = null;
objUserTansaction.commit();

In this case will i get a NullPointerException or an IllegalStateException???
I was expecting a NullPointerException.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36462
460
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe,
You'll definitely get a null pointer. This is due to Java. Since commit is not a static method, it gets called on the object. Which is null.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!