1

I'm try to run a system my group made using Maven and Eclipse, but when I try to use mvn jetty:run, this error appears:

java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
    at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:52)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:975)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:586)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:349)
    at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:102)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:165)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:162)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:165)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:92)
    at org.eclipse.jetty.server.Server.doStart(Server.java:228)
    at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:69)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:433)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:377)
    at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:546)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
2012-07-10 13:35:25.948:INFO::Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server
[INFO] Starting scanner at interval of 10 seconds.

My teammate's systems can run it fine, and we basically have the same settings, repositories, and we are all using Maven2.

Any ideas as to why the error occurs?

Mickey Espiritu
  • 101
  • 1
  • 4
  • 8
  • It is very useful question for me. The same (exactly the second, first was missing jersey-bundle in .pom file) problem I had had in Eclipse after installation JAX-RS Glassfish library. – hariprasad Aug 05 '15 at 13:16

2 Answers2

1

Well, you appear to be needing the asm library. The java.lang.NoClassDefFoundError means you simply don't have the org.objectweb.asm.ClassVisitor class on your classpath. I don't know which version of the Jetty plugin you're using, (if you'd paste your pom.xml), I could be more precise.

Basically, you need one of these dependencies:

Either add this in your project's <dependencies/>:

 <dependency>
    <groupId>asm</groupId>
    <artifactId>asm</artifactId>
    <version>3.3.1</version>
 </dependency>

Or add this as a <dependency> of your Jetty plugin:

<dependency>
   <groupId>org.mortbay.jetty</groupId>
   <artifactId>jetty-runner</artifactId>
   <version>8.1.0.RC4</version>
</dependency>

(Apparently, this dependency contains the ASM classes).

In the future, in order to resolve noclassdef-s, I'd recommend you look up the dependencies the class is part of via some site like:

carlspring
  • 31,231
  • 29
  • 115
  • 197
  • But this dependency should already be part of the Maven Jetty plugin. This should not be added explicitly to the pom. – Kkkev Jul 10 '12 at 19:07
  • No, this is not exactly true. But I do agree that he should try removing his repository. – carlspring Jul 10 '12 at 19:40
  • The asm dependency is already included in the pom.xml, yet the error still occurs. – Mickey Espiritu Jul 18 '12 at 02:50
  • 1
    It's a problem with the eclipse-jetty-plugin and solved in http://stackoverflow.com/questions/9526604/jetty-8-1-1-v20120215-in-eclipse-with-webapp-jsf-maven – Volker Seibt Nov 06 '13 at 13:45
0

If it works for your colleagues but not for you, then it may be due to a corrupt local repository on your machine. Try renaming or deleting your local repository directory to force Maven to download your plugins and dependencies again.

Kkkev
  • 4,716
  • 5
  • 27
  • 43