Thursday, April 9, 2009

JBI and Apache Service Mix

Excellent Video at

http://parleys.com/display/PARLEYS/Home#slide=1;title=ServiceMix;talk=14123079

WAS 6.1 issue with log4J

Apache Commons Logging has a problem with WAS 6.1. Its Log4JLogger either can't be loaded or be reported not compatible with LogFactory.The root cause is WebSphere uses commons-logging and so it's in the root classloader. In addition, WebSphere ships a commons-logging.properties with the following properties set:

org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImplorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger

Therefore by default the application will use JDK logging and not log4j.

The solution is to ensure that the right classloader mode is set and the application has an appropriate commons-logging.properties:

1. Set application classloader mode as PARENT_LAST.
2. Also, add a commons-logging.properties to the application classpath with the following entries:

priority=1
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl

The priority flag was introduced in Commons Logging 1.1 to allow an ordering based on priority.

To ensure that an application's commons-logging.properties will take precedence over WebSphere's file, a priority of greater that 0.0 must be set.