原因:org.apache.logging.log4j.LoggingException:log4j-slf4j2-impl 不能与 log4j-to-slf4j 一起出现,我应该修复什么?

问题描述 投票:0回答:1

我认为我在准备环境时做错了什么。 我有一个战争文件,我被告知它可以正常工作。当我将其放在带有 Tomcat 10 和 java 21 的“CentOS Linux 7(核心)”上时,我在 catalina.out 中得到以下内容

[main] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [/opt/apache-tomcat-10.1.19/webapps/name_of_.war]
java.lang.IllegalStateException: Error starting child
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:686)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:658)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:712)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:969)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1911)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:771)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:423)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1629)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:114)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:345)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:893)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:845)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:240)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:921)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:757)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/name_of_]]
    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:419)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:186)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:683)
    ... 35 more
Caused by: org.apache.logging.log4j.LoggingException: log4j-slf4j2-impl cannot be present with log4j-to-slf4j
    at org.apache.logging.slf4j.Log4jLoggerFactory.validateContext(Log4jLoggerFactory.java:70)
    at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:50)
    at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:33)
    at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:53)
    at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:33)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:422)
    at org.apache.commons.logging.LogAdapter$Slf4jAdapter.createLocationAwareLog(LogAdapter.java:121)
    at org.apache.commons.logging.LogAdapter.createLog(LogAdapter.java:95)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:67)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:59)
    at org.springframework.core.annotation.IntrospectionFailureLogger.getLogger(IntrospectionFailureLogger.java:75)
    at org.springframework.core.annotation.IntrospectionFailureLogger$2.isEnabled(IntrospectionFailureLogger.java:49)
    at org.springframework.core.annotation.AnnotationUtils.handleIntrospectionFailure(AnnotationUtils.java:1129)
    at org.springframework.core.annotation.AnnotationsScanner.processClassHierarchy(AnnotationsScanner.java:233)
    at org.springframework.core.annotation.AnnotationsScanner.processClassHierarchy(AnnotationsScanner.java:171)
    at org.springframework.core.annotation.AnnotationsScanner.processClass(AnnotationsScanner.java:108)
    at org.springframework.core.annotation.AnnotationsScanner.process(AnnotationsScanner.java:92)
    at org.springframework.core.annotation.AnnotationsScanner.scan(AnnotationsScanner.java:82)
    at org.springframework.core.annotation.TypeMappedAnnotations.scan(TypeMappedAnnotations.java:248)
    at org.springframework.core.annotation.TypeMappedAnnotations.get(TypeMappedAnnotations.java:155)
    at org.springframework.core.annotation.TypeMappedAnnotations.get(TypeMappedAnnotations.java:137)
    at org.springframework.core.annotation.OrderUtils.findOrder(OrderUtils.java:123)
    at org.springframework.core.annotation.OrderUtils.getOrderFromAnnotations(OrderUtils.java:116)
    at org.springframework.core.annotation.AnnotationAwareOrderComparator.findOrderFromAnnotation(AnnotationAwareOrderComparator.java:75)
    at org.springframework.core.annotation.AnnotationAwareOrderComparator.findOrder(AnnotationAwareOrderComparator.java:68)
    at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:128)
    at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:116)
    at org.springframework.core.OrderComparator.doCompare(OrderComparator.java:86)
    at org.springframework.core.OrderComparator.compare(OrderComparator.java:73)
    at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
    at java.base/java.util.TimSort.sort(TimSort.java:220)
    at java.base/java.util.Arrays.sort(Arrays.java:1308)
    at java.base/java.util.ArrayList.sort(ArrayList.java:1804)
    at org.springframework.core.annotation.AnnotationAwareOrderComparator.sort(AnnotationAwareOrderComparator.java:111)
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4866)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
    ... 36 more

所以在测试环境中它不起作用。有人告诉我这是权限错误或其他问题,但我如何找到缺少哪些权限?

java tomcat log4j
1个回答
0
投票

在线阅读并询问周围似乎问题是这个文件: /opt/tomcat10/webapps/name_of_/WEB-INF/lib/log4j-slf4j2-impl-2.21.1.jar 删除后就开始了。

© www.soinside.com 2019 - 2024. All rights reserved.