I am trying to test a (Spring-based) WAR I just wrote and am deploying it to TOMCAT_HOME/webapps/ and then starting tomcat. After a minute or so it is obvious the WAR is not running (because it should be consuming messages off an ActiveMQ queue…and its not). I look at the standard output from the console and see:
INFO: Deploying web application archive Optimizer.war
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
23 [Thread-2] INFO org.apache.camel.spring.handler.CamelNamespaceHandler - OSGi environment not detected.
Jan 19, 2012 10:54:20 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Jan 19, 2012 10:54:20 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [184] milliseconds.
Jan 19, 2012 10:54:20 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/Optimizer] startup failed due to previous errors
Here is my log4j.properties file:
log4j.rootLogger=INFO
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%c] [%t] (%F:%L) %-5p %c %x - %m%n
log4j.logger.org.milyn=INFO
log4j.logger.org.exolab.castor=INFO
log4j.logger.org.castor.core=INFO
log4j.logger.org.apache.commons.digester=INFO
log4j.logger.org.apache=INFO
log4j.logger.org.springframework=INFO
log4j.logger.com.ibatis=INFO
log4j.logger.java.sql.Connection=INFO
log4j.logger.java.sql.PreparedStatement=INFO
log4j.logger.java.sql.ResultSet=INFO
log4j.logger.java.sql.Statement=INFO
And here is my web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns /j2ee/web-app_2_4.xsd"
version="2.4">
<!-- The display name of this web application -->
<display-name>Optimizer</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/optimizer-config.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
For one I’d like to know how to make my app/Tomcat more verbose so I can see what’s really going on here (and please note, the Tomcat console and corresponding catalina.log are the only sources I have for debugging… can’t run this from Eclipse workbench because there is no main entry point, just web.xml).
I suspect something is failing in web.xml or perhaps my Spring config file. And I wouldn’t mind debugging my config file if I could just get any sort of indication in the logs/error messages as to what is preventing my app from starting up.
Any ideas/hints/suggestions as to start the process of figuring out whats going wrong are enormously appreciated! Thanks in advance!
You can actually run the entire application from within your IDE if you want, instead of launching Tomcat externally. However, you then run into the issue that you are to working off your war file, but rather from your .class files (compiled in your workspace). Additionally, you are not testing if Tomcat is causing any deployment errors either.
I don’t remember offhand what the Tomcat error file is, but there are other log files you can check out in the tomcat/log directory as well that will provide with a little additional information.
To launch Tomcat in eclispe, you need to create a new Java runtime configuration.
Specify main class as
org.apache.catalina.startup.BootstrapProgram Arguments: [-config ] start
VM Args: as you see fit, but perhaps -Xmx512m, etc…
Working Directory (I usually point to the Tomcat/work directory, if memory serves).
You will also need to add the Tomcat jars (found in tomcat/lib and tomcat/bin) to the classpath under Bootstrap entries).
Once you do that, you should be able to launch tomcat as a java app from within Eclipse, and then you can actually debug step by step the exact process.
NOTE: I’m providing this config information from memory. I don’t remember the exactly path for workspace.