当前位置: 首页 > 知识库问答 >
问题:

用Gradle构建的Spring应用程序在eclipse中运行,但war文件在tomcat上抛出404

慕永年
2023-03-14

我使用EclipseGradle插件执行了一个gradle构建,并将war文件从build/lib部署到远程服务器上的tomcat上。war文件抛出404,即使tomcat管理器将war标识为已部署。看到日志后,似乎Spring应用程序根本没有启动。

日志:

Aug 05, 2014 5:04:45 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false]
Aug 05, 2014 5:04:45 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false]
Aug 05, 2014 5:04:45 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false]
Aug 05, 2014 5:04:45 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false]
Aug 05, 2014 5:04:45 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
Aug 05, 2014 5:04:45 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false]
Aug 05, 2014 5:04:46 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Aug 05, 2014 5:04:46 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 372 ms
Aug 05, 2014 5:04:46 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Aug 05, 2014 5:04:46 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.52 (Ubuntu)
Aug 05, 2014 5:04:46 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/branch.war
Aug 05, 2014 5:04:46 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/var/lib/tomcat7/webapps/branch/WEB-INF/lib/javaee-api-6.0-6.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Aug 05, 2014 5:04:46 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/var/lib/tomcat7/webapps/branch/WEB-INF/lib/javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Aug 05, 2014 5:04:46 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/var/lib/tomcat7/webapps/branch/WEB-INF/lib/jsp-api-2.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Aug 05, 2014 5:04:50 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/var/lib/tomcat7/webapps/branch/WEB-INF/lib/slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/var/lib/tomcat7/webapps/branch/WEB-INF/lib/slf4j-simple-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
log4j:WARN No appenders could be found for logger (net.kencochrane.raven.DefaultRavenFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Aug 05, 2014 5:05:21 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Aug 05, 2014 5:05:21 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/branch] startup failed due to previous errors
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/branch] registered the JDBC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/branch] appears to have started a thread named [pool-1-thread-1] but has failed to stop it. This is very likely to create a memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/branch] appears to have started a thread named [pool-1-thread-2] but has failed to stop it. This is very likely to create a memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/branch] appears to have started a thread named [pool-1-thread-3] but has failed to stop it. This is very likely to create a memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/branch] appears to have started a thread named [pool-1-thread-4] but has failed to stop it. This is very likely to create a memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/branch] appears to have started a thread named [pool-1-thread-5] but has failed to stop it. This is very likely to create a memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/branch] appears to have started a thread named [pool-1-thread-6] but has failed to stop it. This is very likely to create a memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/branch] appears to have started a thread named [pool-1-thread-7] but has failed to stop it. This is very likely to create a memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/branch] appears to have started a thread named [pool-1-thread-8] but has failed to stop it. This is very likely to create a memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/branch] created a ThreadLocal with key of type [net.kencochrane.raven.Raven$1] (value [net.kencochrane.raven.Raven$1@183601a5]) and a value of type [java.lang.Boolean] (value [false]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/branch] created a ThreadLocal with key of type [net.kencochrane.raven.Raven$1] (value [net.kencochrane.raven.Raven$1@183601a5]) and a value of type [java.lang.Boolean] (value [false]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/branch] created a ThreadLocal with key of type [net.kencochrane.raven.Raven$1] (value [net.kencochrane.raven.Raven$1@183601a5]) and a value of type [java.lang.Boolean] (value [true]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/branch] created a ThreadLocal with key of type [net.kencochrane.raven.Raven$1] (value [net.kencochrane.raven.Raven$1@183601a5]) and a value of type [java.lang.Boolean] (value [true]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/branch] created a ThreadLocal with key of type [net.kencochrane.raven.Raven$1] (value [net.kencochrane.raven.Raven$1@183601a5]) and a value of type [java.lang.Boolean] (value [true]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/branch] created a ThreadLocal with key of type [net.kencochrane.raven.Raven$1] (value [net.kencochrane.raven.Raven$1@183601a5]) and a value of type [java.lang.Boolean] (value [true]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/branch] created a ThreadLocal with key of type [net.kencochrane.raven.Raven$1] (value [net.kencochrane.raven.Raven$1@183601a5]) and a value of type [java.lang.Boolean] (value [true]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/branch] created a ThreadLocal with key of type [net.kencochrane.raven.Raven$1] (value [net.kencochrane.raven.Raven$1@183601a5]) and a value of type [java.lang.Boolean] (value [true]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/branch] created a ThreadLocal with key of type [net.kencochrane.raven.Raven$1] (value [net.kencochrane.raven.Raven$1@183601a5]) and a value of type [java.lang.Boolean] (value [true]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 05, 2014 5:05:21 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/branch] created a ThreadLocal with key of type [net.kencochrane.raven.Raven$1] (value [net.kencochrane.raven.Raven$1@183601a5]) and a value of type [java.lang.Boolean] (value [true]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

更新:

在更改log4j属性后,多亏了Stefan,当我试图部署我的war文件时,我发现了以下错误。

INFO: Deploying web application archive /var/lib/tomcat7/webapps/branch.war
Aug 6, 2014 7:47:00 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Aug 6, 2014 7:47:00 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Aug 6, 2014 7:47:00 PM org.apache.catalina.startup.HostConfig deployWARs
SEVERE: Error waiting for multi-thread deployment of WAR files to complete
java.lang.InterruptedException
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1000)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304)
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:248)
    at java.util.concurrent.FutureTask.get(FutureTask.java:111)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:751)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:471)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1453)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:295)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1379)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1537)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1547)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1526)
    at java.lang.Thread.run(Thread.java:701)

共有2个答案

谢华彩
2023-03-14

我终于解决了。问题有两个方面,

  1. 我没有正确配置log4j属性。我在Stefan的帮助下纠正了这一点
尚恩
2023-03-14

首先需要修复日志配置。从war文件中删除slf4j-simple-1.5.8.jar,并将有效的log4j.properties文件插入WEB-INF/class(或项目中的src)目录:

log4j.rootLogger=WARN, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
 类似资料:
  • 主要内容:1- 创建Gradle工程,2- 配置Gradle,3-编辑应用程序结构,项目代码,5- Gradle构建,6-配置以运行应用程序1- 创建Gradle工程 打开 Eclipse ,在菜单中找到 File -> New -> Other…,在打开界面中选择 ,如下图中所示 - 点击下一步(Next),如下图中所示,并继续点击下一步(Next) - 在新打开的界面中输入项目代码的名称,这里我们创建一个名称为 如下图所示- 在新打开界面中,选择 的安装目录,如下图中所示,并继续点击下一步(

  • 我创建了angular和Spring Boot应用程序,并希望将其部署到tomcat服务器上。为此,我在spring boot项目中复制了angular项目,并提供了pom.xml来创建war文件。之后,我在tomcat上部署了war文件,并启动了它。请告诉我是什么 Angular的index.html中的基本href 应该提供什么上下文路径? 是否需要在application.propertie

  • 我对斯普林和格拉德尔还不熟悉。我试图在Tomcat服务器上使用Gradle构建来部署Spring应用程序。我能够生成war文件,但我没有web。用于映射servlet的xml文件,我没有映射servlet。我有一个主类和配置类。 那么,为了在tomcat上部署我的应用程序,我需要做什么?我找不到一个合适的端到端文章。我经历了这一切http://docs.spring.io/spring-boot/

  • 我有一个Spring boot应用程序,希望在Eclipse中作为服务器应用程序运行。因此,该应用程序将被识别为Tomcat web应用程序,并可以在更新facet时添加: 当我运行web应用程序时,找不到我的rest服务。spring boot应用程序包含的文件夹结构与spring boot发布前的spring应用程序不同。spring boot应用程序可以从配置了eclipse的tomcat上

  • 我正在尝试在tomcat服务器上部署spring boot应用程序。我的pom中有这种依赖性。xml文件: 当检查服务器(catalina.out)的日志时,它说: 由于. war文件位于 /webapps目录中,因此创建了webapps/myapp目录。但是,当我尝试访问该服务时,我收到404错误,说明“请求的资源不可用”。我已经尝试过从前端角应用程序、postman和简单的直接从浏览器获取请求

  • 本文向大家介绍Spring Boot使用Thymeleaf + Gradle构建war到Tomcat,包括了Spring Boot使用Thymeleaf + Gradle构建war到Tomcat的使用技巧和注意事项,需要的朋友参考一下 Spring Boot 以Jar的方式部署启动,这个不用介绍了, 之前也介绍了关于 Spring Boot + thymeleaf 的简单使用 ,但是今天遇到一个问