Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB JAR resources classloader issues  RSS feed

Boris Pophristov
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!