• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
  • Carey Brown
  • salvin francis
  • Piet Souris

Packaging and Class Loaders

Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

[ January 13, 2008: Message edited by: Alejandro Dominguez ]
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic