Tuesday, January 08, 2008

Commons Logging and IBM WebSphere 6.1

RSA 7.0.0.3/WAS 6.1.

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.LogFactoryImpl
org.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:

Set application classloader mode as PARENT_LAST. 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.

Wednesday, January 02, 2008

This project needs to migrate WTP metadata

Hello There, I had exactly the same error message and none of the above fixes worked. The problem I found were the following
1) The runtime the old code is still pointing to is WAS 6.0 not WAS 6.1 (in RAD7)
2) RAD7 has more options to change more settings

The Solution: I had to fix the problem on the WAR file that is used by the EAR file Following is my fix for the problem in RAD7 PART I with the WAR PROJECT
\---------------------------
1) Right click on the war project and click on properties.
2) Click on Targeted Runtimes in the properties
3) Now check your desired Runtime WebSphere Application Server 6.1
4) Now click on the WebSphere Application Server 6.1 Runtime in the same window
5) You will see under Runtime Composition com.ibm.ws.ast.st.runtime.61 JRE 5.0: WebSphere v61 JRE
6) Now click on Add/Remove Project Facets link in the same window
7) It opens a new windows Project Facets. This page has dependencies when checking the boxes. Therefore...
8) Here First check Java, I selected the version 5.0.
9) Then check Dynamic Web Module (as I am using web module), I selected 2.4
10) Then check WebSphere Web (coexistence) 6.1
11) Then check WebSphere Web (Extended) 6.1
12) Click Finish
13) Click OK in the properties window
14) Now again open the same properties window
15) You will see new types on the Left Hand Side(LHS) windows namely J2EE Module Dependencies.
16) Click J2EE Module Dependencies. Select from the drop down the EAR file name that should have this WAR file
17) Click Java Build Path on the LHS window.
18) Make sure you see WebSphere Application Server v6.1 under your libraries tab on the Right Hand Side(RHS) window.
19) Click on Project Facets and make sure you see the 4 facets namely Dynamic Web Module, Java, WebSphere Web (Co-existence) and WebSphere Web (Extended) listed with the correct values.
20) Click on the Server on the LHS window.
21) Make sure you see the WebSphere Application Server v6.1 selected on the RHS window. If not, select it.
22) Click on Targeted Runtimes. Mostly you should see this time only WebSphere Application Server v6.1
23) Click OK
24) Manually Refresh and Rebuild this project.

PART II with the EAR project
\----------------------------
1) Right click on the EAR project and click properties
2) Click J2EE module dependencies.
3) Make sure desired xxxxxx.war file is checked.
4) Click on Targeted Runtimes.
5) Make sure you have WebSphere Application server 6.1 is checked
6) Click on project Facets
7) Make sure you have EAR 1.4, WebSphere Web (coexistence) 6.1, WebSphere Web (Extended) 6.1 are selected. If not, go to step 5 and click on the add/remove proejct facets link to do it.
8) click on server and check WebSphere Application Server v6.1
9) Manually Refresh and Rebuild this project.

You should be all set. All the best.