JBoss Community

EAR+WAR+EJB ... cannot find resource ... classloader problem on my side?

created by zecas zecas in Beginner's Corner - View the full discussion

I'm having a serious problem putting a project to work. It really is hold back my advance in the project, and I'm getting very frustrated with this.

 

 

Maybe someone can help me here ... I hope so.

 

 

I have the following structure:

 

 

project.ear

+- load-api.jar

+- webapp.war

   +- WEB-INF

      +- classes

               +- config.properties

+- myejb.jar

 

 

 

 

Components:

 

 

load-api.jar - jar package that loads stuff, including "config.properties" from classpath.

Uses something like:

OneClass.class.getClassLoader().getResourceAsStream( "config.properties" );

 

 

webapp.war - simple war module, the only one that depends on "load-api.jar"

Executes a servlet context listener on startup, that will load "config.properties" through "load-api.jar".

 

 

myejb.jar - simple EJB3 project, that has a simple EJB component that does nothing at this time.

 

 

 

 

Now I need to use from within the EJB project a class that is defined on "load-api.jar". What I did was just to add a dependency to "load-api.jar", and nothing more (manifest.mf gets updated with jar info). Before I even add a line of code, my project stops working.

 

 

What happens: the listener executed from within "webapp.war" fails to find the "config.properties" resource.

 

 

The "config.properties" resource is still defined inside the "WEB-INF->classes" folder of the "webapp.war", like before. But seems that the classloader fails to find it, as if it searches for it inside the EJB ...

 

 

I believe this should be normal ... but why is it? Can I change this behaviour? Is it a manifest.mf classpath problem?

 

 

This seems to be a matter of classloading-hell, as I've heard of it. The solution is to pull everything to the EJB? And if it is, will it work the same way in other application server JavaEE compliant?

 

 

 

 

Thanks

Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community