wood burning stoves 2.0*
The moose likes JBoss/WildFly and the fly likes classloader question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "classloader question" Watch "classloader question" New topic
Author

classloader question

Tim Brizard
Greenhorn

Joined: May 14, 2004
Posts: 4
Hi all,

I have one .ear file which contains a straight-forward Stateless Session Bean. I have a second .ear file that contains some JSP files. I have a ServiceLocator class(in 2nd .ear file) that is called by the JSP files in the 2nd .ear file which has the following code:



However, the call to the PortableRemoteObject.narrow method throws a
java.lang.ClassCastException. I've been reading many posts that explain the way the JBOSS classloaders work and how that it basically creates a "flat" classloader repository. I've also read that a class definition is only loaded once and the first classloader to load it wins. So, in my case I think the first .ear file, the one with the EJB and binding the object to JNDI has one classloader. The ServiceLocator is using a different classloader, which is causing this exception to occur.

So, my question is how can I get the ServiceLocator to use the same classloader that was used by the 1st .ear with the EJB?

thanks in advance

Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 363
Assumming you are using 4.0.1 you should make the container J2EE compliant. It does not come that way initially but there are steps to make it compliant (4 in all). I believe 4.0 did come that way but cannot be sure. It's a real pain in the a$$ though.

I think it is always better to know exactly what you are getting and only a compliant container can give you that with regards to classloading.

If you insist on using the ULC then in theory you can put the thing anywhere and it should be visible....


No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: classloader question
 
Similar Threads
Initial Context Factory
ServiceLocator - issue when shared between two web app.
ClassCast Exception on EJB remote object lookup
Caching remote ejbobject
Service Locator