Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Packaging and Class Loaders  RSS feed

 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web application that references ejbs in an ear file. When a change to an ejb is made and the ear is redeployed, my web application gets a ClassCastException when it performs a lookup on an ejb home. If I redeploy the same exact war file after redeploying the ear file, then everything works. I don't understand exactly what class loading is going on that would cause the same war file to succeed or fail depending on whether it was deployed before or after the changes to the ear file were made. My war file only contains the home and remote interfaces of the ejb. I am using JBoss and so I do not have to put the stubs in the ejb client jar because JBoss dynamically generates them at runtime. Also, the war file and ear file are collocated on the same machine and the same application server.
What should I do to make it so that I don't have to redeploy my unchanged war file after changes to the ejbs have been made? Thanks a lot.
 
Alejandro Dominguez
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for bringing back a dead horse, but I'm facing the same exact problem; I'm using JBoss 4.2.2GA on Mac OS 10.4.

Does anybody know of a workaround? I would like to have my EJBs deployed separately from my webapps so as to have a shared common "core".

I see that JBoss states:

I get ClassCastException

There are some places where it reports this when it really means ClassNotFoundException, e.g. the CORBA PortableRemoteObject.narrow()

Assuming it is the same class name, this problem relates to classes getting loaded from different classloaders. At compile time your class has only one identity, its name. If you "deploy" a class many times in different jars, it has multiple identities. They are not the same. See below for more information on the solutions to this problem.

This can also be caused by you only redeploying part of your application. e.g. a webapp uses an EJB and you only redeploy the EJB. The webapp will still have the old versions of the classes.


... but for many users I don't think redeploying everything is really an option...

Any ideas?

Regards
[ January 13, 2008: Message edited by: Alejandro Dominguez ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!