Sometimes Tomcat (or TomEE) doesn’t start saying something like:
SEVERE: Skipped installing application listeners due to previous error(s) Nov 26, 2012 9:22:46 AM org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerStart Nov 26, 2012 9:22:46 AM org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/demo] startup failed due to previous errors
So great our code doesn’t work…but we don’t know why. Since that’s often while the class is instantiated that’s hard to debug your own code.
If you are not afraid of tomcat code just debug listenerStart() method of StandardContext (add tomcat-catalina as dependency).
If you are more lazy you should find (if you kept the default settings) the error in logs/localhost*.log file.
So ok we got the reason why it failed but that’s not so easy. In development a lot of developpers (I’m part of them) like to get the logs in the console (avoid yet another tab to tail the logs).
To get these logs by default in the console just update the following line from conf/logging.properties:
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler
to
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler,java.util.logging.ConsoleHandler
I personnally use the following logging.properties (the complete file!) to avoid any log file (in dev):
handlers = java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level = FINE java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
Want more content ? Keep up-to-date on my new blog
Or stay in touch on twitter @rmannibucau
When there are multiple versions of jar in the maven repository,got this issue.Leaving a single version help to remove this issue.
yes the exception should be a ClassCastException or NoSuchMethodError or something like that for embedded case, for standalone case maven repo is not used normally