Fork me on GitHub

n. Slang a rough lawless young Kuali developer.
[perhaps variant of Houlihan, Irish surname]
kualiganism n

Blog of an rSmart Java Developer. Full of code examples, solutions, best practices, et al.

Thursday, December 1, 2011

SEVERE: Error listenerStart

Overview

I saw on the rice mailinglist recently someone posted a question where essentially, the application dies before a logger can be initialized. Here is the result:
INFO: Deploying web application archive kr-dev.war
log4j:WARN No appenders could be found for logger (org.kuali.rice.core.web.listener.KualiInitializeListener).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Dec 1, 2011 1:35:19 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Dec 1, 2011 1:35:19 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/kr-dev] startup failed due to previous errors

What has happened here is the listener failed to start. The listener is what starts up the application (in this case, Rice). If Rice does not start, there is no logger to tell you what is wrong. Thus, you get no error. Usually, what causes this is a dependency is not included in tomcat.

So far, I have not seen a case where the problem is caused by anything but a missing library. It is usually the database driver, because that is the only thing not included in the rice war by default. It can possibly be something else though. I have seen KFS not start because of a missing log4j file. Since KFS actually requires the application to deploy additional libraries to the application server before startup, it is the only exceptional case.

Solution

Of course, the solution is to make sure your database driver is in the tomcat/lib folder, right? What if that doesn't do the job? What if it's another library? Read on.

Alternate

Sometimes you need to figure out what library is missing. This is almost never the case. Nearly always it is the database driver that is missing. Almost, right? If this happens and the database driver is loading correctly, then you need to figure out what the problem is. This means consulting the tomcat logger. I am going to assume that you have installed the rice war file in your tomcat installation. The war file is now unpacked and there's a webapp directory somewhere. Within the WEB-INF/classes path of that webapp directory, you can create a logging.properties with the following contents.
org.apache.catalina.core.ContainerBase.[Catalina].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler
Why? The reason is that rice uses commons-logging and log4j while tomcat uses java.util.logging. Essentially, separate things. Also, since Kuali did not start, it did not start the logging configuration. What we can do is add a logging configuration that tomcat will pick up and use when it tries to start Rice. That is essentially what we are doing here.

Now try to restart the server. You should see some kind of NoClassDefFoundError somewhere explaining what library you are missing.

8 comments:

  1. Hi!

    kudos for your prediction skills!

    I had this "Error listenerStart" thingy with no other information whatsoever in the logs; and it was due to the missing mysql connector/J on my production env.

    thanks!

    ReplyDelete
    Replies
    1. Hi

      my connector/J is named "mysql-connector-java-5.1.18-bin.jar"
      in "/WEB-INF/lib" is it correct?

      Delete
    2. Database drivers shouldn't go into your web application's classpath, but rather the tomcat classpath in your tomcat/lib directory.

      Delete
  2. Thanks a lot for the great comment!

    ReplyDelete
    Replies
    1. I am building the new Rice 2.0 release and I ran into this issue. I made sure the database driver was in /usr/local/tomcat/lib/mysql-connector-java-5.1.18-bin.jar

      So I figured I was one of the almost never cases. When I created the logging.properties file and restarted tomcat I got the following error.

      SEVERE: Exception sending context initialized event to listener instance of class org.kuali.rice.core.web.listener.KualiInitializeListener
      org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; n
      ested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]

      applicationContext.xml was not in WEB-INF. Any ideas?
      Is applicationContext.xml supposed to be included in the kr-dev.war?

      Delete
    2. This post to the rice.collab list may be helpful to you. Sounds exactly like what you're going through. https://groups.google.com/a/kuali.org/group/rice.collab/browse_thread/thread/669567a81f46be0d/bb76a205d55701fd?lnk=gst&q=applicationContext.xml#bb76a205d55701fd

      Delete
    3. Thanks for the help. I put the -Dweb.bootstrap.spring.file=classpath:org/kuali/rice/standalone/config/StandaloneSpringBeans.xml
      in CATALINA_OPTS and it got me past this error.

      Delete
  3. Another thing to add, I just had this happen when starting up KFS inside Eclipse following a Rice upgrade (hence the names of the jars changed). The trick here was to do a Refresh following the dist-local.

    ReplyDelete