Tomcat7/Jackson/WebApp deployment crash/-Collection of common programming errors
I’m trying to deploy a new version of my web app on a Ubuntu server (12.04) running Tomcat 7.0.26. Rather than include the jackson- libraries that I use (-core
, -annotations
, and -databind
), I’m trying to place them in the /usr/share/tomcat7/lib
area for use by other applications that I plan to deploy.
I can start the server, and deploy my app. However, once I do, the app crashes and takes down Tomcat. Clearly the ObjectMapper is not being properly loaded, but it exists in the databind jar file (I’ve jar tvf’d it to check)…
The response to the client is:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:679)
And, the catalina.out log file shows the following after the app is executed:
Mar 11, 2013 1:42:55 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Mar 11, 2013 1:42:55 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Mar 11, 2013 1:42:57 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Mar 11, 2013 1:42:57 AM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already. Could not load com.fasterxml.jackson.databind.ObjectMapper. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1587)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
at org.comtor.authserv.APIServer.doPost(APIServer.java:150)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
Mar 11, 2013 1:42:57 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Any help here is appreciated. I’m attempting to learn what is going wrong, how I can prevent it, and also prevent the server from going down (crashing) when the web application is executed and this happens.
Thanks.
-
I had a similar issue with the Jersey REST libraries. It turned out that Tomcat was crashing my app because there was a version conflict between some jars I included in my WAR file and jars I had moved to Tomcat’s lib folder.
I recommend that you troubleshoot this on a local development machine first because it is quicker and easier to move jar files around. Start with just the libraries Tomcat comes with and all of your required libraries packed into your war file. Your app should run fine. Then move jar files from your app to Tomcat lib. You can do this without re-building your app. Just open your war file with an unzip utility like 7-zip and delete the files from your war file as you move them to Tomcat/lib. You probably need to restart Tomcat every time but I found it didn’t take me long to get a working configuration this way. Now my war file is only 735KB instead of 8MB, which matters to me because I’m working with a slow upload speed.