Short answer:
Please read (carefully), the following documentation:
http://tomcat.apache.org/tomcat-6.0-doc/appdev/deployment.html
Longer answer:
1. remove the docBase attribute from your Context
Your docBase would only work if you have a directory
$CATALINA_BASE/com.mycompany.myapp.
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: http://tomcat.apache.org/tomcat-6.0-doc/config/manager.html
4b. Hibernate: http://community.jboss.org/wiki/sessionsandtransactions
5. Remove the Resource node from your Context.
6. Place the hibernate.cfg.xml file where it will be packaged in
WEB-INF/classes.
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: http://community.jboss.org/wiki/UsingHibernatewithTomcat
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
listener.
. . . . just my two cent.
/mde/
----- Original Message ----
From: Justin Case <send_lotsa_spam_here@yahoo.com>
To: users@tomcat.apache.org
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
fine.
<Host appBase="wtpwebapps" autoDeploy="false"
deployOnStartup="false"
name="localhost" unpackWARs="true" xmlNamespaceAware="false"
xmlValidation="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"
type="org.hibernate.SessionFactory"
factory="com.mycompany.myapp.HibernateSessionFactoryTomcatFactory"
configuration="hibernate.cfg.xml" />
</Context>
</Host>
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.
BUT!
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,
JC
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
|