小编典典

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

tomcat

尝试在IntelliJ 2017.2.2中的Java9预发行版下运行Vaadin8.1应用程序,我能够vaadinjavanine.war使用一个新项目构建一个,并使用Jetty
Server托管该项目

我最终试图将产生的战争部署到tomcat服务器。但是,在tomcat服务器启动期间,出现以下异常:

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)

异常指出无法处理module-info.class从Java9生成的module-info.java有办法解决吗?
还是这实际上意味着tomcat尚未准备好使用Java9模块?

注意 :作为Tomcat的新手,我尚未自定义任何设置。让我知道,是否可以共享其他信息以获取更多信息。


阅读 1649

收藏
2020-06-16

共1个答案

小编典典

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

产生的原因:java.lang.UnsupportedClassVersionErrornullpointer/MyUI$MyUIServlet已经有最新版本的Java运行时(类文件版本53.0)的编制,这个版本的Java运行时只能识别类文件版本到52.0(无法加载类nullpointer.MyUI$MyUIServlet

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

确保在Java 9上运行Tomcat。此外,您可能想尝试Tomcat9早期访问版本,这是Java9兼容性所必需的。

2020-06-16