Tuesday, February 25, 2014

WAS Admin Console login error: ExceptionInInitializerError

Issue: Attempting to log into the Administration Console on my local WebSphere 7 server, I received a java.lang.ExceptionInInitializerError error message. This was caused by ClassNotFoundException: org.apache.commons.logging.impl.Log4JLogger.

Resolution: I added the commons-logging.jar to a WAS directory.

More Details:
IDE + Server: Rational Application Developer (RAD)(based on Eclipse), with WebSphere Application Server (WAS) 7.
Action Attempted: Right-click on running server, select Administration > Run Administration Console, then log in if needed. I even removed my application (Add/Remove) from the server, but was still getting the error after logging in.

Error Message:
Error Page Exception
SRVE0260E: The server cannot use the error page specified for your application to handle the Original Exception printed below.

Original Exception: 
Error Message: java.lang.Exception: java.lang.ExceptionInInitializerError
Error Code: 500
Target Servlet: action
Error Stack: 
java.lang.Exception: java.lang.ExceptionInInitializerError 
     at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadServlet(ServletWrapper.java:1987) 
     at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:731) 
     at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:503) 
     at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181) 
     at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:372) 
     at com.ibm.ws.webcontainer.servlet.FilterProxyServlet.dispatch(FilterProxyServlet.java:88) 
     at com.ibm.ws.webcontainer.servlet.FilterProxyServlet.service(FilterProxyServlet.java:62) 
     at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1658) 
     at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1598) 
     at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:149) 
     at com.ibm.ws.console.core.servlet.WSCUrlFilter.setUpCommandAssistence(WSCUrlFilter.java:961) 
     at com.ibm.ws.console.core.servlet.WSCUrlFilter.continueStoringTaskState(WSCUrlFilter.java:500) 
     at com.ibm.ws.console.core.servlet.WSCUrlFilter.doFilter(WSCUrlFilter.java:321) 
     at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190) 
     at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:125) 
     at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:80) 
     at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:908) 
     at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:997) 
     at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:1078) 
     at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:775) 
     at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3954) 
     at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276) 
     at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:942) 
     at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592) 
     at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186) 
     at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:453) 
     at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515) 
     at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:306) 
     at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83) 
     at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784) 
     at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165) 
     at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) 
     at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) 
     at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) 
     at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) 
     at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) 
     at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) 
     at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1646) 
     Caused by: java.lang.ExceptionInInitializerError 
     at java.lang.J9VMInternals.initialize(J9VMInternals.java:222) 
     at java.lang.Class.forNameImpl(Native Method) 
     at java.lang.Class.forName(Class.java:217) 
     at java.beans.Beans.instantiate(Beans.java:189) 
     at java.beans.Beans.instantiate(Beans.java:80) 
     at com.ibm.ws.webcontainer.servlet.ServletWrapper$1.run(ServletWrapper.java:1918) 
     at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118) 
     at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadServlet(ServletWrapper.java:1909) 
     ... 37 more 
     Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JLogger 
     at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:532) 
     at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:272) 
     at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:246) 
     at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:395) 
     at org.apache.struts.action.ActionServlet.(Unknown Source) 
     at java.lang.J9VMInternals.initializeImpl(Native Method) 
     at java.lang.J9VMInternals.initialize(J9VMInternals.java:200) 
     ... 44 more 
     Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JLogger 
     at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:416) 
     at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:525) 
     ... 50 more 
     Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JLogger 
     at java.lang.Class.forName(Class.java:184) 
     at org.apache.commons.logging.impl.LogFactoryImpl$1.run(LogFactoryImpl.java:466) 
     at java.security.AccessController.doPrivileged(AccessController.java:228) 
     at org.apache.commons.logging.impl.LogFactoryImpl.loadClass(LogFactoryImpl.java:454) 
     at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:406) 
     ... 51 more 

So the key is, WAS seems to be looking for Log4JLogger class. A quick search shows that class is in the commons-logging.jar file. My Java application compiles and runs fine, but for some reason WAS seems to need it and cannot find it.

I looked at the WAS Console output after startup, and saw three entries that could possibly solve my problem:
  • ws.ext.dirs
  • Classpath
  • Java Library path
The Java Library path pointed mostly to /bin/ directories, not exactly a source of jar files.
Classpath pointed to a few specific jars and application-specific property folders.
But ws.ext.dirs seemed to point to libs and classes. Here was my entry, with 'C:\IBMRAD8' being the location of my RAD8 install.
ws.ext.dirs = 
C:\IBMRAD8\runtimes\base_v7/java/lib;
C:\dev\servers\MyAppServer/classes;
C:\IBMRAD8\runtimes\base_v7/classes;
C:\IBMRAD8\runtimes\base_v7/lib;
C:\IBMRAD8\runtimes\base_v7/installedChannels;
C:\IBMRAD8\runtimes\base_v7/lib/ext;
C:\IBMRAD8\runtimes\base_v7/web/help;
C:\IBMRAD8\runtimes\base_v7/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime

Final Resolution:
Adding commons-logging.jar in any of these folders would probably have done the trick. For me, '/base_v7/lib/ext' seemed to make the most sense, and since it was empty, should not affect anything else. I added the jar file there, restarted my WAS server, and successfully logged into the Admin Console.