0

我得到以下堆栈跟踪

java.lang.UnsupportedClassVersionError: Bad version number in .class file
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:620)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
             org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1634)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:860)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1307)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Server$Connector.<init>(Server.java:137)
Server$Connector.<init>(Server.java:134)
Server.<init>(Server.java:79)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:494)
java.lang.Class.newInstance0(Class.java:350)
java.lang.Class.newInstance(Class.java:303)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:595)

相关线路是

connector = new Connector(); // Server.java line 79 (constructor)
private class Connector { // Server.java line 134
    private List<GameParticipant> activePlayers = new    ArrayList<GameParticipant>();
    private List<GameParticipant> observers = new ArrayList<GameParticipant>();
    private SquareValue nextPlayerToBeAssigned = SquareValue.BLACK; // Server.java line 137

附带说明一下,我在本地机器上编译了所有内容,然后在服务器上复制了 .class 文件。这可能是问题的根源吗?

4

1 回答 1

1
java.lang.UnsupportedClassVersionError: Bad version number in .class file

似乎您的类是用比您的运行时版本更高的版本编译的。如果您使用的是 eclipse,请查看此讨论

于 2012-08-17T05:09:13.480 回答