Link to home
Start Free TrialLog in
Avatar of yac678
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/LoginHandler
web.xml looks as follows:
    <servlet>
        <servlet-name>LoginHandler</servlet-name>
        <servlet-class>web.control.LoginHandler</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>LoginHandler</servlet-name>
        <url-pattern>/keywords/LoginHandler</url-pattern>
    </servlet-mapping>

When IntelliJ launches Tomcat, I see the following line:
Using CATALINA_BASE:   C:\Documents and Settings\Administrator\.IntelliJIdea8x\system\tomcat\Unnamed_Keywordse57d4893

When I look in $CATALINA_BASE\conf\Catalina\localhost, I see keywords.xml which defines the following context path:
<Context path="/keywords" docBase="C:\Development\Keywords\out\exploded\KeywordsWeb" />

...and when I look in C:\Development\Keywords\out\exploded\KeywordsWeb\C:\Development\Keywords\out\exploded\KeywordsWeb\WEB-INF\classes\web\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\webapps\ROOT. I was expecting IntelliJ to create another directory under C:\apache-tomcat-5.5.26\webapps 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.
Avatar of yac678
yac678

ASKER

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\webapps\ROOT. I was expecting IntelliJ to create another directory under C:\apache-tomcat-5.5.26\webapps 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?
SOLUTION
Avatar of rrz
rrz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yac678

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.
>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.
Avatar of yac678

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/webapps/KeywordsWeb.
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/web.xml</WatchedResource>
</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?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yac678

ASKER

It worked! I changed the directory to "keywords" and now all the internal references work too. Thanks for your patience with me :-)