yac678
asked on
HTTP status 404 for a servlet using Tomcat and IntelliJ
I am using IntelliJ 8.1 and a simple Web application which has a login JSP. The JSP has a form with the following action: ACTION=/keywords/LoginHand ler
web.xml looks as follows:
<servlet>
<servlet-name>LoginHandler </servlet- name>
<servlet-class>web.control .LoginHand ler</servl et-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginHandler </servlet- name>
<url-pattern>/keywords/Log inHandler< /url-patte rn>
</servlet-mapping>
When IntelliJ launches Tomcat, I see the following line:
Using CATALINA_BASE: C:\Documents and Settings\Administrator\.In telliJIdea 8x\system\ tomcat\Unn amed_Keywo rdse57d489 3
When I look in $CATALINA_BASE\conf\Catali na\localho st, I see keywords.xml which defines the following context path:
<Context path="/keywords" docBase="C:\Development\Ke ywords\out \exploded\ KeywordsWe b" />
...and when I look in C:\Development\Keywords\ou t\exploded \KeywordsW eb\C:\Deve lopment\Ke ywords\out \exploded\ KeywordsWe b\WEB-INF\ classes\we b\control, I see LoginHandler.class
So everything seems to be configured right, but when the login form submits, I get the dreaded error "HTTP Status 404 - /keywords/LoginHandler ... The requested resource (/keywords/LoginHandler) is not available."
Tomcat version is 5.5.26.
Any ideas?
I have additional information which may be useful. When IntelliJ launches Tomcat, I also see the line:
Using CATALINA_HOME: C:\apache-tomcat-5.5.26
I have another IntelliJ project which has a web application in C:\apache-tomcat-5.5.26\we bapps\ROOT . I was expecting IntelliJ to create another directory under C:\apache-tomcat-5.5.26\we bapps but this did not happen. I have configured the application context to /keywords Iin Run/Debug Configuration->Tomcat Server). Is there any additional configuration I should be aware of?
Thanks.
web.xml looks as follows:
<servlet>
<servlet-name>LoginHandler
<servlet-class>web.control
</servlet>
<servlet-mapping>
<servlet-name>LoginHandler
<url-pattern>/keywords/Log
</servlet-mapping>
When IntelliJ launches Tomcat, I see the following line:
Using CATALINA_BASE: C:\Documents and Settings\Administrator\.In
When I look in $CATALINA_BASE\conf\Catali
<Context path="/keywords" docBase="C:\Development\Ke
...and when I look in C:\Development\Keywords\ou
So everything seems to be configured right, but when the login form submits, I get the dreaded error "HTTP Status 404 - /keywords/LoginHandler ... The requested resource (/keywords/LoginHandler) is not available."
Tomcat version is 5.5.26.
Any ideas?
I have additional information which may be useful. When IntelliJ launches Tomcat, I also see the line:
Using CATALINA_HOME: C:\apache-tomcat-5.5.26
I have another IntelliJ project which has a web application in C:\apache-tomcat-5.5.26\we
Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Sage,
The 404 problem was fixed after I changed the servlet mapping to /LoginHandler and changed the form action to /keywords/LoginHandler!
The question is how do I configure Tomcat to have 2 different appliations on the same server? I already have another application deployed in webapps\ROOT, and there is no sign of the keywords application under webapps. I want to deploy the keywords application on a Linux server which already has a tomcat installation and a different application running on webapps/root.
The 404 problem was fixed after I changed the servlet mapping to /LoginHandler and changed the form action to /keywords/LoginHandler!
The question is how do I configure Tomcat to have 2 different appliations on the same server? I already have another application deployed in webapps\ROOT, and there is no sign of the keywords application under webapps. I want to deploy the keywords application on a Linux server which already has a tomcat installation and a different application running on webapps/root.
>I want to deploy the keywords application on a Linux server which already has a tomcat installation
A war file is used to make the transfer. Somehow you can ask IntelliJ to zip up your web application into a file named
keywords.war
Place this file into Tomcat's webapp folder. When Tomcat is restarted, it will unpack the war file and create your web app.
A war file is used to make the transfer. Somehow you can ask IntelliJ to zip up your web application into a file named
keywords.war
Place this file into Tomcat's webapp folder. When Tomcat is restarted, it will unpack the war file and create your web app.
ASKER
I have copied the application in an open directory structure to the webapps directory on tomcat. I already have another web application deployed in an open directory structure in webapps/ROOT and if I remember orrectly, it is not good to mix war files and open directories.
The new application is now on /usr/tomcat/apache-tomcat- 5.5.28/web apps/Keywo rdsWeb.
I have also added a context.xml file to the META-INF directory which looks as follows:
<Context path="/keywords">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/w eb.xml</Wa tchedResou rce>
</Context>
According to tomcat's configuration guide, the docBase attribute is not needed if the context.xml is placed in the application/META-INF directory. Still, I cannot access [my domain]/keywords/home.jsp. What am I missing?
The new application is now on /usr/tomcat/apache-tomcat-
I have also added a context.xml file to the META-INF directory which looks as follows:
<Context path="/keywords">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/w
</Context>
According to tomcat's configuration guide, the docBase attribute is not needed if the context.xml is placed in the application/META-INF directory. Still, I cannot access [my domain]/keywords/home.jsp.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It worked! I changed the directory to "keywords" and now all the internal references work too. Thanks for your patience with me :-)
ASKER
Using CATALINA_HOME: C:\apache-tomcat-5.5.26
I have another IntelliJ project which has a web application in C:\apache-tomcat-5.5.26\we