I’m getting a NoClassDefFoundError exception on org.apache.commons.logging.LogFactory after I have already created an instance. I can create a LogFactory object just fine and get an instance of org.apache.commons.logging.Log from it but when creating an object of type org.apache.axis.description.TypeDesc, a NoClassDefFoundError is thrown when this class tries to get an instance of org.apache.commons.logging.Log from LogFactory. Seems like an exception should be thrown at line 284.(?)
Here’s my code (DtUiLoggingRequest lines 282 to 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);
Here’s what the log says;
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)
This looks like a classloader issue to me. You’re working in a system with hierarchical classloaders, like a web app, and Axis is being loaded by a higher-status classloader than Commons Logging. That means that, even though Commons Logging is in your system, Axis is not allowed to see it. My wild-arsed guess would be that you’re loading Axis from a JRE extension directory, but Commons Logging from your war file.