Weblogic Tips #1

Weblogic throws NoClassDefFoundError: weblogic.util.NestedUtilException

Environment: WebLogic 10.3

Symptoms
Parsing xml in a standalone mode (out of weblogic 10.3 container) but app has dependency on weblogic.jar file.

If you are trying to run an application (say test case) in standalone mode (ie outside Weblogic container) and you have a dependency on weblogic.jar file, xml parsing might end up throwing the NoClassDefFoundError: weblogic.util.NestedUtilException (For eg loading log4j.xml via DOMConfigurator).

WebLogic has a RegistryXmlParserDocumentBuilderFactory class which may come in between the classpath if you are trying to parse an xml. This in turn depends on several other weblogic modules, not all of which will be in classpath. So you end up getting the NestedUtilException which gobbles up the actual error.

Solution:
Set the -Djava.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl value in the jvm arguments.