Web Hosting Talk







View Full Version : Tomcat: Getting .war deployment and web.xml to work properly


RisingHost
04-11-2003, 04:00 PM
I'm trying to get .war deployment and web.xml files working on my server with not much success. Individual JSP pages and /servlet /servlets work on my server but when I try to do war deployment the war file unpacks but the JSP pages don't work and neither do the included servlets... or when I try and put a web.xml directory within a WEB-INF folder under the public_html directory it doesn't appear to give the proper results. Has anyone here experienced this and have any suggestions?


Background:
RedHat 7.3 w/ cpanel... I've installed Tomcat 4.0.3 configured the httpd.conf with the
Include "/usr/local/jakarta/jakarta-tomcat-4.0.3-src/build/conf/auto/mod_jk.conf"
AddModule mod_jk.c
in the addmod section

as well as adding the following line in the handler section
AddType text/html .jsp

I've also added the following lines to each domain which will be using tomcat.
<IfModule mod_jk.c>
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
</IfModule>

</VirtualHost>

Lastly I've configured the web.xml file for /servlet and /servlets and added the following lines to the server.xml for the virtual hosts which will be using tomcat:

<Host name="[domainname]" appBase="/home/[user]/public_html">
<Context path="" reloadable="true" docBase="/home/[user]/public_html" debug="1"/>
</Host>

I still dont have individual web.xml files working or war deployment for user accounts... Please help! :)

iago
02-03-2004, 02:48 AM
Hi Risinghost, sorry to bring back this old topic but Im trying to do the same thing: deploy .war files properly but still have no success.

Just want to know if you were able to do this and how did you make this to work properly.

Im using RH7.3 + Cpanel + Apache1 + mod_jk2 (tomcat 4.1)

The .war files seem to be deploying inside the jakarta directories: /pathtojakarta/build/work/Standalone/domain.com

When trying to access them from the domain.com/servlets/ i get a 404 error.

Does the files inside a .war should be deployed inside /home/user/public_html/ ? or are they ok inside the jakarta directories? If so how does apache is supposed to find/map this files?

JSP and the servlets directory works fine, its jut with the .war deployment that im lost. I checked your messages at other forums but i couldnt find a solution to this.

Hope someone can help me with this :(
Kind regards!

stdunbar
02-03-2004, 11:58 AM
iago,
Are you creating new webapps? One of the problems I have with mod_jk is that you have to have the path to each of your webapps in the Apache httpd.conf file in the JkMount directive. So if you add a new war with a path of /newwebapp you need to also add a JkMount directive.

I've deployed wars with no problem other than the above. Can we see a VirtualHost section from your httpd.conf to help debug the problem?

iago
02-03-2004, 12:13 PM
Hi, thanks for your help! This is the entry for

<VirtualHost 209.50. X.X>
ServerAlias www.domain.com domain.com
ServerAdmin webmaster@domain.com
DocumentRoot /home/user/public_html
BytesLog domlogs/domain.com-bytes_log
ServerName www.domain.com
User user
Group user
CustomLog domlogs/domain.com combined
ScriptAlias /cgi-bin/ /home/user/public_html/cgi-bin/

<IfModule mod_jk.c>
JkMount /*.jsp ajp13
JkMount /servlets ajp13
JkMount /servlets/* ajp13
JkMount /eed ajp13
JkMount /eed/* ajp13
JkMount /servlet ajp13
JkMount /servlet/* ajp13
JkMount /journal ajp13
JkMount /journal/* ajp13
JkMount /jtg ajp13
JkMount /jtg/* ajp13
</IfModule>
</VirtualHost>

Actually i have restarted tomcat and apache several times and it seems to just detect servlets inside /servlet/ and not mapping properly the other directives.

Regards!

stdunbar
02-03-2004, 03:48 PM
So are you deploying the wars to /home/user/public_html/servlets or is it one level up? Is there already a WEB-INF/web.xml file in that directory?

iago
02-03-2004, 04:52 PM
Actually it is a file called jtg.war and it is being deployed inside the /jakarta/build/work/Standalone/domain.com/ but i managed to make it deply inside /home/user/public_html/ though it is not being extracted inside WEB-INF it is creating a jtg directory inside public_html

Inside this jtg directory i can see another WEB-INF (inside this web-inf are the classes and lib directories containing all the files and a web.xml), a META-INF and a web.xml

Does this extracted files should be deployed in runtime? or is it ok to just open the war file and upload all the files manually, also, how to make apache to recognize all /jtg/ as a servlet call, even though i added that to the httpd.conf i get an 404 apache error instead of a tomcat response.

I have also this entries in my server.xml file:

<Context path="/jtg" docBase="jtg.war" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="jtg." suffix=".log" timestamp="false"/>
</Context>

<Context path="/servlet" docBase="jtg.war" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="forum." suffix=".log" timestamp="false"/>
</Context>


Thanks!