debugging – JGuru https://jguru.fi When you need a guru Sat, 24 Jan 2015 12:35:56 +0000 en-US hourly 1 https://jguru.fi/wp-content/uploads/2015/01/javaguru_icon-54c89537v1_site_icon-32x32.png debugging – JGuru https://jguru.fi 32 32 83852845 What to Do When You Get “Error listerStart” with Tomcat https://jguru.fi/what-to-do-when-you-get-error-listerstart-with-tomcat.html?utm_source=rss&utm_medium=rss&utm_campaign=what-to-do-when-you-get-error-listerstart-with-tomcat https://jguru.fi/what-to-do-when-you-get-error-listerstart-with-tomcat.html#comments Tue, 29 May 2012 13:58:41 +0000 http://javaguru.fi/?p=20 I’m sure many people other than me have banged their head in the wall trying to figure out an error like this:

SEVERE: Error listenerStart 
26-May-2012 13:44:27 org.apache.catalina.core.StandardContext startInternal 
SEVERE: Context [] startup failed due to previous errors

That basically means that tomcat failed to start the webapp because there was an error with some listener, quite often Spring context listener. The really annoying part is that it doesn’t actually show you what went wrong. There’s actually pretty simple way to get tomcat to log the actual error. You just need to create a logging.properties in WEB-INF/classes of the failing webapp and add following lines to it:

org.apache.catalina.core.ContainerBase.[Catalina].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler

Then just reload the webapp to see the error in tomcat console log. I hope this tip saves you a lot of hasle from trying to figure out the root cause of the problem.

]]>
https://jguru.fi/what-to-do-when-you-get-error-listerstart-with-tomcat.html/feed 1 20
Debugging Maven Plugins https://jguru.fi/debugging-maven-plugins.html?utm_source=rss&utm_medium=rss&utm_campaign=debugging-maven-plugins https://jguru.fi/debugging-maven-plugins.html#respond Sun, 27 May 2012 08:49:52 +0000 http://javaguru.fi/?p=24 When developing maven plugins things don’t always work the way you expect so you need to debug the Mojo to see what’s really going on. I had a weird case where my plugin worked when I ran it independently but when I ran it with mvn clean package it always failed. First thing you can do is run in debug mode which produces a lot more output and shows all the plugin execution configuration. You can enable it with -X argument like this:

mvn -X clean package

Now that didn’t quite help with my case so next thing I did was to run it with remote debugger. That way I could step through the code line by line and inspect all the variables. To do that you just modify the MAVEN_OPTS environment variable in the shell where you are executing you maven plugin and add java debugger agentlib config like this:

MAVEN_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y"

I used suspend=y so that it would wait for my debugger to attach before continuing the execution. Then you just add some breakpoints in you IDE and remote debug it like any java application. That by the way solved my issue as I realized each of my Liferay maven plugins were initialing Liferay configuration but since they were all run after each other in the same context only the first one mattered.

]]>
https://jguru.fi/debugging-maven-plugins.html/feed 0 24