Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-3099

Util.loadClass() still swallows NoClassDefFoundError

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Done
    • Major
    • 9.0.0.CR4, 8.2.7.Final
    • 5.2.5.Final
    • Core
    • None

    Description

      My log contains stack traces like the following:

      Caused by: org.infinispan.CacheConfigurationException: Unable to instantiate class org.infinispan.loaders.bdbje.BdbjeCacheStore
      	at org.infinispan.util.Util.loadClass(Util.java:101)
      	at org.infinispan.util.Util.getInstance(Util.java:222)
      	at org.infinispan.configuration.parsing.Parser51.parseLoader(Parser51.java:440)
      	at org.infinispan.configuration.parsing.Parser51.parseLoaders(Parser51.java:418)
      	at org.infinispan.configuration.parsing.Parser51.parseCache(Parser51.java:189)
      	at org.infinispan.configuration.parsing.Parser51.parseNamedCache(Parser51.java:148)
      	at org.infinispan.configuration.parsing.Parser51.readElement(Parser51.java:115)
      	at org.infinispan.configuration.parsing.Parser51.readElement(Parser51.java:84)
      	at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
      	at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69)
      	at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:77)
      	... 73 more
      Caused by: java.lang.ClassNotFoundException: org.infinispan.loaders.bdbje.BdbjeCacheStore
      	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      	at java.lang.Class.forName0(Native Method)
      	at java.lang.Class.forName(Class.java:249)
      	at org.infinispan.util.Util.loadClassStrict(Util.java:138)
      	at org.infinispan.util.Util.loadClass(Util.java:99)
      	... 83 more
      

      However, this ClassNotFoundException comes from the System classloader, but the code still swallows the following Error:

      Caused by: org.infinispan.CacheConfigurationException: Unable to instantiate class org.infinispan.loaders.bdbje.BdbjeCacheStore
      	at org.infinispan.util.Util.loadClass(Util.java:101)
      [SNIP - see above]
      	at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:77)
      	... 73 more
      Caused by: java.lang.ClassNotFoundException: org.infinispan.loaders.bdbje.BdbjeCacheStore
      	at org.infinispan.util.Util.loadClassStrict(Util.java:150)
      	at org.infinispan.util.Util.loadClass(Util.java:99)
      	... 83 more
      Caused by: java.lang.NoClassDefFoundError: com/sleepycat/collections/TransactionWorker
      	at java.lang.Class.forName0(Native Method)
      	at java.lang.Class.forName(Class.java:249)
      	at org.infinispan.util.Util.loadClassStrict(Util.java:138)
      	... 84 more
      Caused by: java.lang.ClassNotFoundException: com.sleepycat.collections.TransactionWorker from BaseClassLoader@3598d24f{vfsfile:/D:/App/Java/jboss/brms-standalone-5.3.0/jboss-as/server/lettergen-ds-default/deploy/modeshape-datastore.ear/}
      	at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:477)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      	... 87 more
      

      It is this error which is actually important: the BdbjeCacheStore class was found but it cannot be loaded because the sleepycat jar is not on the classpath. It is impossible to see this without changing the code.

      The commits for ISPN-2559 did not properly fix this problem. The Error should be logged in all cases because the ClassNotFoundException will also happen in almost every case: the last search ClassLoader is the System ClassLoader which will likely never have the searched class.

      Once again: please log all NoClassDefFoundErrors (suppressing Errors is bad in any case) or at least handle them before handling any ClassNotFoundExceptions. The attached patch does exactly that.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              albertdev Bert Jacobs (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: