aspose file tools*
The moose likes Websphere and the fly likes Websphere 6.1 - Apache commons logging with log4j does not work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Websphere 6.1 - Apache commons logging with log4j does not work" Watch "Websphere 6.1 - Apache commons logging with log4j does not work" New topic
Author

Websphere 6.1 - Apache commons logging with log4j does not work

sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear All,
I have an existing application which is succesffully running in WAS 5.1 and WASD.We have migrated the appliication in WAS 6.1 and RAD 7.0.
While deployed successfuly the code in WAS 6.1 and RAD 7.0 and start the server we are facing the same type of error in the console.



Could you please suggest me should Log4j(log4j-1.2.9.jar) compatible with Websphere 6.1 or we need higher version log4j jar for WAS 6.1.

Please suggest.

Thanks in advance.
Regards
Sumanta Panda
sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear All,
I wanted to know whether this version Log4j(log4j-1.2.9.jar) will still work on WAS6.1 or we will have to upgrade to later version on log4j?

Please suggest.

Thanks for your time.

Regards
Sumanta Panda
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Well, the class isn't even being found! It doesn't matter which version you use if it can't find the class.

You' probably have a classloader issue.

Understanding WebSphere and Classloader Issues

Find the code that is causing the problem, and try and invoke the logger programatically and see if it still can't be found.

-Cameron McKenzie
sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear Cameron,
Thanks for your response.
Could you please suggest me how to fix this error?

Thanks for your time.

Regards
Sumanta Panda
Don Andrews Ne
Greenhorn

Joined: May 01, 2009
Posts: 4
Your best bet is probably to include it in the enterprise application or web application you're working with. That way it won't interfere with other applications and you'll have better control over the logging options.
sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear All,
Our log4j.properties file is not properly loaded in the server .So we are getting the error java.lang.ds
NoClassDefFoundError: org.apache.log4j.Logger


Please suggest me how to fix this error.

Thanks in advance.
Regards,
Sumanta Panda
udo online
Greenhorn

Joined: Sep 04, 2009
Posts: 1
sumanta panda wrote: ... So we are getting the error
java.lang.NoClassDefFoundError: org.apache.log4j.Logger


The Problem is that WAS6.1.0.19 uses commons-logging-1.0.3 .
commons-logging-1.1.1 raises this exception in bundle with log4j.

This (solution) replacement of commons-logging via jcl-over-slf4j works very well . I tested it successfully yesterday.

--
MfG. udoline
Nischit Shetty
Greenhorn

Joined: Feb 21, 2007
Posts: 25
I am sorry that I am replying to one of the oldest thread. Long time back I had found a solution in another forum. Wish I could recall and paste that link.

I have tested the solution provided by them on Websphere 6.1 and websphere 7 and it works.

1) No need to have commons-logging.properties in the classpath. No need to change the class loading policy to PARENT_LAST.
2) Under META-INF/services, create a file by name "org.apache.commons.logging.LogFactory". The content of file should be just "org.apache.commons.logging.impl.Log4jFactory"
3) Now comes the most important part. Websphere 6.1 and 7.0 still uses apache-commons-logging "1.0.3" version.
a) In Websphere 6.1, go to <WEBSPHERE INSTALLED FOLDER>/plugins and open the jar "com.ibm.ws.runtime_6.1.0.jar". It contains the commons logging file
b) Download apache commons logging 1.0.3 version from its archived website. Open the downloaded jar. When you compare the contents with the jar file of Websphere you will find that the downloaded version of apache commons logging has the below extra files
- org.apache.commons.logging.impl.Log4JCategoryLog.class
- org.apache.commons.logging.impl.Log4jFactory.class
- org.apache.commons.logging.impl.Log4JLogger.class
- org.apache.commons.logging.impl.LogKitLogger.class
All other files are common files in both websphere and apache library.
c) Now from the downloaded apache commons logging jar, delete the common files. Only retain the above mentioned file. Once you are done, you will basically have a stripped version of apache commons logging 1.0.3. Put this stripped jar in WEB-INF/lib
d) You are all set, restart the server.
4) In Websphere 7.0, the apache commons logging can be found at <WEBSPHERE INSTALLED FOLDER>/plugins/com.ibm.ws.prereq.commons-logging.jar. All other activities will be similar to the one explained above
5) With this approach, we are not changing core library file of Websphere. Neither we are changing the class loading policies.

As I mentioned above, this solution was found in some forum which I am unable to recall. I have basically tried to provide as much information as I can. I had done the above activities in one of my previous project and was successful.
 
jQuery in Action, 2nd edition
 
subject: Websphere 6.1 - Apache commons logging with log4j does not work