2 Replies Latest reply on May 26, 2004 10:54 AM by sporritt

    Classpath problem with JBoss 3.2.3

    sporritt Newbie

      Hi,

      I have an app that works fine in JBoss 3.2.1 with Tomcat. It uses a log4j appender that I wrote myself; this is packaged in a jar file in the lib directory of the server instance that I use. This is the relevant part of the log when JBoss is started:

      15:26:30,703 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/conf/jboss-service.xml
      15:26:32,609 INFO [Log4jService] Creating
      15:26:32,703 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:log4j.xml
      15:26:32,984 INFO [Log4jService] Created

      But in 3.2.3, with exactly the same setup, this is what I'm getting:

      15:28:02,171 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss-3.2.3/server/default/conf/jboss-service.xml
      15:28:03,593 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:log4j.xml
      log4j:ERROR Could not create an Appender. Reported error follows.
      java.lang.ClassNotFoundException: mp.sql.MyJDBCAppender
      at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:141)
      at org.apache.log4j.helpers.Loader.loadClass(Loader.java:160)

      I have tried putting the jar containing the JDBC appender in the main lib directory of JBoss (yes I know this is bad form, but if it can't find it there, where can it find it!), but it still doesn't work.

      Anyone have any ideas?

      Thanks

      Simon


        • 1. Re: Classpath problem with JBoss 3.2.3
          Steve Lewis Expert

          I'm not sure what the official answer is, but in the past we've had to add classes12.jar/zip to the run.sh script so that it's on the system classpath.

          • 2. Re: Classpath problem with JBoss 3.2.3
            sporritt Newbie

            Hi, thanks for the reply - I got it to work by doing that. It's a very strange problem though - my appender class ultimately extends org.apache.lo4j.AppenderSkeleton, which is found in the file log4j-boot.jar, contained in the main lib directory of JBoss. But after I added my jar file to the classpath, JBoss then complained about not being able to find AppenderSkeleton:

            15:49:33,906 WARN [ServiceController] Problem creating service jboss.system:type=Log4jService,service=Logging
            java.lang.NoClassDefFoundError: org/apache/log4j/AppenderSkeleton

            Yet it's in a jar file in the main lib directory, and - even weirder - travelling up the stack trace you find this:

            at java.lang.Class.forName(Class.java:141)
            at org.apache.log4j.helpers.Loader.loadClass(Loader.java:160)
            at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:164)

            What's that class there? org.apache.log4j.helpers.Loader?? But isn't that in the same jar file as the class it's trying to load??!

            So I ended up having to add log4j-boot.jar to the classpath in run.bat! It works but something is not right.

            Simon