英文:
Tomcat 9 NoSuchFileException in WEB-INF/lib but the file is present
问题
我正在运行Tomcat 9,Java 11,并部署了一个Spring Boot应用程序。
该应用程序已成功部署,但我收到了404响应。查看Tomcat日志,它说找不到一个JAR文件,但如果我定位到WEB-INF/lib
目录下的文件spring-messaging-5.3.29.jar
,实际上是存在的。
那么可能的原因是什么?
编辑:如果我重新部署应用程序,会出现另一个JAR文件spring-boot-starter-data-jpa-2.7.14.jar
。我猜,总体上出现了一些问题。
感谢您的回复!
英文:
I'm running Tomcat 9, Java 11 and deploy a Spring Boot Application.
The application was successfully deployed but I'm getting a 404 response. Looking in the Tomcat logs, it says that a JAR could not be found but if I locate the file spring-messaging-5.3.29.jar
under WEB-INF/lib
, it's actually there.
So what can be the reason?
Edit: If I redeploy the application, it shows up another JAR spring-boot-starter-data-jpa-2.7.14.jar
. I guess, something in general is broken here.
Thanks for your response!
[Catalina-utility-1] org.apache.catalina.core.StandardContext.listenerStop Exception sending context destroyed event to listener instance of class [ch.qos.logback.classic.$
java.lang.IllegalStateException: java.io.IOException: java.lang.reflect.InvocationTargetException
at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.getArchiveEntry(AbstractSingleArchiveResourceSet.java:101)
at org.apache.catalina.webresources.AbstractArchiveResourceSet.getResource(AbstractArchiveResourceSet.java:256)
at org.apache.catalina.webresources.StandardRoot.getResourceInternal(StandardRoot.java:282)
at org.apache.catalina.webresources.Cache.getResource(Cache.java:62)
at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:217)
at org.apache.catalina.webresources.StandardRoot.getClassLoaderResource(StandardRoot.java:226)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2303)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:865)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1334)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
at ch.qos.logback.core.ContextBase.getLifeCycleManager(ContextBase.java:260)
at ch.qos.logback.core.ContextBase.reset(ContextBase.java:175)
at ch.qos.logback.classic.LoggerContext.reset(LoggerContext.java:220)
at ch.qos.logback.classic.LoggerContext.stop(LoggerContext.java:348)
at ch.qos.logback.classic.servlet.LogbackServletContextListener.contextDestroyed(LogbackServletContextListener.java:36)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4730)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5396)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:805)
at org.apache.catalina.startup.HostConfig.undeploy(HostConfig.java:1424)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1351)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1610)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:305)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1151)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1353)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1357)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1335)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.io.IOException: java.lang.reflect.InvocationTargetException
at org.apache.tomcat.util.compat.Jre9Compat.jarFileNewInstance(Jre9Compat.java:236)
at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:162)
at org.apache.catalina.webresources.AbstractArchiveResourceSet.openJarFile(AbstractArchiveResourceSet.java:307)
at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.getArchiveEntry(AbstractSingleArchiveResourceSet.java:97)
... 34 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.GeneratedConstructorAccessor7.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.apache.tomcat.util.compat.Jre9Compat.jarFileNewInstance(Jre9Compat.java:233)
... 37 more
Caused by: java.nio.file.NoSuchFileException: /var/lib/tomcat9/webapps/spring-boot/WEB-INF/lib/spring-messaging-5.3.29.jar
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:149)
at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
at java.base/java.nio.file.Files.readAttributes(Files.java:1764)
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1259)
at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:733)
at java.base/java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:850)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:248)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:177)
at java.base/java.util.jar.JarFile.<init>(JarFile.java:350)
... 41 more
答案1
得分: 0
最后,我通过在 pom.xml
中放入正确的Java版本解决了这个问题:
<!-- language: xml -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release> <!-- Java版本 -->
<tomcat.version>9.0.31</tomcat.version>
</properties>
英文:
Finally, I solved the issue by putting the correct Java version in the pom.xml
:
<!-- language: xml -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release> <!-- Java version -->
<tomcat.version>9.0.31</tomcat.version>
</properties>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论