Skip navigation.
Home

Integrating Jakarta Commons Logging (JCL) with WSAD 5.1.2

I had forgotten what a pain it is to get WSAD to use the commons-logging framework the way that I want it to...

In typical IBM fashion, WSAD has bundled a version of a third party library and crippled its configurability/useability. In this case, the default console logger for WSAD uses a prebuilt commons-logging jar that uses com.ibm.ws.commons.logging.TrLogFactory as the log factory.

This means that you won't be able to use any of the loggers for which commons-logging is already setup. (e.g. Log4J, jdk14) This presents a problem for lots of open-source applications that have already been built not using the WSAD LogFactory (which is probably every single one).

IBM has published a document which descibes a bunch of different ways to get around the limitation. It is attached below as well.

I like to use the option that:

  1. Create commons-logging.properties file in WEB-INF/classes or at the root of a $SRC folder (so that it gets compiled into WEB-INF/classes
  2. Switch the classloader mode to PARENT_LAST for the WAR only (not the application level).

This way I'm only affecting the particular WAR I'm interested in. If I ever use EJBs, I would probably move it to a dependent jar.


Matt, I tried steps

Matt,

I tried steps suggested by you for Integrating Jakarta Commons Logging (JCL) with WSAD 5.1.2, but when i set the classloader mode to PARENT_LAST for the WAR, my servlets are not loading can you please help me.

Thanks

Veena

Matt Fleming's picture

Sorry!

I have been so busy at work, I haven't checked up on things. If you are still out there please post the error message.. If it is a dependent jar classpath thing make sure your META-INF/manifest entries in the WAR are checked properly.

-Matt

Matt Fleming's picture

Emailing

Hopefully I setup the emailing in php correctly, so that I will get notified if someone posts a comment. We'll see Eye-wink

-Matt

Got Error

Matt,

We have a servlet which loads on startup. After setting the classloader mode to PARENT_LAST for the WAR, I am getting the following error at the time of starting the server.

[8/21/06 15:16:03:863 IST] 3e25bbcd WebGroup E SRVE0020E: [Servlet Error]-[APSLLogInitServlet]: Failed to load servlet: java.lang.ClassCastException: com.honeywell.apsl.web.action.load.APSLLogInitServlet
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadServlet(WebAppServletManager.java:188)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadAutoLoadServlets(WebAppServletManager.java:542)
at com.ibm.ws.webcontainer.webapp.WebApp.loadServletManager(WebApp.java:1277)
at com.ibm.ws.webcontainer.webapp.WebApp.init(WebApp.java:283)
at com.ibm.ws.webcontainer.srt.WebGroup.loadWebApp(WebGroup.java:387)
at com.ibm.ws.webcontainer.srt.WebGroup.init(WebGroup.java:209)
at com.ibm.ws.webcontainer.WebContainer.addWebApplication(WebContainer.java:1005)
at com.ibm.ws.runtime.component.WebContainerImpl.install(WebContainerImpl.java:136)
at com.ibm.ws.runtime.component.WebContainerImpl.start(WebContainerImpl.java:356)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:505)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:808)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:354)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:578)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:299)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:256)
at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
at com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:128)
at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:183)
at com.ibm.ws.runtime.WsServer.start(WsServer.java:128)
at com.ibm.ws.runtime.WsServer.main(WsServer.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
at java.lang.reflect.Method.invoke(Method.java:386)
at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:105)
at com.ibm.etools.websphere.tools.runner.api.ServerRunnerV5$1.run(ServerRunnerV5.java:97)

Thanks

Veena G

Matt Fleming's picture

Since all you have changed

Since all you have changed is which dependent jars have been loaded prior to your web app starting, I think you should start looking there. What jars is the APSLLogInitServlet dependent upon? In order to compile, the jar needs to exist in the project classpath or a dependent project's classpath. For it to work in runtime, the jar either needs to be in the WAR's lib directory and/or in the WAR's manifest.

The ClassCastException is a little unexpected, but I don't know what the code looks like around the APSLLogInitServlet code. I think it is a red-herring though if all you have changed is the Classloader mode. You could also try one of the other three solutions in the document.. doing a different one might trigger an aha moment for you about the solution you are trying now.

-Matt

Albert

Is anybody here i do not see anyone

Matt Fleming's picture

Yep

I'm here