Sunday, February 7, 2010

Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/management/WebLogicMBean

While working in WebLogic, are you haunted by weblogic logging classes (which in 10.3 are spread into a miriad of jar files, and ultimately in any case you can't avoid including weblogic.jar in the classpath, messing around everything else)?


Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/management/WebLogicMBean
    at weblogic.kernel.KernelLogManager$LoggerMaker.(KernelLogManager.java:22)
    at weblogic.kernel.KernelLogManager.getLogger(KernelLogManager.java:28)
    at weblogic.logging.commons.LogImpl.(LogImpl.java:14)
    at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:21)
    at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:18)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
    at org.apache.axis2.description.AxisDescription.(AxisDescription.java:76)
    at org.openuri.www.GetPrepaidAccountBalanceProcessStub.populateAxisService(GetPrepaidAccountBalanceProcessStub.java:41)
    at org.openuri.www.GetPrepaidAccountBalanceProcessStub.(GetPrepaidAccountBalanceProcessStub.java:91)
    at org.openuri.www.GetPrepaidAccountBalanceProcessStub.(GetPrepaidAccountBalanceProcessStub.java:78)
    at org.openuri.www.GetPrepaidAccountBalanceProcessStub.(GetPrepaidAccountBalanceProcessStub.java:124)
    at org.openuri.www.GetPrepaidAccountBalanceProcessStub.(GetPrepaidAccountBalanceProcessStub.java:117)
    at com.pierre.acmetester.AcmePrepaidTester.main(JawwalPrepaidTester.java:14)






the solution is:
import org.apache.commons.logging.LogFactory;
...


System.setProperty(LogFactory.FACTORY_PROPERTY, "org.apache.commons.logging.impl.Log4jFactory");

This will force Apache Commons Logging to use Log4J rather than WebLogic... and don't listen to people saying that Log4J is the default implementation for Apache... IT IS NOT!

I can't believe in 2010 we are still in such a pathetic shape.... Java will die, it's too messy, everything is just a HUGE mess.... even the fact that in order to log a message I need to instantiate a WebLogicMBean is grotesque. And the fact that the WebLogicMBean initialization fails without a proper error message is grotesque.... EVERYTHING IS GROTESQUE. Why people can't do a proper job. Why do we have to suffer so much.

1 comment:

Anonymous said...

add commons-logging-XXXXX.jar

http://nexus.cestpasdur.com/nexus/content/repositories/sonatype-forge/com/adobe/flex/compiler/commons-logging/4.5.1.21328/

add try it!