Hi,

I tried to implement service based logging, that means:
Each WebService deployed as an AAR in an Axis2 web application should write its 
own log files.

I put a log4j.jar to the /lib folder of the AAR and a log4j.xml to the root of 
the AAR.
But the lib and the configuration are always loaded from the webapp Axis2, 
i.e. from webapps/axis2/WEB-INF/lib and webapps/axis2/WEB-INF/classes .

I wrote a little test code in the startUp() method of a ServiceLifeCycle 
implementation:

  public void startUp(ConfigurationContext configCtx, AxisService service) {
    DeploymentClassLoader cl = (DeploymentClassLoader)service.getClassLoader();
    try {
      Class c = cl.loadClass("org.apache.log4j.Logger");
      System.out.println("Services ClassLoader: " + cl.toString());
      System.out.println("Loggers ClassLoader: " + 
c.getClassLoader().toString());
    }
    catch(ClassNotFoundException cnfE) {
    }
  }

that prints this to tomcat's stdout:
Services ClassLoader: org.apache.axis2.deployment.deploymentclassloa...@4d76b4
Loggers ClassLoader: WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.standardclassloa...@1fddc31

I think, DeploymentClassLoader does not work in child-first manner,
because it inherits loadClass() from Java's ClassLoader that works parent-first.

Am I right or do I miss something in my test code or in my thoughts?

TIA
Detlef Meier

Reply via email to