tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Eggers <>
Subject Re: automatic deployment without server.xml - bad request
Date Wed, 01 Dec 2010 19:37:24 GMT
Short answer:

Please read (carefully), the following documentation:

Longer answer:

1. remove the docBase attribute from your Context

Your docBase would only work if you have a directory 

2. remove the path attribute from your Context

Rename your WAR file to myapp.war. Tomcat will correctly infer the path

3. Place myapp.war in $CATALINA_BASE/webapps

Tomcat (by default) will unpack and deploy your application

4. Remove the Manager node from your Context.

The Manager node relates to managing HTTP Sessions. The Hibernate sessions 
relate to Hibernate units of work.

4a. Tomcat:
4b. Hibernate:

5. Remove the Resource node from your Context.

6. Place the hibernate.cfg.xml file where it will be packaged in 

6a. In a NetBeans project, place it in <project-name>/src/java
6b. In a Maven project, place it in <project-name>/src/main/resources

7. Use a ServletContextListener to get a Hibernate SessionFactory.

Here's an example:

I do things a little differently, by creating a utility class, and then using 
that utility class in a listener. I can then attach logging and MBeans to the 

. . . . just my two cent.


----- Original Message ----
From: Justin Case <>
Sent: Wed, December 1, 2010 6:22:01 AM
Subject: automatic deployment without server.xml - bad request

Hello all,

I'm on Tomcat 6.0.29 in Windows (XP or server 2003, same) and I'm trying to get 
an application to deploy automatically without putting it in server.xml - as the 

documentation strongly recommends. 

Just to note, if I put the context setting in server.xml like this all works 

            <Host appBase="wtpwebapps" autoDeploy="false" 
                name="localhost" unpackWARs="true" xmlNamespaceAware="false"
                <Valve className="org.apache.catalina.valves.AccessLogValve"
                    directory="logs" pattern="common" prefix="access_log."
                    resolveHosts="false" suffix=".txt" />
                <Context docBase="com.mycompany.myapp" path="/myapp"
                    reloadable="true" override="true">
                    <Manager pathname="" />
                    <Resource name="hibernate/MySessionFactory" auth="Container"
                        configuration="hibernate.cfg.xml" />

If I remove the context from server.xml and place a context.xml in my app's 
META-INF, then enable the two deploy params, the deployment happens succesfully 
- that's what the console says at least. The application even starts ok, I can 
see the logging of my classes.
Each request to the application will throw immediately a HTTP error 400 - bad 
request. Funny enough, this error will not even be logged anywhere, even when I 
enabled debug logging in Tomcat! (and got 100M of logs which I searched 
through). No record of the 400 whatsoever, while I can confirm the Host header 
IS there - I see it in Firebug (and with the other context it works anyway).

What I see different is that the Tomcat's work directory, the 
work/Catalina/localhost/com.mycomp.myapp directory it created automatically at 
startup is and stays EMPTY. Now normally there should be the compiled JSP's 
right? So there's SOMETHING not ok about this automatic deployment, and I'm 
unable to figure out what it is. There was in May an interesting discussion 
thread on this list called "Misunderstanding deployOnStartup actions", but that 
guy also ended up using server.xml so... I only see advice like "your config is 
wrong to start with", which might be very true (otherwise one wouldn't be 
posting), but I wasn't able to see anywhere sampled a CORRECT config.

Thanks A LOT for any hints/samples/links,


To unsubscribe, e-mail:
For additional commands, e-mail:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message