LifecycleException:无法在 Tomcat 中启动组件部署战争

     2023-02-27     305

关键词:

【中文标题】LifecycleException:无法在 Tomcat 中启动组件部署战争【英文标题】:LifecycleException: Failed to start component deploying war in Tomcat 【发布时间】:2016-07-23 11:38:35 【问题描述】:

我用 Spring Boot 实现了 restful api。当我在带有嵌入式 Tomcat 服务器的 Spring Boot Suite 中启动应用程序时,它可以工作。但是,当我尝试将战争部署到 Tomcat 7 时,出现以下错误:

SEVERE: Exception fixing docBase for context [/cgweb]
java.io.FileNotFoundException: /Users/djiao/Downloads/apache-tomcat-7.0.68/webapps/cgweb/LICENSE (Is a directory)

SEVERE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/cgweb]]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
Caused by: java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;

SEVERE: Error deploying web application archive /Users/djiao/Downloads/apache-tomcat-7.0.68/webapps/cgweb.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina
].StandardHost[localhost].StandardContext[/cgweb]]

我知道可能有数百个类似类型的帖子。经过我2天多的研究,以下是导致此类问题的主要原因。

    Tomcat 版本与 java 编译器版本不匹配。

我使用 java 7 编译并使用 Tomcat 7 进行部署。我确保我为 JAVA_HOME 而不是 jdk 路径设置了 jre 路径。

    jpa 2.0 和 2.1 之间的冲突(与外键错误有关)。

我在我的依赖项中都有并删除了 2.0。

    hibernate-entitymanger 和 hibernate-core 之间的版本不匹配。

检查了pom的依赖层次,都是4.3.11.Final。

    通过手动将战争复制到 webapp 文件夹进行部署。

尝试在 Tomcat 管理器 UI 中部署。

这些都不适用于我的案例。尝试了一切,但没有任何效果。由于我使用的是 Spring Boot,因此大部分配置都是自动完成的。我没有 web.xml。我在主应用程序类之前有以下注释。

@SpringBootApplication
@EntityScan("org.mdacc.rists.cghub.model") 
@EnableJpaRepositories(basePackages = "org.mdacc.rists.cghub.ws.repository")

在 application.properties 中,除了数据源配置之外,我还有以下几行。

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.data.jpa.repositories.enabled=true

还有其他可能导致部署失败的原因吗?

【问题讨论】:

检查是否有任何休眠或 JPA 相关的 jar 文件在 tomcat 服务器 lib 或 common 目录中,这优先于您在 WEB-INF/lib 中打包的文件。并且只是为了确保进行干净的构建并清理 tomcat 工作目录并重新启动。 抱歉,java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey 只意味着一件事。您在运行时的 CLASSPATH 中有一个 JPA API v2.0 jar。仍然。所以打印出运行时system.classpath 尝试使用-verbose:class 运行 Tomcat。它会告诉你 JPA 2.0 类是从哪里加载的 @Neil Stockton 如何打印运行时 system.classpath? @AndyWilkinson 我运行了startup.sh -verbose:class,但在 catalina.[date].log 中没有打印任何关于课程的信息。我应该在哪里寻找这些信息? 【参考方案1】:

总结一下这个问题,即使从这个项目中删除了 jpa 2.0 的 maven 依赖项,war 文件也同时具有 jpa 2.0 和 2.1 jar 文件。

原因是,jpa 2.0 是从另一个项目中挑选出来的,该项目是该项目的依赖项之一。为该依赖包执行 maven clean(删除 jpa 2.0 之后)并再次重建它解决了这个问题。

【讨论】:

失败 - 遇到异常 org.apache.catalina.LifecycleException

】失败-遇到异常org.apache.catalina.LifecycleException【英文标题】:FAIL-Encounteredexceptionorg.apache.catalina.LifecycleException【发布时间】:2012-06-2619:23:55【问题描述】:我无法在Tomcat7上部署.war。它在其中一台服务器上运行良好,但在另一台... 查看详情

lifecycleexception:failedtostartcomponent[org

异常信息:java.util.concurrent.ExecutionException:org.apache.catalina.LifecycleException:Failedtostartcomponent[[email protected]]Failedtostartcomponent[StandardEngine[Catalina].StandardHost[localhost 查看详情

MIUI 11/12 主题切换导致 LifeCycleException、ClassCastException

】MIUI11/12主题切换导致LifeCycleException、ClassCastException【英文标题】:MIUI11/12ThemeSwitchResultsinLifeCycleException,ClassCastException【发布时间】:2021-02-1008:45:03【问题描述】:自从MIUI11/12使用它自己的暗模式自定义实现,使用下面的代码会... 查看详情

isEqual to operator 在 Flutter Firestore 中无法正常工作

】isEqualtooperator在FlutterFirestore中无法正常工作【英文标题】:isEqualtooperatorisnotworkingproperlyinFlutterFirestore【发布时间】:2020-09-0600:28:38【问题描述】:我正在尝试在CloudFirestore中使用Flutter中的isEqualTo运算符在StreamBuilder内执行复合... 查看详情

imageField 中的 upload_to 属性无法将图像保存在磁盘上

】imageField中的upload_to属性无法将图像保存在磁盘上【英文标题】:upload_topropertyinimageFieldcannotsaveimageondisk【发布时间】:2012-12-2908:29:28【问题描述】:我是django的初学者。我想要一个imageField我的ModelForm可以保存上传到我磁盘中... 查看详情

javaweb项目启动报错org.apache.catalina.lifecycleexception:failedtostartcomponent[standardengine[catal

org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/cab-web]] atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.j 查看详情

LINQ to Entities 无法识别该方法(在相关实体上)

】LINQtoEntities无法识别该方法(在相关实体上)【英文标题】:LINQtoEntitiesdoesnotrecognizethemethod(onarelatedentity)【发布时间】:2016-09-2305:56:23【问题描述】:我正在尝试使一些代码更具可读性,但并没有完全掌握如何构建扩展方法和/... 查看详情

更新 substring(to:) 导致无法推断通用参数

】更新substring(to:)导致无法推断通用参数【英文标题】:updatingsubstring(to:)resultsingenericparametercouldnotbeinferred【发布时间】:2017-11-0702:27:07【问题描述】:我正在使用一个使用substring(to:)的框架,该框架现已在swift4中被弃用。letsplit=... 查看详情

无法在 linq to entity 查询中构造实体或复杂类型“x”

】无法在linqtoentity查询中构造实体或复杂类型“x”【英文标题】:theentityorcomplextype\'x\'cannotbeconstructedinalinqtoentitiesquery【发布时间】:2015-07-0600:55:31【问题描述】:谁能告诉我以下代码有什么问题,因为我在运行时在主题中收到... 查看详情

org.apache.catalina.lifecycleexception:failedtostartcomponent(代码片段)

...项目中解决的问题启动Tomcat时报以下错误org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/servlet3]] atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162) atorg.apache.catalina.core.Container... 查看详情

XSLT 3.0 - 无法在 XSLT 3.0 xml-to-json() 中获取对象数组

】XSLT3.0-无法在XSLT3.0xml-to-json()中获取对象数组【英文标题】:XSLT3.0-NotabletogetArrayofobjectsinXSLT3.0xml-to-json()【发布时间】:2021-11-0819:25:58【问题描述】:我正在尝试使用XSLT3.0将给定的json数据从一种形式转换为另一种形式。我正在... 查看详情

java.util.concurrent.executionexception:org.apache.catalina.lifecycleexception

启动springboot项目的时候遇到了报错:27-Sep-201818:04:15.513INFO[main]org.apache.catalina.core.StandardService.startInternalStartingservice[Catalina]27-Sep-201818:04:15.513INFO[main]org.apache.catalina.core.Standar 查看详情

在 to_date 函数中使用 cx_oracle 变量时无法正确绑定

】在to_date函数中使用cx_oracle变量时无法正确绑定【英文标题】:Cannotgetcx_oraclevariabletobindproperlywhenusingitinto_datefunction【发布时间】:2019-01-0606:55:15【问题描述】:我正在尝试替换此调用:cursor=connection.cursor()try:sql="selectm.lat,m.longt... 查看详情

无法在 LINQ to Entity VS 2017 中使用包含我的查询附加

】无法在LINQtoEntityVS2017中使用包含我的查询附加【英文标题】:UnabletouseContainsinLINQtoEntityVS2017myqueryattached【发布时间】:2020-09-1912:41:08【问题描述】:我的查询是,这里我试图获取区域名称匹配的区域id,varRid=db.Regions.Where(p=>S... 查看详情

无法快速使用递归

】无法快速使用递归【英文标题】:Notabletouserecursioninswift【发布时间】:2014-07-2912:21:56【问题描述】:我正在使用这个功能funccountFrom(from:Int,#to:Int)->()println("\\(from)")iffrom<tocountFrom(from+1,to:to)countFrom(1,to:10)但在编译时我得到Swi... 查看详情

无法使用 Attachinary 在 Heroku 上运行 Rails 控制台:未定义方法 `respond_to' for Attachinary::CorsController:Class

】无法使用Attachinary在Heroku上运行Rails控制台:未定义方法`respond_to\\\'forAttachinary::CorsController:Class【英文标题】:ImpossibletorunaRailsconsoleonherokuwithAttachinary:undefinedmethod`respond_to\'forAttachinary::CorsController:Class无法使用At 查看详情

无法比较 to_char(timestamp, 'day') = 'monday'

】无法比较to_char(timestamp,\\\'day\\\')=\\\'monday\\\'【英文标题】:Troublecomparingto_char(timestamp,\'day\')=\'monday\'无法比较to_char(timestamp,\'day\')=\'monday\'【发布时间】:2020-03-2820:28:35【问题描述】:在PostgreSQL数据库中,我有一个表支付,其... 查看详情

javaweb-org.apache.catalina.lifecycleexception:protocolhandlerstartfailed(代码片段)

报错问题org.apache.catalina.LifecycleException:Protocolhandlerstartfailed错误原因端口号被占用导致程序启动失败解决方案找到对应端口号和PID,看下是啥程序占用了该端口号,要么杀死该程序,要么换个端口号温馨提示不一定是... 查看详情