Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Packaging and Class Loaders

 
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.
 
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 ]
 
I carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic