views:

949

answers:

5

I have a Spring/Hibernate application which I have converted into a web application in order to provide RESTful web services (using Jersey). I am trying to deploy the web application onto Tomcat 6.0.20 and I get only a cryptic error message in the log file:

Jul 8, 2009 2:25:22 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Jul 8, 2009 2:25:22 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/lmrest] startup failed due to previous errors

I have set my logging level to debug but there are no suspicious messages which show what went awry, other than this one, which looks pretty innocuous to me:

1360 [http-8080-1] INFO  org.hibernate.cfg.search.HibernateSearchEventListenerRegister  - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.

I am using the latest versions of Spring and Hibernate. I am using a ContextLoaderListener in my web.xml. Could this be the listener that is failing to start? I assume it is running at least partially since I can see many Hibernate configuration log messages scroll past before the failure of the start of the web app. My main trouble is I can't see any error messages indicating what has failed to start the listener it's complaining about.

The web.xml I'm using looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;

    <!-- listener to pull in the Spring application context -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:appContext.xml</param-value>
    </context-param>

    <!-- Jersey servlet container to intercept all URIs -->
    <servlet>
        <servlet-name>JerseyContainer</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>JerseyContainer</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

If anyone can give me some ideas as to where to look for my error I'll really appreciate it, as I'm stumped. Thanks in advance!

--James

A: 

Are there any errors further up in the log (at an earlier point in time)? That's not much to go off of (though I wouldn't be surprised if that's it).

Jon
Unfortunately that's the only thing that jumps out as an error, even though it's listed as an INFO level log message. Almost all of the DEBUG messages involve Hibernate annotation binding, all of which appear to be reporting a successful operation.
James Adams
+1  A: 

Check your log4j.properties or log4j.xml and make sure your logging level is set to DEBUG

Gandalf
Yes, as stated above I have done this, but unfortunately there is no error to be seen other than the previously mentioned INFO message which indicates that the FullTextIndexEventListener class can't be found on the classpath. However in the WAR I can see the following Hibernate JARs in WEB-INF/lib:hibernate-3.2.6.ga.jarhibernate-annotations-3.4.0.GA.jarhibernate-commons-annotations-3.1.0.GA.jarhibernate-core-3.3.0.SP1.jarhibernate-validator-3.0.0.ga.jar
James Adams
It's interesting that when I search for the FullTextIndexEventListener class I find it in hibernate-annotations-3.2.1.ga.jar, but in my pom.xml (and in the resulting WAR artifact) I have a later version of that dependency (version 3.4.0.GA). Maybe there's some backwards compatibility issues, i.e. that class is no longer present in the newer version?
James Adams
A: 

Apache can't find class org.hibernate.cfg.search.HibernateSearchEventListenerRegister. Are you sure that all classes needed to start hibernate are loaded in classpath? Hibernate is divided into many .jar package, I suggest you to check dependencies beetween files .jar

tommaso
And if you were using maven you wouldn't need to do much for managing the dependencies since that's one of the things maven is famous for.
lumpynose
Yes, I am using Maven. It's curious that this Spring application context starts up fine when I run it at the command line (packaged as a JAR) but when it's deployed in Tomcat (packaged as a WAR) it fails at some point. If the application context is valid when called from within a main class, via 'new ClassPathXmlApplicationContext("appContext.xml")' then shouldn't it behave the same when it's started by Tomcat via the ContextLoaderListener and a contextConfigLocation parameter which uses the same exact application context XML?
James Adams
Maybe there's some difference between how Maven organizes classes in JAR and WAR artifacts which is causing this issue? I am using the shade plugin in order to include all dependency JARs in the final artifact, and when I package the application as a JAR I see the actual class files of the dependencies included in the JAR whereas when I package the application as a WAR I instead see the dependency JARs included under WEB-INF/lib. Is it possible that this is causing some sort of ill effect? Am I assuming too much thinking that my orig app context XML file should work just as well in Tomcat?
James Adams
+2  A: 

Please do the following:

  • remove all log4j related artifacts from your war file - includes log4j.jar/properties/xml;
  • include log4j.jar in common/lib or lib ( depending on your Tomcat version );
  • add a log4j.properties file in common/classes ( not sure on Tomcat 6 ).

This config should make sure that all log4j output is properly directed. Switch to debug if needed, but it should not be:

log4j.rootLogger=info, R 

log4j.appender.R=org.apache.log4j.RollingFileAppender 
log4j.appender.R.File=${catalina.home}/logs/catalina.out 
log4j.appender.R.MaxFileSize=10MB 
log4j.appender.R.MaxBackupIndex=10 
log4j.appender.R.layout=org.apache.log4j.PatternLayout 
log4j.appender.R.layout.ConversionPattern=%d %p %t %c - %m%n
Robert Munteanu
this one worked for me. At least it helps you to find the real cause!Thanks Robert!
Brian Clozel
thank you, thank you. I was pulling my hair out on this one.
Don Branson
A: 

Here is a similar discussion at the SprinSource forums. Since the applicationContext.xml works with a standard JAR, this is most probably a classpath problem. Double check the WEB-INF/lib folder and make sure there aren't conflicting jars in Tomcat's shared folder.

kgiannakakis