我使用Maven在eclipse中创建了一个简单的Spring mvc项目。 我使用的是Java 1.8和Tomcat 9.0。 对于4.3.5或更低版本的JAR,一切正常。
但是当我尝试使用4.3.6 JAR版本时,它会显示以下问题
Feb 28, 2017 11:56:21 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:demoMaven' did not find a matching property.
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/9.0.0.M9
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Jul 4 2016 18:22:47 UTC
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 9.0.0.0
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 8
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.2
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files\Java\jre1.8.0_121
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_121-b13
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: E:\J2EE\HYD\SPRINGMAVEN\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: E:\Tomcat 9.0
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=E:\J2EE\HYD\SPRINGMAVEN\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=E:\Tomcat 9.0
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=E:\J2EE\HYD\SPRINGMAVEN\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=E:\Tomcat 9.0\endorsed
Feb 28, 2017 11:56:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Feb 28, 2017 11:56:21 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.8.0_121\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_121/bin/server;C:/Program Files/Java/jre1.8.0_121/bin;C:/Program Files/Java/jre1.8.0_121/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_121\bin;;E:\STUDY SW\JAVA\IDE\eclipse-jee-neon-R-win32-x86_64\eclipse;;.
Feb 28, 2017 11:56:21 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-9090"]
Feb 28, 2017 11:56:22 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Feb 28, 2017 11:56:22 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Feb 28, 2017 11:56:22 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Feb 28, 2017 11:56:22 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1179 ms
Feb 28, 2017 11:56:22 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Feb 28, 2017 11:56:22 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/9.0.0.M9
Feb 28, 2017 11:56:22 AM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/demoMaven]]
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:911)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:890)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/demoMaven]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@54a801fe]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4830)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4962)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@cd12c98]
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:112)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:141)
at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:701)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
... 9 more
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature)
at org.apache.catalina.webresources.JarResourceSet.initInternal(JarResourceSet.java:139)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
... 12 more
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
at java.util.zip.ZipFile.read(Native Method)
at java.util.zip.ZipFile.access$1400(Unknown Source)
at java.util.zip.ZipFile$ZipFileInputStream.read(Unknown Source)
at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(Unknown Source)
at java.util.zip.InflaterInputStream.read(Unknown Source)
at sun.misc.IOUtils.readFully(Unknown Source)
at java.util.jar.JarFile.getBytes(Unknown Source)
at java.util.jar.JarFile.getManifestFromReference(Unknown Source)
at java.util.jar.JarFile.getManifest(Unknown Source)
at org.apache.catalina.webresources.JarResourceSet.initInternal(JarResourceSet.java:137)
... 13 more
Feb 28, 2017 11:56:22 AM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:911)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:791)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at org.apache.catalina.startup.Catalina.start(Catalina.java:655)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:920)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:890)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
... 6 more
Feb 28, 2017 11:56:22 AM org.apache.catalina.startup.Catalina start
SEVERE: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
at org.apache.catalina.startup.Catalina.start(Catalina.java:655)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:791)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:920)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
... 11 more
Feb 28, 2017 11:56:22 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-nio-9090"]
Feb 28, 2017 11:56:22 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-nio-8009"]
Feb 28, 2017 11:56:22 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Feb 28, 2017 11:56:22 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-nio-9090"]
Feb 28, 2017 11:56:22 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-nio-8009"]
答案 0 :(得分:1)
首先检查您的tomcat是否能够在不运行您构建的项目的情况下启动。如果是,请按照以下步骤
某些Spring Jars可能与Java版本存在兼容问题。因此,请尝试手动添加以下jar / dependencies并确保它们具有相同的版本
-commons-logging-x.y.z.jar
-org.springframework.asm-x.y.z.jar
-org.springframework.beans-x.y.z.jar
-org.springframework.context-x.y.z.jar
-org.springframework.core-x.y.z.jar
-org.springframework.expression-x.y.z.jar
-org.springframework.web.servlet-x.y.z.jar
-org.springframework.web-x.y.z.jar
-spring-web.jar
-servlet.jar
更改JRE,右键单击项目Build-path - >配置构建路径 - >库,确保存在/添加JRE系统库。
请仅在lib文件夹下添加提取的Jars以及构建路径。
您的申请现在应该可以正常运作。