我已经创建了一个实例后,我在NoClassDefFoundError
上收到org.apache.commons.logging.LogFactory
个异常。我可以创建一个LogFactory
对象并从中获取org.apache.commons.logging.Log
的实例但是在创建类型为org.apache.axis.description.TypeDesc
的对象时,当此类尝试时会抛出NoClassDefFoundError
从org.apache.commons.logging.Log
获取LogFactory
的实例。似乎应该在第284行抛出异常。(?)
这是我的代码(DtUiLoggingRequest第282行到第294行);
log.debug("vvvvvvvvvvvvvvvv");
org.apache.commons.logging.LogFactory logFactory = (org.apache.commons.logging.LogFactory)LogFactory.getFactory();
Log myLog = LogFactory.getLog(DtUiLoggingRequest.class.getName());
log.debug(logFactory.getClass().getName());
log.debug(myLog.getClass().getName());
myLog.debug("This is coming from 'myLog'");
log.debug("^^^^^^^^^^^^^^^^");
typeDesc = new org.apache.axis.description.TypeDesc(DtUiLoggingRequest.class);
这是日志所说的内容;
DEBUG 2012-02-23 09:32:08,739 vvvvvvvvvvvvvvvv
DEBUG 2012-02-23 09:32:08,739 org.apache.commons.logging.impl.LogFactoryImpl
DEBUG 2012-02-23 09:32:08,739 org.apache.commons.logging.impl.Log4JLogger
DEBUG 2012-02-23 09:32:08,739 ^^^^^^^^^^^^^^^^
ERROR 2012-02-23 09:32:08,739 Exception Details:
java.lang.NoClassDefFoundError: org.apache.commons.logging.LogFactory
at org.apache.axis.components.logger.LogFactory.class$(LogFactory.java:45)
at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:45)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:41)
at org.apache.axis.components.logger.LogFactory.<clinit>(LogFactory.java:33)
at org.apache.axis.description.TypeDesc.<clinit>(TypeDesc.java:61)
at com.symantec.cas.ucf.sensors.DtUiLoggingRrequest.initTypeDesc(DtUiLoggingRequest.java:294)
at com.symantec.cas.ucf.sensors.sap.DtUiLoggingRequest.<init>(DtUiLoggingRequest.java:58)
at com.symantec.cas.ucf.sensors.sap.SapSensor.OpenDevice(Sensor.java:151)
at com.symantec.cas.ucf.collector.SensorJob.openSensor(SensorJob.java:156)
at com.symantec.cas.ucf.collector.SensorJob.run(SensorJob.java:290)
at java.lang.Thread.run(Thread.java:662)
答案 0 :(得分:2)
这看起来像是一个类加载器问题。您正在使用具有分层类加载器的系统(如Web应用程序),并且Axis由比Commons Logging更高级别的类加载器加载。这意味着,即使Commons Logging在您的系统中,Axis也不允许看到它。我疯狂的猜测是你从一个JRE扩展目录加载Axis,但从你的war文件中加载Commons Logging。