Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-5328

NoClassDefFound not wrapped in the ClassScanner

    XMLWordPrintableJSON

    Details

      Description

      Unfortunately only ClassNotFoundException is wrapped in https://github.com/apache/felix/blob/trunk/tools/org.apache.felix.scr.generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java#L148. Every other exception is not wrapped at all, making it very hard to figure out where an issue happened.

      An example stack trace of an error might look likes this

      [ERROR] Bundle <some bundle : Got unexpected exception while analyzing:java.lang.NoClassDefFoundError: javax/servlet/jsp/el/VariableResolver
      	at java.lang.ClassLoader.defineClass1(Native Method)
      	at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
      	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
      	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
      	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
      	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      	at org.apache.felix.scrplugin.helper.ClassScanner.scanSources(ClassScanner.java:144)
      	at org.apache.felix.scrplugin.SCRDescriptorGenerator.execute(SCRDescriptorGenerator.java:146)
      	at org.apache.felix.scrplugin.bnd.SCRDescriptorBndPlugin.analyzeJar(SCRDescriptorBndPlugin.java:178)
      	at aQute.bnd.osgi.Analyzer.doPlugins(Analyzer.java:656)
      	at aQute.bnd.osgi.Analyzer.analyze(Analyzer.java:209)
      	at aQute.bnd.osgi.Builder.analyze(Builder.java:385)
      	at aQute.bnd.osgi.Analyzer.calcManifest(Analyzer.java:687)
      	at aQute.bnd.osgi.Builder.build(Builder.java:105)
      	at org.apache.felix.bundleplugin.BundlePlugin.buildOSGiBundle(BundlePlugin.java:972)
      	at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:470)
      	at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:387)
      	at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:378)
      	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
      	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
      	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
      	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
      	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
      	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
      	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
      	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
      	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
      	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
      	at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
      Caused by: java.lang.ClassNotFoundException: javax.servlet.jsp.el.VariableResolver
      	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      

      I would suggest to not only catch ClassNotFoundException in the ClassScanner but basically all Throwable's

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cziegeler Carsten Ziegeler
                Reporter:
                kwin Konrad Windszus
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: