2 Replies Latest reply on Jun 22, 2007 11:42 AM by Laird Nelson

    Influencing classpath order

    Laird Nelson Apprentice

      I have read the class loading use cases topic, and understand it as well as any mortal can hope to, so please please please please don't refer me there please please.

      For various legacy reasons, I need to make sure that various jars present in jboss-4.0.5/server/myserver/lib are available on the classpath in a certain order. I understand this means effectively that I have to influence the order in which UCLs contribute their jars to the common loader repository.

      So, for example, let's say I have shadow.jar which has a Foo.class in it. I also have base.jar which has a Foo.class in it. I need it to be the case that whenever these two jars appear together in a classpath that the Foo.class from shadow.jar trumps the other one.

      What magic bit of configuration must I change to accomplish this? I had tried to influence this order by using the element in the jboss-service.xml file present in the lib directory. I cannot tell, however, whether this works because (a) that's how you do it or (b) dumb luck.



        • 1. Re: Influencing classpath order
          Laird Nelson Apprentice

          I should have said that I tried to use the (left angle bracket) classpath (right angle bracket) element in jboss-4.0.5/server/myServer/conf/jboss-service.xml. I put in three such elements, like this:

          <classpath codebase="${jboss.server.lib.url:lib}" archives="shadow.jar"/>
          <classpath codebase="${jboss.server.lib.url:lib}" archives="base.jar"/>
          <classpath codebase="${jboss.server.lib.url:lib}" archives="*"/>

          I would think that would make it so that the various JBoss classloaders in effect would get Foo.class from shadow.jar, not base.jar. I have reports from users that this is not consistent across systems, which makes me think that this is not the way to do it.

          Also, in the case of a web application deployed later on, will it--when its loader comes up to this parent in search of Foo.class--will the parent loader in such a case respect this order? The mind-bending diagram in the classloader use cases topic would appear to say yes, this is the case, but that's not the behavior being seen.

          Finally, if in my code I ask a UCL for its URLs, I take it their order is absolutely and entirely insignificant, and that it is actually impossible to tell who will load a given class.

          • 2. Re: Influencing classpath order
            Laird Nelson Apprentice

            Guess I'll go elsewhere for help. Oh well.