wood burning stoves 2.0
The moose likes BEA/Weblogic and the fly likes EJB JAR resources classloader issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "EJB JAR resources classloader issues" Watch "EJB JAR resources classloader issues" New topic

EJB JAR resources classloader issues

Boris Pophristov

Joined: Jan 13, 2009
Posts: 2

I have a classloader related problem with EJB JAR resources. Here's the situation:

We have several EJB JARs packed in the same EAR. Each EJB JAR contains a single stateless session EJB. The EJBs are looked up by reference from a single web application in the EAR. Each EJB class uses JAR resource files from its EJB JAR file (xml, xslt files). These files are retrieved using getClass().getResourceAsStream(). And here's the problem:

If a JAR resource file with the same name exists in more than one EJB JARS the same file is retrieved no matter from which session EJB class getClass().getResourceAsStream() is called. Here's a more schematic explanation:

- EJB1.class - stateless session EJB;
- resources/config.xml;

- EJB2.class - stateless session EJB;
- resources/config.xml;

Calling getClass().getResource("/resources/config.xml") from EJB1class retrieves: ...EJB1.jar!/resources/config.xml.
Calling getClass().getResource("/resources/config.xml") from EJB2class retrieves again: ...EJB1.jar!/resources/config.xml.

Can this behavior be controlled in any way? If I put each EJB in its own classloader I will not be able to look them up by reference from the web application. Is there another solution?

Thanks in advance.

I agree. Here's the link: http://aspose.com/file-tools
subject: EJB JAR resources classloader issues
It's not a secret anymore!