Fix Jetty 9.1 for JDK8 annotations
I discovered this problem and solution while trying to run an app built using Spring 4.0 GA and JDK8b120 and deploying within Jetty. Spring Web MVC makes heavy use of the newly added Java 8 annotations on types which causes a problem with the version of ASM bundled in Jetty.
Jetty 9.1.0 comes bundled with ASM 4.1 but running with bytecode level 1.8 and annotations causes the following error:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| java.lang.RuntimeException: Error scanning file PingController.class | |
| at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:705) | |
| at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:686) | |
| at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:686) | |
| at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:686) | |
| at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:686) | |
| at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:821) | |
| 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:744) | |
| Caused by: | |
| java.lang.IllegalArgumentException | |
| at org.objectweb.asm.ClassReader.<init>(Unknown Source) | |
| at org.objectweb.asm.ClassReader.<init>(Unknown Source) | |
| at org.objectweb.asm.ClassReader.<init>(Unknown Source) | |
| at org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:970) | |
| at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:700) | |
| at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:686) | |
| at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:686) | |
| at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:686) | |
| at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:686) | |
| at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:821) | |
| 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:744) |
The fix is pretty simple. Download ASM 5.0 or greater and replace TWO(2) files within the Jetty installation.
Replace: jetty-distribution-9.1.0.v20131115/lib/annotations/(asm-4.1.jar|asm-commons-4.1.jar) with asm-5.0_BETA/(asm-5.0_BETA.jar|asm-commons-5.0_BETA.jar)
Leave a Comment