7 Replies Latest reply on Dec 2, 2004 7:41 PM by Richard Berger

    JBoss system classpath

    Rahul Jain Newbie

      Hi All,

      How can one place an exploded directory of classes on the JBoss system classpath. Obviously, I tried adding that directory to the
      %JBOSS_CLASSPATH% in the run.bat used to start jboss. But that does not help because Jboss starts giving out weird errors while deploying my application jars and other modules.

      Also, where should I place the exploded class folder and how would I add it to the system classpath?

      Plz help.



        • 1. Re: JBoss system classpath
          Mike Finn Apprentice

          Is there a particular reason you need it in the system classpath? You can add to server classpath by adding it in conf/jboss-service.xml.

          Say you add a directory, called 'local-lib' in you server config dir (same level as conf and lib), and your jar is exploded in a dir called foo.jar. You can add an entry like the following:

          <classpath codebase="local-lib/foo.jar" archives="*"/>


          • 2. Re: JBoss system classpath
            Rahul Jain Newbie

            Hi Mike,

            The issue is that I auto-generate some java code on the fly, compile that code and try to load those classes at runtime and this is when I get in issues. The classloader is not able to find the classes and hence is not able to load them.

            Below is a detailed description of the setup on my JBoss server:
            The application is deployed in JBoss in an exploded ear format. So under my JBoss server you would see this (remember that all the .*ar are folder names and not real archives):

            <Jboss config>\deploy\myApp.ear

            The myApp.ear itself has a META-INF, web.war and serverCode.jar

            Now what happens at runtime is that inside the serverCode.jar folder I generate some java code on-the-fly, compile the code and then try to load it. But as I told u before this loading fails. On of the issues is that the classloader used is the system classloader and hence I wanted to put this auto-generated classes on the system classpath (which I assume is the one specified in the run.bat that comes with JBoss).

            The solution you suggested would not work for me because the code would not be generated at runtime in the local-lib folder but inside my serverCode.jar folder.



            • 3. Re: JBoss system classpath
              Mike Finn Apprentice

              Ahhh, I misunderstood. Sorry.

              Have you tried using a URLClassLoader (instantiate it, pointing the URL at your JAR file). Not really sure here, as you may run into problems (ie ClassCastException), esp. if you are serializing/deserializing instances from classes loaded from different classloader instances.


              • 4. Re: JBoss system classpath
                Rahul Jain Newbie

                Hi Mike,

                The thing is that I would like to not make any major changes to the source code. I had the app deployed on weblogic and was porting it to JBoss and so having any app server-specific code in our application source would break its portability between servers. Hence, I was trying to put the generated classes on the system classpath or atleast as you suggested on the server classpath.

                I even tried adding this in the jboss-service.xml :

                Doesn't help either.



                • 5. Re: JBoss system classpath
                  Rahul Jain Newbie


                  the code text didn't get thru. Here it is again:

                  <classpath codebase="deploy/myApp.ear" archives="serverCode.jar"/>

                  • 6. Re: JBoss system classpath
                    Rahul Jain Newbie


                    I turned logging on for class loading in JBoss by adding entries in the log4j.xml. And it seems to me by looking at the class loader logs that the JBoss unified class loader seems to build a map from package names to the ClassLoader used to load the package. So in case of dynamically generated packages, the packages would not have existed at JBoss startup and so it doesn't recognize the packages and fails to find the classes under those packages.

                    Does anybody know how to load classes generated at run-time in JBoss?



                    • 7. Re: JBoss system classpath
                      Richard Berger Newbie

                      I am having the same problem. In Weblogic I was able to use the APP-INF directory to hold jars that were needed by the code I was generating at runtime. But I don't know how to do this in JBoss. Did you eventually solve the problem?