嵌入式 Jetty 中的 Wicket 应用程序导致 UnsupportedClassVersionError
我尝试使用以下代码在嵌入式 Jetty 中运行 Wicket 应用程序:
public static void main( String[] args ){
Server server = new Server(8080);
Context root = new Context( server, "/", Context.SESSIONS );
FilterHolder filterHolder = new FilterHolder( new WicketFilter() );
filterHolder.setInitParameter("applicationClassName", cz.dw.test.WicketApplication.class.getName() );
root.addFilter( filterHolder, "/*" , Handler.ALL );
try {
server.start();
} catch (Exception ex) {
ex.printStackTrace();
}
}
但我收到 java.lang.UnsupportedClassVersionError: Bad version number in .class file
。
切换我的应用程序的目标类版本(1.6 -> 1.5)没有帮助。
我使用Sun JDK 1.6.0_17、Wicket 1.4.8、Jetty 6.1.24。
当我正常运行应用程序(部署到 Jetty 或 mvn jetty:run
)时,它工作正常。
我尝试调试,但 JRE 类没有调试数据。堆栈跟踪没有任何用处,因为它是在将类加载到 JVM 时发生的。
有什么想法可能是错的吗? 我怎样才能找到哪个类导致了这个问题?
谢谢, 翁德拉
I've tried to run a Wicket app in an embedded Jetty, using this code:
public static void main( String[] args ){
Server server = new Server(8080);
Context root = new Context( server, "/", Context.SESSIONS );
FilterHolder filterHolder = new FilterHolder( new WicketFilter() );
filterHolder.setInitParameter("applicationClassName", cz.dw.test.WicketApplication.class.getName() );
root.addFilter( filterHolder, "/*" , Handler.ALL );
try {
server.start();
} catch (Exception ex) {
ex.printStackTrace();
}
}
But I got java.lang.UnsupportedClassVersionError: Bad version number in .class file
.
Switching the target class version for my app (1.6 -> 1.5) did not help.
I use Sun JDK 1.6.0_17, Wicket 1.4.8, Jetty 6.1.24.
When I run the app normally (deploy to Jetty or mvn jetty:run
), it works fine.
I tried to debug, but the JRE classes have no debug data. The stacktrace is of no use as it happens when loading the classes into JVM.
Any ideas what could be wrong?
How can I find which class is causing this?
Thanks,
Ondra
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
离开 IDE 后,我发现在
pom.xml
中版本仍然是 1.6 - 所以 IDE 没有改变它;不过,我想知道为什么当我积极使用 JDK 1.6 时会发生这种情况。也许 Jetty 插件改变了类加载配置?更新:所以问题出在 NetBeans、Maven 和 Maven 的 exec 插件之间。不知何故,exec 插件进入了一个
java
环境,该环境被解析为/usr/bin/java
,即 Sun JDK 1.5.0。我将此作为 NetBeans 错误报告。
http://netbeans.org/bugzilla/show_bug.cgi?id=185547
After leaving the IDE, I found out that in
pom.xml
the version was still 1.6 - so the IDE did not change it; Still, I wonder why this was happening when I positively used JDK 1.6. Perhaps the Jetty plugin changes classloading configuration?Update: So the problem is somewhere between NetBeans, Maven and Maven's exec plugin. Somehow the exec plugin gets to an environment which's
java
is resolved as/usr/bin/java
, which was Sun JDK 1.5.0.I am reporting this as a NetBeans bug.
http://netbeans.org/bugzilla/show_bug.cgi?id=185547