• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB JAR resources classloader issues

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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.jar:
- EJB1.class - stateless session EJB;
- resources/config.xml;

EJB2.jar:
- 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.

JBoris
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic