Considerations
Problem in using Jakarta Commons Logging
If you've added commons-logging.jar in the WEB-INF/lib folder of the contact management application to get rid of a compilation error, you'll get the errors shown in Listing 12 when you try to deploy the application.
An issue WebSphere Application Server Community Edition has with regard to Commons Logging is that you won't be able to use your custom commons-logging configuration in your Web application that you deploy into WebSphere Application Server Community Edition. This is not to say that you can't use the Commons Logging library in your application -- you can. However, you can't configure the logging fashion particular to your own specific application. That means that you can't have commons-logging.jar in your WEB-INF/lib; instead, you should use commons-logging.jar in your WASCE/lib folder. Also, you should change WASCE/var/log/server-logging.properties for specifying logging properties of your application. Note that you're using the Commons Logging API in your contact management application.
Listing 12. Stack trace if you include commons-logging.jar in WEB-INF/lib folder
15:43:24,319 ERROR [[/contact]] Exception sending context
initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener
org.apache.commons.logging.LogConfigurationException:
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.)
(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)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance
(LogFactoryImpl.java:235) |
Follow these steps to configure WebSphere Application Server Community Edition to generate trace information for Spring and your contact management application:
- Remove commons-loggin.jar and log4j.jar from ContactMang application's WEB-INF/lib folder. In the sample application, these two .jar files are included in the lib folder with a compile-time dependency on them. When you use the build.xml file to build the ContactMang application, the resultant .war file won't have these two .jar files in the WEB-INF/lib folder.
- Deploy the ContactMang.war file on the server.
- Open the C:\util\WASCE\var\log\server-log4j.properties file, and
include the two lines shown in Listing 13 in it.
Listing 13. Stack trace if you include commons-logging.jar in WEB-INF/lib folderlog4j.category.org.springframework=DEBUG log4j.category.com.sample=TRACE
Note that server-log4j.properties also contains logging configuration information for the server itself, so if you want to know what's going on inside the server, change the logging level for root logger to
DEBUG, and restart the server. When the server is restarted, open the WASCE/var/log/server.log file to take a look at the log generated by WebSphere Application Server Community Edition, Spring, and the ContactMang application.
Note: You're likely to face a similar problem if you try to include cglib.jar in the WEB-INF/lib folder of your Web application.




