views:

433

answers:

2

Hello,

Initially I had a webapp called "admin" running fine, deployed inside the $CATALINA_HOME/webapps/ directory of tomcat 6. Now I tried setting up a vitual host to run this webapp.

Step1: I added the following in $CATALINA_HOME/conf/server.xml

<Host name="mysubdomain.domain.com" appBase="keshav">

</Host>

Step2: I created a folder $CATALINA_HOME/keshav

Step3: Created the ROOT context as $CATALINA_HOME/keshav/ROOT

Step4: Moved my "admin" webapp (which was inside $CATALINA_HOME/webapps/) to $CATALINA_HOME/keshav

Now when I access http://mysudomain.domain.com/admin/jsp/login.jsp, it WORKS fine bringing up the login page. But when I try accessing http://mysubdomain.domain.com/admin/Login.do or any other struts action it gives me 404 error-

"HTTP Status 404 - Servlet action is not available"

In the catalina.out file I get the message "INFO: Servlet action is currently unavailable"

Can anyone please help me figure out what is wrong in this config?

UPDATE: I also had changed the connector port from 8080 to 80. Since opening 80 port requires root privileges, I am starting tomcat using sudo (the user that I am using is in the sudoers list).

Whenever I run tomcat with sudo, the 404 error for struts actions are occuring. If I change the connector port from 80 to 8080 and start without using sudo, the virtual host is working fine..

If I su to root and start tomcat, it is working fine as well. Using sudo seems to be causing this problem..

A: 
  1. Have you defined context for your virtual host? Take a look at Configuring Your Context section of Tomcat virtual hosting guide.
  2. ROOT context is not required (unless you're actually using it).
  3. Is 'action' servlet mapped to '*.do' pattern in your web.xml? I assume so since you've said it was running fine but it never hurts to check.
ChssPly76
Thanks chssply76 for your reply. 1) No, I am thinking a separate context.xml is not required for my "admin" webapp, the default in the $CATALINA_HOME/conf would suffice 2) Yes ROOT is not required but I am using it for redirection to the "admin" webapp 3) Yes. Please check my latest update.. – Keshav
Keshav
So JSP works even on port 80 with sudo but action doesn't? Are you SURE that the working JSP is actually from your "virtual" host and not the artefact of a previous run (e.g. cached compiled one or the one from non-virtual app)? Running sudo may (and usually does) change your environment, run 'sudo -V' to see the specifics. Perhaps something screwy is happening with classpath... Try starting Tomcat via sudo while port remains at 8080 - this should help narrowing it down to sudo vs port issue. Be sure to start Tomcat clean (nothing in work / tmp; webapp deployed to a single place).
ChssPly76
A: 

This is typical of ActionServlet. It maps all exception to UnavailableException so you always get "unavaiable" error even if the servlet is dead. There should be other information in log to show you the exact cause.

When you run the server in sudo, the environment changes. Maybe struts config relies on some environment variable or default working directory?

Try "sudo -s catalina.sh". It may help.

ZZ Coder