Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.ClassCastException:

 
shradha sharma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My servlet program code

Context ctx = null;
ctx = new ContextLoader().getContext();
UserTransaction utx = (UserTransaction)ctx.lookup("java:comp/UserTransaction");

throws the below exception

java.lang.ClassCastException: org.jboss.tm.usertx.client.ServerVMClientUserTransaction

am using jboss 4.0.4

any idea ???
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure what a ContextLoader is. Usually you do the lookup as follows:



Try it out. Let us know if it does not fix the issue.
 
shradha sharma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tried with your suggestion also. I still face the same exception.

Is there any change required in the Jboss server properties ?
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the entire exception stacktrace that you are seeing.
 
shradha sharma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
was able to find out the reason..
my lib included both servlet.jar and javax.servlet.jar...so was throwing the error.....

thnks for the help yaar..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic