gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 21:57:46 25 4
gpt4 key购买 nike

尝试 Run Vaadin 8.1 app under Java 9 prerelease in IntelliJ 2017.2.2我能够使用 fresh project 构建一个 vaadinjavanine.war并使用 Jetty Server 托管相同的内容。

我最终尝试将生成的 war 部署到 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 的新手,我没有自定义任何设置。如果可以分享其他信息以获取更多信息,请告诉我。

最佳答案

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

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)

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

确保在 Java 9 上运行 Tomcat。此外,您可能想尝试 early access build of Tomcat 9 ,这是 Java 9 兼容性所必需的。

关于tomcat - 无法在 Java9 项目中处理文件 module-info.class 导致 ClassFormatException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45802981/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com