1 Reply Latest reply: Oct 24, 2011 11:07 AM by Ales Justin RSS

Class Loading issues in JBoss 5.1.0

aitor moragas Newbie

Hi,

 

I've checked other class loading issues threads in this forum, but no provided solution has worked for me so far. Therefore, I shall post here my problem to check that I am doing things rightly.

 

I have a jboss instance, which is currently shared by numerous applications. I mean, various applications are deployed there, most of which we cannot touch or control.

 

Our application is an EAR which includes two modules: an EJB and a WAR.

 

app.ear

|

|\

|  myEjb.jar

\

  myWar.war

 

myEjb.jar uses a class let's call it myClass.class (inside app.ear/lib) whose name is shared by other applications running in this JBoss instance. Therefore, I thought that a classloading file like

 

<classloading xmlns="urn:jboss:classloading:1.0"

          name="app.ear"

          domain="app.ear:loader=app.ear"

          parent-domain="DefaultDomain"

          export-all="NON_EMPTY"

          import-all="true"

          parent-first="false"/>

 

would be enough to make sure the classes that both the EJB and the WAR use are the ones inside app.ear.

 

I also added two class loading files for the EJB and the WAR. They are like these:

 

<classloading xmlns="urn:jboss:classloading:1.0"

          name="myEjb.ejb"

          domain="myEjb.ejb"

          parent-domain="app.ear:loader=app.ear"

          export-all="NON_EMPTY"

          import-all="true"

          parent-first="false"/>

 

<classloading xmlns="urn:jboss:classloading:1.0"

          name="myWar.war"

          domain="myWar.war"

          parent-domain="app.ear:loader=app.ear"

          export-all="NON_EMPTY"

          import-all="true"

          parent-first="false"/>

 

But this configuration is not guaranteeing that the actual myClass that the EJB is loading is the one inside the app.ear/lib directory.

 

I don't want to set the parent-domain to "ignored" since there are lots of libraries in the common/lib directory that my application needs (spring, hibernate...)

 

Is there something I should do differently?

 

Thx

  • 1. Re: Class Loading issues in JBoss 5.1.0
    Ales Justin Master

    Hmm, that parent-first=false should do the trick.

    Can you debug why it doesn't find your myClass first?

     

    btw: ejb jar already "hangs" off ear classloader, hence no need for a new domain

    and war's parent is also already ear classloader, while parent-first=false is per servlet spec