无法在Tomcat上部署战争

时间:2016-09-07 14:46:20

标签: java eclipse tomcat gradle

我使用Tomcat 8的本地实例在Eclipse中开发了一个Spring Messaging应用程序。这可以在eclipse中完美地运行,但是当我创建一个war并在webapps内部署它时Tomcat的目录不起作用。 这些是我到目前为止所做的步骤。 我在Windows机器上使用gradle构建系统。因此我跑了gradlew build。 这在war内生成了root/build/lib个文件 我转到我本地tomcat的bin目录并运行start.bat 这设置Tomcat运行,然后我将war复制到tomcat的webapps目录。 我得到的只是404

这是我的catalina.log

07-Sep-2016 10:32:21.857 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.0.36
07-Sep-2016 10:32:21.858 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jun 9 2016 13:55:50 UTC
07-Sep-2016 10:32:21.859 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.0.36.0
07-Sep-2016 10:32:21.859 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 8.1
07-Sep-2016 10:32:21.859 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.3
07-Sep-2016 10:32:21.859 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
07-Sep-2016 10:32:21.859 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\Java\jdk1.8.0_91\jre
07-Sep-2016 10:32:21.859 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_91-b14
07-Sep-2016 10:32:21.860 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
07-Sep-2016 10:32:21.860 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Tomcat\v8\apache-tomcat-8.0.36
07-Sep-2016 10:32:21.860 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         C:\Tomcat\v8\apache-tomcat-8.0.36
07-Sep-2016 10:32:21.860 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
07-Sep-2016 10:32:21.860 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Tomcat\v8\apache-tomcat-8.0.36\conf\logging.properties
07-Sep-2016 10:32:21.860 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
07-Sep-2016 10:32:21.861 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=C:\Tomcat\v8\apache-tomcat-8.0.36\endorsed
07-Sep-2016 10:32:21.861 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Tomcat\v8\apache-tomcat-8.0.36
07-Sep-2016 10:32:21.861 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Tomcat\v8\apache-tomcat-8.0.36
07-Sep-2016 10:32:21.862 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Tomcat\v8\apache-tomcat-8.0.36\temp
07-Sep-2016 10:32:21.862 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent 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\jdk1.8.0_91\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\AccuRev\bin;C:\common;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;%MAVEN_HOME/bin%;C:\Program Files\Apache\apache-maven-3.3.9\bin;C:\Dev\gradle-2.13\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Users\SG047329\AppData\Roaming\npm;.
07-Sep-2016 10:32:22.029 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
07-Sep-2016 10:32:22.094 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
07-Sep-2016 10:32:22.096 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
07-Sep-2016 10:32:22.104 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
07-Sep-2016 10:32:22.105 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 524 ms
07-Sep-2016 10:32:22.130 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
07-Sep-2016 10:32:22.130 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.36
07-Sep-2016 10:32:22.223 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive C:\Tomcat\v8\apache-tomcat-8.0.36\webapps\opl-ws-webui-0.1.0.war
07-Sep-2016 10:32:29.090 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
07-Sep-2016 10:32:33.793 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive C:\Tomcat\v8\apache-tomcat-8.0.36\webapps\opl-ws-webui-0.1.0.war has finished in 11,570 ms
07-Sep-2016 10:32:33.795 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Tomcat\v8\apache-tomcat-8.0.36\webapps\docs
07-Sep-2016 10:32:33.826 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Tomcat\v8\apache-tomcat-8.0.36\webapps\docs has finished in 30 ms
07-Sep-2016 10:32:33.826 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Tomcat\v8\apache-tomcat-8.0.36\webapps\examples
07-Sep-2016 10:32:34.734 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Tomcat\v8\apache-tomcat-8.0.36\webapps\examples has finished in 908 ms
07-Sep-2016 10:32:34.735 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Tomcat\v8\apache-tomcat-8.0.36\webapps\host-manager
07-Sep-2016 10:32:34.775 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Tomcat\v8\apache-tomcat-8.0.36\webapps\host-manager has finished in 40 ms
07-Sep-2016 10:32:34.776 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Tomcat\v8\apache-tomcat-8.0.36\webapps\manager
07-Sep-2016 10:32:34.811 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Tomcat\v8\apache-tomcat-8.0.36\webapps\manager has finished in 35 ms
07-Sep-2016 10:32:34.811 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Tomcat\v8\apache-tomcat-8.0.36\webapps\ROOT
07-Sep-2016 10:32:34.835 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Tomcat\v8\apache-tomcat-8.0.36\webapps\ROOT has finished in 24 ms
07-Sep-2016 10:32:34.839 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
07-Sep-2016 10:32:34.856 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
07-Sep-2016 10:32:34.871 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 12765 ms

我在这里有几个问题,

  1. 如何部署战争并让它在Tomcat中运行。
  2. 当我在eclipse中运行时,我看不到build/lib内部实际创建的任何战争,那么eclipse如何使用Tomcat来运行我的webapp呢?

1 个答案:

答案 0 :(得分:0)

1.-实际上你开始一个干净的Tomcat实例的方式是:

  • 停止Tomcat服务器
  • 清理日志,临时文件和工作文件夹
  • 将.war文件复制到webapps文件夹
  • 启动Tomcat

    如果此过程不起作用,您可以看到在tomcat日志文件中生成的文件以查看未启动的原因

2.- Eclipse以及IDEA之类的其他IDE直接使用webapp,构建应用程序的文件夹,而不是.war文件。 war文件包含在这个webapp文件夹中,当你启动tomcat时会解压缩。