在TomCat上手动部署Web App

时间:2018-03-05 21:48:29

标签: java spring-mvc tomcat

我正在尝试在Tomcat上手动部署Web应用程序。 我创建了一个" myapp" webapps文件夹中的文件夹,包含以下文件和文件夹: -

1)myapp \ WEB-INF \ index.html

2)myapp \ WEB-INF \ classes

3)myapp \ WEB-INF \ lib

4)myapp \ WEB-INF \ myapp-servlet.xml

5)myapp \ WEB-INF \ web.html

但我得到以下例外: -

 java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp]]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:756)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1141)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        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)

我在tomcat和我刚刚复制粘贴的其他文件中链接了我的classes文件夹。我能够像往常一样运行这个。但我没有得到我所缺少的东西。是build.xml吗?谢谢!

更新1: -

05-Mar-2018 16:18:51.089 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.5.28
05-Mar-2018 16:18:51.093 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Feb 6 2018 23:10:25 UTC
05-Mar-2018 16:18:51.093 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.5.28.0
05-Mar-2018 16:18:51.093 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 10
05-Mar-2018 16:18:51.094 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            10.0
05-Mar-2018 16:18:51.094 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
05-Mar-2018 16:18:51.094 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\Java\jdk1.8.0_161\jre
05-Mar-2018 16:18:51.094 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_161-b12
05-Mar-2018 16:18:51.094 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
05-Mar-2018 16:18:51.095 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28
05-Mar-2018 16:18:51.095 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28
05-Mar-2018 16:18:51.095 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28\conf\logging.properties
05-Mar-2018 16:18:51.095 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
05-Mar-2018 16:18:51.095 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
05-Mar-2018 16:18:51.096 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
05-Mar-2018 16:18:51.096 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -agentlib:jdwp=transport=dt_socket,address=localhost:8000,server=y,suspend=n
05-Mar-2018 16:18:51.096 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
05-Mar-2018 16:18:51.096 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28
05-Mar-2018 16:18:51.096 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28
05-Mar-2018 16:18:51.096 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28\temp
05-Mar-2018 16:18:51.097 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.16] using APR version [1.6.3].
05-Mar-2018 16:18:51.097 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
05-Mar-2018 16:18:51.097 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
05-Mar-2018 16:18:52.219 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.0.2m  2 Nov 2017]
05-Mar-2018 16:18:52.442 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
05-Mar-2018 16:18:52.801 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
05-Mar-2018 16:18:52.826 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
05-Mar-2018 16:18:52.831 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
05-Mar-2018 16:18:52.833 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 2489 ms
05-Mar-2018 16:18:52.872 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
05-Mar-2018 16:18:52.872 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.28
05-Mar-2018 16:18:52.890 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28\webapps\docs]
05-Mar-2018 16:18:53.476 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28\webapps\docs] has finished in [586] ms
05-Mar-2018 16:18:53.478 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28\webapps\examples]
05-Mar-2018 16:18:54.474 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28\webapps\examples] has finished in [997] ms
05-Mar-2018 16:18:54.475 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28\webapps\host-manager]
05-Mar-2018 16:18:54.528 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28\webapps\host-manager] has finished in [54] ms
05-Mar-2018 16:18:54.529 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28\webapps\myapp]
05-Mar-2018 16:18:54.623 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[/myapp]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1141)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
    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:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@5323bab5]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4868)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5003)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 10 more
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@3cbf78d5]
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:113)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:724)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 13 more
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature)
    at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:142)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
    ... 16 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(ZipFile.java:60)
    at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:734)
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:434)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at sun.misc.IOUtils.readFully(IOUtils.java:65)
    at java.util.jar.JarFile.getBytes(JarFile.java:425)
    at java.util.jar.JarFile.getManifestFromReference(JarFile.java:193)
    at java.util.jar.JarFile.getManifest(JarFile.java:180)
    at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:140)
    ... 17 more

05-Mar-2018 16:18:54.627 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Error deploying web application directory [C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28\webapps\myapp]
 java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp]]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:756)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1141)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
    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:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

更新2: - 现在添加POM.xml我遇到了异常

05-Mar-2018 16:33:41.240 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[/myapp]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1141)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
        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:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name [myapp]
        at org.apache.catalina.core.StandardContext.addServletMappingDecoded(StandardContext.java:3155)
        at org.apache.catalina.core.StandardContext.addServletMappingDecoded(StandardContext.java:3145)
        at org.apache.catalina.startup.ContextConfig.configureContext(ContextConfig.java:1375)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1189)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:774)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5113)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 10 more

05-Mar-2018 16:33:41.242 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Error deploying web application directory [C:\Software Applications\apache-tomcat-8.5.28-windows-x64\apache-tomcat-8.5.28\webapps\myapp]
 java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp]]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:756)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1141)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
        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:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

2 个答案:

答案 0 :(得分:0)

如果您正在使用运行环境的jdk路径,则可以从cheking开始,您必须使用jre路径。确保tomcat使用与您的应用程序相同的java版本。

答案 1 :(得分:0)

根据之前的回答,我做了以下事情: -

1)添加了pom.xml而不是lib文件夹

2)更改了web.xml中的servlet名称

在tomcat上成功部署了上述Web应用程序。

更新: pom.xml不会让tomcat失败,但是一些与tomcat lib冲突的jar会删除那些东西都没问题。