1 Reply Latest reply on Oct 25, 2007 6:03 AM by Jeff Yu

    Classloader question

    Jeff Yu Master

      Hi, I've read the JBoss classloader from this wiki http://www.jboss.org/wiki/Wiki.jsp?page=JBossClassLoadingUseCases.

      And I tried to write a simple code to see if it worked as it described.

      Firstly, I've wrote a very simple class, called Util. the code is:

       package com.company.util;
      
      public class Util {
      
       public String getResponse() {
       return "This response is from Application Server's library such as JBoss" ;
       }
      
       public String getRequest() {
       return "doNothing";
       }
      
      }
      


      and package this class as a JAR, called util.jar.

      I've written another class, called Util.

       package com.company.util;
      
      public class Util {
      
       public String getResponse() {
       return "This response is from web app's library" ;
       }
      
      }
      


      and I package this class as util-webapp.jar

      3).
      I wrote a simple class, which call the Util class, as following :
       Util util = new Util();
       System.out.println("Util response is: [" + util.getResponse() + "]");
      


      Belows are some scenarios that I deployed.

      1.
      1) put the util.jar in the JBoss_HOME/lib
      2) put the util-webapp.jar in my war, and I deployed war in the $JBoss_home/server/default/deploy

      Result: I've found that the application uses the war's jar, which is util-webapp.jar.

      2.
      1) put the util.jar in the JBoss_home/lib/endorsed
      2) put the util-webapp.jar in my war, and I deployed war in the $JBoss_home/server/default/deploy

      Result: It uses the util.jar in the endorsed folder.

      3)
      1) put the util.jar in the JBoss_HOME/lib
      2) put the util-webapp.jar in my war.
      3) I package the war in an ear, and then uses the isolated classloader, and "java2ParentDelegation=false",

      Result, it still uses the util-webapp.jar

      I dont know what I am doing wrong here, but it seems it doesn't work as the JBoss configuration wiki said, can someone shed some light on this.

      Thanks in advance
      Jeff