How to resolve a log4j class loading problem related to protected web services making use of Apache Log4j
search cancel

How to resolve a log4j class loading problem related to protected web services making use of Apache Log4j

book

Article ID: 22668

calendar_today

Updated On:

Products

CA Single Sign On Secure Proxy Server (SiteMinder) CA Single Sign On SOA Security Manager (SiteMinder) CA Single Sign-On

Issue/Introduction

Problem:

The SOA Agent for WebLogic uses the Apache log4j package to produce logging output. This can lead to class loading and logging output conflict problems when the SOA Agent is configured to protect web services that also use the log4j package.

If such a conflict is occurring WebLogic logs error output similar to the following:

log4j:ERROR A "org.apache.log4j.DailyRollingFileAppender" object is not assignable to a "o
rg.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [java.net.URLClassLoader@d8116d] whereas object of type
log4j:ERROR "org.apache.log4j.DailyRollingFileAppender" was loaded by [weblogic.utils.clas
sloaders.ChangeAwareClassLoader@10abd60 finder: weblogic.utils.classloaders.CodeGenClassFinder@5e33d4 annotation: [email protected]].
log4j:ERROR Could not instantiate appender named "CUSTOMER_APPENDER_NAME".

 

Environment

Release: SOASA199000-12.1-SOA Security Manager-w/ SOA Agent Addl CPUs
Component:

Resolution

Cause:

This error is caused by the web service class loader loading the specific Appender implementation class: DailyRollingFileAppender and the SOA Agent class loader loading the Appender interface class.

Resolution:

Configure the system class loader to load the log4j jar instead of the SOA Agent and web service class loaders by adding log4j.jar to the JVM classpath.

To configure the system class loader to load the log4j package

  1. Add WLS_HOME/weblogicXY/server/lib/log4j.jar to the classpath variable passed into the Java Virtual Machine at startup.

    For a WebLogic Server running as a command line application, make this change by editing the startWeblogic.cmd (Windows) or startWeblogic.sh (UNIX) script located in WLS_HOME/user_projects/domains/your_domain/bin.

  2. Rename the SOA Agent log4j.jar to prevent it from being loaded:

    1. Navigate to SOA_HOME/wlsagent/lib/thirdparty.

    2. Rename log4j.jar to log4j.jar_hidden.

  3. For each protected web service that also uses the log4j package, rename log4j.jar to prevent it from being loaded:

    1. Navigate to the directory that contains the log4j.jar file used by the web service.

    2. Rename log4j.jar to log4j.jar_hidden.

  4. Modify the XML message processing logging configuration:

    1. Navigate to SOA_HOME/wlsagent/config

    2. Open the log.config file in text editor.

    3. Locate the line that defines the log4j.category.com.netegrity.tm parameter. For example:

      log4j.category.com.netegrity.tm=DEBUG

    4. Append an explicit reference to the Message Processing Appender also declared in the log.config file. For example, if the name of the Daily Rolling File Appender is "A2", the log4j.category.com.netegrity.tm parameter definition line becomes:

      log4j.category.com.netegrity.tm=DEBUG, A2