Why my TomEE/Tomcat doesn’t start because of listener?


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

 

Advertisements

2 thoughts on “Why my TomEE/Tomcat doesn’t start because of listener?

  1. Sunitha

    When there are multiple versions of jar in the maven repository,got this issue.Leaving a single version help to remove this issue.

    Reply
    1. rmannibucau Post author

      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

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s