无法在Java9项目中处理文件module-info.class导致ClassFormatException

时间:2017-08-21 17:49:35

标签: tomcat tomcat8 java-9 vaadin8 classformatexception

尝试Run Vaadin 8.1 app under Java 9 prerelease in IntelliJ 2017.2.2我能够使用fresh project构建vaadinjavanine.war并使用Jetty Server托管相同的21-Aug-2017 22:53:38.830 SEVERE [localhost-startStop-1] org.apache.catalina.startup.ContextConfig.processAnnotationsFile Unable to process file [/Library/Tomcat/apache-tomcat-8.0.22/webapps/vaadinjavanine/WEB-INF/classes/module-info.class] for annotations org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19 at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:97) at org.apache.tomcat.util.bcel.classfile.ConstantPool.<init>(ConstantPool.java:55) at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:177) at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:85) at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2011) at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:1994) at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:1988) at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1939) at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1897) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1149) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:771) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5066) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1768) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 21-Aug-2017 22:53:38.980 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/vaadinjavanine]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1768) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.UnsupportedClassVersionError: nullpointer/MyUI$MyUIServlet has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0 (unable to load class nullpointer.MyUI$MyUIServlet) at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2476) at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:854) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1274) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157) at org.atmosphere.util.IOUtils.isAtmosphere(IOUtils.java:381) at org.atmosphere.cpr.ContainerInitializer.onStartup(ContainerInitializer.java:58) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5156) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 10 more 21-Aug-2017 22:53:38.981 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive /Library/Tomcat/apache-tomcat-8.0.22/webapps/vaadinjavanine.war java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/vaadinjavanine]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:728) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1768) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

我最终试图将生成的war部署到tomcat服务器。但是,在tomcat服务器启动期间,我遇到以下异常:

module-info.class

异常表示无法处理从module-info.java生成的EL = structure(c(1, 5, 4, 2, 7, 4, 7, 6, 6, 2, 9, 6, 3, 10, 7, 8, 3, 9, 8, 5, 3, 4, 10, 13, 12, 12, 13, 12, 13, 15, 15, 11, 11, 14, 14, 11, 11, 11, 15, 15, 11, 11, 13, 13, 11, 13), .Dim = c(23L, 2L)) g2 = graph_from_edgelist(EL, directed = FALSE) Groups = c(rep(1, 10), 2,2,3,3,3) plot(g2, vertex.color=rainbow(3)[Groups]) GroupByVertex01 = function(Groups, spacing = 5) { Position = (order(Groups) + spacing*Groups) Angle = Position * 2 * pi / max(Position) matrix(c(cos(Angle), sin(Angle)), ncol=2) } GBV1 = GroupByVertex01(Groups) plot(g2, vertex.color=rainbow(3)[Groups], layout=GBV1) 有没有办法解决这个问题?或者这实际上意味着tomcat还没有为java9模块做好准备吗?

注意 :作为Tomcat的新手,我没有自定义任何设置。请告诉我,如果可以分享其他信息以获取更多信息。

1 个答案:

答案 0 :(得分:2)

我不是Tomcat专家,但看起来模块描述符并不是最严重的问题。 nexted异常包含此块:

  

引起:java.lang.UnsupportedClassVersionErrornullpointer/MyUI$MyUIServlet已由更新版本的Java Runtime(类文件版本53.0)编译,此版本的Java Runtime仅识别最高为52.0的类文件版本(无法加载课程nullpointer.MyUI$MyUIServlet

这使得它看起来像是在Java 8(类文件版本52)上运行Tomcat,而您的代码是使用Java 9(类文件版本53)编译的。

确保在Java 9上运行Tomcat。此外,您可能需要尝试{9}},这是Java 9兼容性所必需的。