Oracle application server deployed application throwing an error - NoClassDefFoundError

1.3k views Asked by At

We have deployed our web application deployed on oracle applications server 10 and we encounter this error when running the application.

 Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category

 Caused by: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@12badee for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category)

We have log4j bundled inside our webapp WEBINF/lib and we have a shared lib for log4j in our application server lib as well. Since this shared lib is shared by many applications we can't remove it.

I understand that there is some class conflict in between these 2 log4j libs. Is there anyway that we can exclude this shared lib and work with the bundled log4j inside the web application? any help on this regard is highly appreciated.

2

There are 2 answers

0
Viccari On BEST ANSWER

Use the prefer-web-inf-classes element in your weblogic.xml application descriptor.
According to the documentation,

Setting this element to True subverts the classloader delegation model so that class definitions from the Web application are loaded in preference to class definitions in higher-level classloaders. This allows a Web application to use its own version of a third-party class, which might also be part of WebLogic Server.

This is a related question which might help you as well.

0
cirovladimir On

@Viccari I was looking for this same thing but for an old Application Server with OC4J. The solution would be to add a WEB-INF/orion-web.xml with the following contents

<orion-web-app ...>
  ...
  <web-app-class-loader search-local-classes-first="true"
   include-war-manifest-class-path="true" />
  ...
</orion-web-app>

Since I was deploying the application through the Enterprise Manager Console, the above solution didn't work. You must configure class loading in deployment settings on it, disabling the "Inherit parent application's shared library imports" option.

Another option is creating an EAR with a META-INF/orion-application.xml file with the following contents and deploy that

<?xml version="1.0" encoding="UTF-8"?>
<orion-application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-application-10_0.xsd"
    deployment-version="10.1.3.4.0" default-data-source="jdbc/OracleDS"
    component-classification="external" schema-major-version="10"
    schema-minor-version="0">

    <imported-shared-libraries>
        <remove-inherited name="*"></remove-inherited>
    </imported-shared-libraries>

</orion-application>