java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor

Java.net JIRA | gazmoo | 3 years ago
  1. 0

    When embedding Jersey in a standalone Java app, I've specified a set of singleton resources in my ResourceConfig using {noformat} resourceConfig.registerInstances(resources); {noformat} I then publish the resources in Jetty using {noformat} webabbContext.add(new ServletHolder(new ServletContainer(resourceConfig)), pathToJersey); {noformat} I excluded the repackaged ASM jars in my Maven POM because of a conflict with other libraries in the application: {noformat} <exclusion> <groupId>org.glassfish.hk2.external</groupId> <artifactId>asm-all-repackaged</artifactId> </exclusion> {noformat} However, when the servlets are initialised, the following exception is thrown: {noformat} java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor at org.glassfish.jersey.server.ResourceConfig.scanClasses(ResourceConfig.java:875) at org.glassfish.jersey.server.ResourceConfig._getClasses(ResourceConfig.java:840) at org.glassfish.jersey.server.ResourceConfig.getClasses(ResourceConfig.java:755) at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1171) at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1144) at org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1140) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:299) at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:169) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:359) at javax.servlet.GenericServlet.init(GenericServlet.java:244) at com.gaz.test.JerseySpringSingletonBeansServlet.init(JerseySpringSingletonBeansServlet.java:43) at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:542) at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:351) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:800) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:288) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1322) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:731) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:490) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:108) at org.eclipse.jetty.server.Server.start(Server.java:342) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:90) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58) at org.eclipse.jetty.server.Server.doStart(Server.java:290) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69) at Main.start(Main.java:68) at Main.main(Main.java:17) {noformat} There appears to be no easy way to prevent the exception. Debugging the application, I noted that the {{ResourceConfig._getClasses()}} method does not return any classes in my case - it does not attempt to do any scanning, but the ClassVisitor is still instantiated in the AnnotationAcceptingListener constructor, throwing the exception. I've worked around it temporarily by extending the ResourceConfig class and overriding the _getClasses() method to just return an empty set. I had to extend it in the same package, because the method is package private. I could not use the Application class instead of the ResourceConfig class because the ServletContainer only accepts a ResourceConfig. It could be fixed a number of ways: * Allow users to completely disable classpath scanning, and don't attempt to create ASM objects if it's disabled * Make the ResourceConfig more easily extensible for customisation * Hide all implementation details of classpath scanning (move the bundled ASM into a different package to avoid conflicts)

    Java.net JIRA | 3 years ago | gazmoo
    java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
  2. 0

    GitHub comment 4#9069076

    GitHub | 4 years ago | larsschwegmann
    java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    Hello Jersey Team, Some tests are failing on master due to missing asm dependency. I fixed this by modifying this file: {code} containers/jdk-http/pom.xml {code} And adding missing dependency with test cope: {code} <dependencies> <dependency> <groupId>asm</groupId> <artifactId>asm</artifactId> <version>3.3.1</version> <scope>test</scope> </dependency> </dependencies> {code} Now jersey-container-jdk-http module tests are passing. I can push this change to Jersey repository on github if you like. The failure log: {code} [INFO] ------------------------------------------------------------------------ [INFO] Building jersey-container-jdk-http 2.14-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-versions) @ jersey-container-jdk-http --- [INFO] [INFO] --- build-helper-maven-plugin:1.7:parse-version (parse-version) @ jersey-container-jdk-http --- [INFO] [INFO] --- maven-istack-commons-plugin:2.6.1:rs-gen (default) @ jersey-container-jdk-http --- Resources: org/glassfish/jersey/jdkhttp/internal/localization.properties Skipping /home/sarxos/workspace/jersey/containers/jdk-http/src/main/resources/org/glassfish/jersey/jdkhttp/internal/localization.properties [INFO] [INFO] --- build-helper-maven-plugin:1.7:add-source (default) @ jersey-container-jdk-http --- [INFO] Source directory: /home/sarxos/workspace/jersey/containers/jdk-http/target/generated-sources/rsrc-gen added. [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jersey-container-jdk-http --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] Copying 2 resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jersey-container-jdk-http --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 5 source files to /home/sarxos/workspace/jersey/containers/jdk-http/target/classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jersey-container-jdk-http --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /home/sarxos/workspace/jersey/containers/jdk-http/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ jersey-container-jdk-http --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.17:test (default-test) @ jersey-container-jdk-http --- [INFO] Surefire report directory: /home/sarxos/workspace/jersey/containers/jdk-http/target/surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running org.glassfish.jersey.jdkhttp.LifecycleListenerTest Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.364 sec <<< FAILURE! - in org.glassfish.jersey.jdkhttp.LifecycleListenerTest testStartupShutdownHooks(org.glassfish.jersey.jdkhttp.LifecycleListenerTest) Time elapsed: 0.29 sec <<< ERROR! java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor at java.net.URLClassLoader$1.run(URLClassLoader.java:372) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.glassfish.jersey.server.ResourceConfig.scanClasses(ResourceConfig.java:885) at org.glassfish.jersey.server.ResourceConfig._getClasses(ResourceConfig.java:849) at org.glassfish.jersey.server.ResourceConfig.getClasses(ResourceConfig.java:755) at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1181) at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1154) at org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1150) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:318) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:273) at org.glassfish.jersey.jdkhttp.JdkHttpHandlerContainer.<init>(JdkHttpHandlerContainer.java:98) at org.glassfish.jersey.jdkhttp.JdkHttpServerFactory.createHttpServer(JdkHttpServerFactory.java:104) at org.glassfish.jersey.jdkhttp.JdkHttpServerFactory.createHttpServer(JdkHttpServerFactory.java:85) at org.glassfish.jersey.jdkhttp.AbstractJdkHttpServerTester.startServer(AbstractJdkHttpServerTester.java:113) at org.glassfish.jersey.jdkhttp.LifecycleListenerTest.testStartupShutdownHooks(LifecycleListenerTest.java:146) testReload(org.glassfish.jersey.jdkhttp.LifecycleListenerTest) Time elapsed: 0.016 sec <<< ERROR! java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor at java.net.URLClassLoader$1.run(URLClassLoader.java:372) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.glassfish.jersey.server.ResourceConfig.scanClasses(ResourceConfig.java:885) at org.glassfish.jersey.server.ResourceConfig._getClasses(ResourceConfig.java:849) at org.glassfish.jersey.server.ResourceConfig.getClasses(ResourceConfig.java:755) at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1181) at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1154) at org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1150) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:318) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:273) at org.glassfish.jersey.jdkhttp.JdkHttpHandlerContainer.<init>(JdkHttpHandlerContainer.java:98) at org.glassfish.jersey.jdkhttp.JdkHttpServerFactory.createHttpServer(JdkHttpServerFactory.java:104) at org.glassfish.jersey.jdkhttp.JdkHttpServerFactory.createHttpServer(JdkHttpServerFactory.java:85) at org.glassfish.jersey.jdkhttp.AbstractJdkHttpServerTester.startServer(AbstractJdkHttpServerTester.java:113) at org.glassfish.jersey.jdkhttp.LifecycleListenerTest.testReload(LifecycleListenerTest.java:111) Running org.glassfish.jersey.jdkhttp.JdkHttpPackageTest Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.02 sec <<< FAILURE! - in org.glassfish.jersey.jdkhttp.JdkHttpPackageTest testJdkHttpPackage(org.glassfish.jersey.jdkhttp.JdkHttpPackageTest) Time elapsed: 0.02 sec <<< ERROR! java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor at java.net.URLClassLoader$1.run(URLClassLoader.java:372) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.glassfish.jersey.server.ResourceConfig.scanClasses(ResourceConfig.java:885) at org.glassfish.jersey.server.ResourceConfig._getClasses(ResourceConfig.java:849) at org.glassfish.jersey.server.ResourceConfig.getClasses(ResourceConfig.java:755) at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1181) at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1154) at org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1150) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:318) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:273) at org.glassfish.jersey.jdkhttp.JdkHttpHandlerContainer.<init>(JdkHttpHandlerContainer.java:98) at org.glassfish.jersey.jdkhttp.JdkHttpServerFactory.createHttpServer(JdkHttpServerFactory.java:104) at org.glassfish.jersey.jdkhttp.JdkHttpServerFactory.createHttpServer(JdkHttpServerFactory.java:85) at org.glassfish.jersey.jdkhttp.AbstractJdkHttpServerTester.startServer(AbstractJdkHttpServerTester.java:113) at org.glassfish.jersey.jdkhttp.JdkHttpPackageTest.testJdkHttpPackage(JdkHttpPackageTest.java:79) Running org.glassfish.jersey.jdkhttp.RuntimeDelegateTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.34 sec - in org.glassfish.jersey.jdkhttp.RuntimeDelegateTest Running org.glassfish.jersey.jdkhttp.BasicJdkHttpServerTest Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.023 sec <<< FAILURE! - in org.glassfish.jersey.jdkhttp.BasicJdkHttpServerTest testCreateHttpsServer(org.glassfish.jersey.jdkhttp.BasicJdkHttpServerTest) Time elapsed: 0.014 sec <<< ERROR! java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor at java.net.URLClassLoader$1.run(URLClassLoader.java:372) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.glassfish.jersey.server.ResourceConfig.scanClasses(ResourceConfig.java:885) at org.glassfish.jersey.server.ResourceConfig._getClasses(ResourceConfig.java:849) at org.glassfish.jersey.server.ResourceConfig.getClasses(ResourceConfig.java:755) at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1181) at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1154) at org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1150) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:318) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:273) at org.glassfish.jersey.jdkhttp.JdkHttpHandlerContainer.<init>(JdkHttpHandlerContainer.java:98) at org.glassfish.jersey.jdkhttp.JdkHttpServerFactory.createHttpServer(JdkHttpServerFactory.java:104) at org.glassfish.jersey.jdkhttp.JdkHttpServerFactory.createHttpServer(JdkHttpServerFactory.java:85) at org.glassfish.jersey.jdkhttp.BasicJdkHttpServerTest.testCreateHttpsServer(BasicJdkHttpServerTest.java:87) testCreateHttpServer(org.glassfish.jersey.jdkhttp.BasicJdkHttpServerTest) Time elapsed: 0.008 sec <<< ERROR! java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor at java.net.URLClassLoader$1.run(URLClassLoader.java:372) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.glassfish.jersey.server.ResourceConfig.scanClasses(ResourceConfig.java:885) at org.glassfish.jersey.server.ResourceConfig._getClasses(ResourceConfig.java:849) at org.glassfish.jersey.server.ResourceConfig.getClasses(ResourceConfig.java:755) at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1181) at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1154) at org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1150) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:318) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:273) at org.glassfish.jersey.jdkhttp.JdkHttpHandlerContainer.<init>(JdkHttpHandlerContainer.java:98) at org.glassfish.jersey.jdkhttp.JdkHttpServerFactory.createHttpServer(JdkHttpServerFactory.java:104) at org.glassfish.jersey.jdkhttp.JdkHttpServerFactory.createHttpServer(JdkHttpServerFactory.java:85) at org.glassfish.jersey.jdkhttp.BasicJdkHttpServerTest.testCreateHttpServer(BasicJdkHttpServerTest.java:78) Results : Tests in error: LifecycleListenerTest.testStartupShutdownHooks:146->AbstractJdkHttpServerTester.startServer:113 » NoClassDefFound LifecycleListenerTest.testReload:111->AbstractJdkHttpServerTester.startServer:113 » NoClassDefFound JdkHttpPackageTest.testJdkHttpPackage:79->AbstractJdkHttpServerTester.startServer:113 » NoClassDefFound BasicJdkHttpServerTest.testCreateHttpsServer:87 » NoClassDefFound org/objectwe... BasicJdkHttpServerTest.testCreateHttpServer:78 » NoClassDefFound org/objectweb... Tests run: 6, Failures: 0, Errors: 5, Skipped: 0 {code}

    Java.net JIRA | 2 years ago | sarxos
    java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
  5. 0

    install Groovy in RedHat as4 | 飛奔嘅蝸牛

    strongd.net | 12 months ago
    java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NoClassDefFoundError

      org/objectweb/asm/ClassVisitor

      at org.glassfish.jersey.server.ResourceConfig.scanClasses()
    2. jersey-core-server
      ApplicationHandler.<init>
      1. org.glassfish.jersey.server.ResourceConfig.scanClasses(ResourceConfig.java:875)
      2. org.glassfish.jersey.server.ResourceConfig._getClasses(ResourceConfig.java:840)
      3. org.glassfish.jersey.server.ResourceConfig.getClasses(ResourceConfig.java:755)
      4. org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1171)
      5. org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1144)
      6. org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1140)
      7. org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:299)
      7 frames
    3. jersey-container-servlet-core
      ServletContainer.init
      1. org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
      2. org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:169)
      3. org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:359)
      3 frames
    4. JavaServlet
      GenericServlet.init
      1. javax.servlet.GenericServlet.init(GenericServlet.java:244)
      1 frame
    5. com.gaz.test
      JerseySpringSingletonBeansServlet.init
      1. com.gaz.test.JerseySpringSingletonBeansServlet.init(JerseySpringSingletonBeansServlet.java:43)
      1 frame
    6. Jetty
      AbstractLifeCycle.start
      1. org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:542)
      2. org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:351)
      3. org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:800)
      4. org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:288)
      5. org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1322)
      6. org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:731)
      7. org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:490)
      8. org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
      9. org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:108)
      10. org.eclipse.jetty.server.Server.start(Server.java:342)
      11. org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:90)
      12. org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
      13. org.eclipse.jetty.server.Server.doStart(Server.java:290)
      14. org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
      14 frames
    7. Unknown
      Main.main
      1. Main.start(Main.java:68)
      2. Main.main(Main.java:17)
      2 frames