1 Reply Latest reply on Aug 17, 2002 11:08 AM by davidjencks

    Classloading of classes without package-names

    sanderbos

      Hi there,

      I am testing against a JBoss 3.0.0, JBoss 3.0.1 and a JBoss head-branch version that I checked out of CVS last Thursday August 8. All on Windows 2000. JBoss 3.0.0 works fine, the other versions have the problem described below.

      The problem I have is related to classloading. I have placed a jar in jboss/server/default/lib. Another jar placed in the same directory instantiates classes from this jar with Class.forName(...) (and this jar is used from an EJB). Most of the classes are loaded just fine, but some of the classes give classnotfound exceptions. It gives the same error for the same classes every time, in the same situation (so the problem is consistent).

      I have narrowed the problem down to the fact that the classes in the jar do not have a package name (it is an obfuscated jar). When I create another obfuscated jar, where each class is prefixed with a dummy packagename, it works fine. I created different obfuscated jars with and without a packagename (the classes are otherwise named randomly), and the behavior is consistent.

      I am not sure the problem is related to JBoss, but I have never seen this before, and the jars work fine when performing the same tasks in a more basic setting.

      My question is this: Does anybody know whether JBoss classloaders treat classes without any package name differently then those with a package-name, since 3.0.1? And if so, what is different?
      It is very strange behavior, since most of the classes load like a charm I would say there is no difference, but the problem goes away when I introduce package names so it really seems to be related to that.

      For what it's worth, here is part of the stacktrace of the classnotfound exception (from the CVS version), but I looked in the sources and all I can see there is that all attempts to load the class have failed, so it does not immediately present the answer.
      java.lang.ClassNotFoundException: XHIVE836
      at org.jboss.mx.loading.UnifiedLoaderRepository2.loadClass(UnifiedLoaderRepository2.java:149)
      at org.jboss.mx.loading.UnifiedClassLoader.loadClass(UnifiedClassLoader.java:283)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClassInternal(Unknown Source)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Unknown Source)
      at com.pm.NonSessionConnection.findClass(NonSessionConnection.java:59)
      ...


      TIA for any pointers,

      --Sander.

        • 1. Re: Classloading of classes without package-names
          davidjencks

          I suspect this is due to the code that locates which classloaders to look for classes in based on the package name. I think this was added between 3.0 and 3.0.1. I don't know much about the issues here but right now I don't consider this a high priority to fix since the idea of classes not in a package ... well... seems odd.

          You could search the bug list and if no one else has reported it file a bug report. If you want to have a look the code is in jmx/src/main/org/jboss/mx/loading in one of the LoaderRepository classes.