Previous Topic: Finalize the SiteMinder WSS Agent for WebLogic InstallationNext Topic: CA SiteMinder WSS Agent for IBM WebSphere Guide


Troubleshoot Issues Related to Protected Web Services Making Use of Apache Commons Logging and Log4j

Because the SiteMinder WSS Agent for WebLogic implements logging using the Apache Commons Logging and Apache log4j packages, class loading problems can occur if protected web service applications also use the Commons Logging and log4j packages.

Commons Logging Classl Loading Problem

Symptom:

The SiteMinder WSS Agent for WebLogic uses the Apache Commons Logging package as part of its logging implementation. Class loading conflicts can occur when the SiteMinder WSS Agent is configured to protect web services that also use Commons Logging if the web service and SiteMinder WSS Agent are not using the same version of Commons Logging.

If such a class loading conflict is occurring, WebLogic may log an error output similar to the following during initialization:

<Sep 16, 2009 9:15:54 AM EDT> <Error> <HTTP> <BEA-101216> <Servlet: "ServicesServlethttp"
failed to preload on startup in Web application: "XXXXXX.war".
java.lang.ExceptionInInitializerError
….
org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfig
urationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.) (Caused by org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.))
        at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
….

Solution:

To remove class loading conflicts between the SiteMinder WSS Agent and protected web service, verify that the web service uses the same version of the Apache Commons Logging jar file (commons-logging.jar) as the SiteMinder WSS Agent (version 1.1.1). If the web service is not using the same version, replace the commons-logging.jar used by the web service with the 1.1.1 version.

log4j Conflict Problems

Symptom:

The SiteMinder WSS 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 SiteMinder WSS 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: StockTradeDemoDCC@StockTradeDemoDCC.war].
log4j:ERROR Could not instantiate appender named "CUSTOMER_APPENDER_NAME".

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

Solution:

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

Follow these steps:

  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 SiteMinder WSS Agent log4j.jar to prevent it from being loaded:
    1. Navigate to WSS_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 WSS_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