WLS 10.3.3: Appc doesn't work on ear/lib shared library in order to build an application using ANT. (Doc ID 1196833.1)

Last updated on NOVEMBER 05, 2016

Applies to:

Oracle Weblogic Server - Version 10.3.3 to 10.3.4
Information in this document applies to any platform.
***Checked for relevance on 14-Aug-2013***

Symptoms

On WebLogic 10.3.3, to run appc on an EARs, it is common to use an ANT script with a task similar to this:

<java classname="weblogic.appc" fork="yes" dir="${build}" failonerror="yes" classpathref="compile-classpath">
<jvmarg line="-Xms128M -Xmx256M" />
<arg line="-compiler ${compiler} -classpath ${lib}/commons-logging.jar -verbose -forceGeneration -keepgenerated -iiop -basicclientjar ${dist}/${earfile}"/>
</java>


This should look fairly straightforward except for a couple of properties. Under WebLogic 10.3.3, an EAR's modules are expected to discover shared libraries through the app-inf/lib directory of the EAR.
 
The JEE5 standard says that you can place your shared libraries in the EAR's lib directory. WebLogic respects this at runtime, but does not respect this while running appc.

For example, applications that implement logging using the Apache commons-logging interfaces and use log4j as the underlying logging mechanism and each of these applications use their own unique log4j log file (i.e. output file), each application needs to have its own commons-logging/log4j configuration files (and not what is first picked up on the system classpath). To achieve this ensure that the commons-logging/log4j classes are picked up via the application's classloader, not the system classloader. To ensure this, each application must have a weblogic-application.xml file with the below xml:

<prefer-application-packages>
<package-name>org.apache.*</package-name>
<prefer-application-packages>


Because the ejb-classloader used by appc respects this property in the deployment descriptor, it doesn't pick up the Apache classes as specified in the aforementioned compile-classpath classpathref. Therefore, when attempting to compile an EAR module using ANT, the following error occurs.

Error
- Run ANT:

Buildfile: build.xml

init:
[echo] Using Java Version: 1.6.0_20

cfg-jar:
[jar] Updating jar: \build\lib\aaa.appcdemo.jar

compile:

ejb:
[jar] Updating jar: \build\appcdemo.jar

ear:
<J2EE> <BEA-160186> <Compiling EAR module 'xxxx.swingbase.jar'>
[java] java.lang.NoClassDefFoundError: Class not found: Lorg/apache/commons/logging/Log

Changes

N/A

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms