3

我正在尝试部署我的应用程序,但它给了我一个错误:无法实例化 SLF4J LoggerFactory 报告异常:

java.lang.NoClassDefFoundError: org/apache/log4j/Level
    at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:75)
    at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:45)
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
    at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:197)
    at org.hibernate.ejb.Ejb3Configuration.<clinit>(Ejb3Configuration.java:133)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
    at weblogic.persistence.BasePersistenceUnitInfo.initializeEntityManagerFactory(BasePersistenceUnitInfo.java:452)
    at weblogic.persistence.BasePersistenceUnitInfo.initializeEntityManagerFactory(BasePersistenceUnitInfo.java:445)
    at weblogic.persistence.BasePersistenceUnitInfo.init(BasePersistenceUnitInfo.java:119)
    at weblogic.persistence.BaseJPAIntegrationProvider.createPersistenceUnitInfo(BaseJPAIntegrationProvider.java:53)
    at weblogic.persistence.AbstractPersistenceUnitRegistry.storeDescriptors(AbstractPersistenceUnitRegistry.java:420)
    at weblogic.persistence.AbstractPersistenceUnitRegistry.loadPersistenceDescriptor(AbstractPersistenceUnitRegistry.java:339)
    at weblogic.persistence.ModulePersistenceUnitRegistry.<init>(ModulePersistenceUnitRegistry.java:67)
    at weblogic.ejb.container.deployer.EJBModule.setupPersistenceUnitRegistry(EJBModule.java:190)
    at weblogic.ejb.container.deployer.EJBModule$1.execute(EJBModule.java:297)
    at weblogic.persistence.PersistenceUnitRegistryInitializer.setupPersistenceUnitRegistries(PersistenceUnitRegistryInitializer.java:62)
    at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:394)
    at weblogic.application.internal.ExtensibleModuleWrapper$PrepareStateChange.next(ExtensibleModuleWrapper.java:295)
    at weblogic.application.internal.ExtensibleModuleWrapper$PrepareStateChange.next(ExtensibleModuleWrapper.java:285)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
    at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:109)
    at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
    at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:172)
    at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:167)
    at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:80)
    at weblogic.work.ContextWrap.run(ContextWrap.java:40)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:550)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)

我在 Maven 依赖项中有 jar-s:

Maven依赖

weblogic中log4j jar的类路径:

log4j.xml

log4j.xml(来自类路径):

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

    <appender name="LOGFILE" class="org.apache.log4j.FileAppender">

        <param name="File"   value="C:\\Work\\KEPLER\\KH_RRM\\log/rrm-web.log" />
        <param name="Append" value="false" />
        <layout class="org.apache.log4j.PatternLayout">
           <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p [%c{1}] %m%n"/>
        </layout>
    </appender>

    <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
           <param name="ConversionPattern" value=" %d{yyyy-MM-dd HH:mm:ss} [%t] %-5p [%c{1}] %m%n"/>
        </layout>
    </appender>

    <root>
       <priority value ="ALL" />
       <appender-ref ref="STDOUT" />
       <appender-ref ref="LOGFILE" />
    </root>

</log4j:configuration>

我错了什么?我无法想象...请帮助我!谢谢!

4

2 回答 2

2

通常,因为这是与 maven 相关的问题,所以请附加您的 pom.xml(或其中的一部分)。这比附上截图要好:)

您的 log4j 依赖项提供了范围,这意味着 log4j 已经在您的服务器上并且不应该与应用程序一起安装。

于 2013-11-11T16:33:21.897 回答
1

答案是:我正在部署到 Adminserver,但我必须将我的应用程序部署到集群,因为 ServerStart 中的 ClassPath 和 Arguments 设置不仅适用于 Adminserver,它只会适用于其他服务器。

于 2013-11-12T22:51:08.020 回答