Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Embedded Jetty with Annotations and Jersey gets IncompatibleClassChangeError

I tried to use the information at http://www.eclipse.org/jetty/documentation/current/using-annotations-embedded.html but on startup I get a bunch of exceptions during annotation processing.

 

2014-01-22 13:53:04.872:WARN:oejut.QueuedThreadPool:qtp1193472379-16:

java.lang.IncompatibleClassChangeError: class org.eclipse.jetty.annotations.AnnotationParser$MyClassVisitor has interface org.objectweb.asm.ClassVisitor as super class

       at java.lang.ClassLoader.defineClass1(Native Method)

       at java.lang.ClassLoader.defineClass(ClassLoader.java:792)

       at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

       at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)

       at java.net.URLClassLoader.access$100(URLClassLoader.java:71)

       at java.net.URLClassLoader$1.run(URLClassLoader.java:361)

       at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

       at java.security.AccessController.doPrivileged(Native Method)

       at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

       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.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:971)

       at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.java:953)

       at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:906)

       at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:828)

       at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:111)

       at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:472)

       at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)

       at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536)

       at java.lang.Thread.run(Thread.java:724)

 

Examining the transitive dependencies I found

 

       asm-all-repackaged-2.2.0-b21.jar

       asm-4.1.jar

       asm-commons-4.1.jar

       asm-tree-4.1.jar

 

with asm-all-repackaged-2.2.0-b21 coming from jersey-container-jetty-servlet.  Examining the sources I find that indeed, org.objectweb.asm.ClassVisitor changed from an interface in 2.2.0 to an abstract class in 4.1.

 

However, I still get the error even after removing asm-all-repackaged-2.2.0-b21.jar from the jetty classpath.

 

Here's the Java embedded launcher code:

 

import org.eclipse.jetty.server.Server;

import org.eclipse.jetty.webapp.Configuration.ClassList;

import org.eclipse.jetty.webapp.WebAppContext;

 

public class JettyLauncher

{

    public static void main(String[] args) throws Exception

    {

        Server server = new Server(8080);

        ClassList classlist = ClassList.setServerDefault(server);

        classlist.addAfter("org.eclipse.jetty.webapp.FragmentConfiguration", "org.eclipse.jetty.plus.webapp.EnvConfiguration", "org.eclipse.jetty.plus.webapp.PlusConfiguration");

        classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");

 

        WebAppContext wac = new WebAppContext("target/server-0.1.0-SNAPSHOT","/test");

        server.setHandler(wac);

        server.start();

        server.join();

    }

}

 

Questions:

 

1) Why didn't removing asm-all-repackaged from the classpath make it work?

2) Is it possible to get Jetty and Jersey to play nice when using annotations?


Back to the top