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.
yac678Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

yac678Author Commented:
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?
0
rrzCommented:
I don't use IntelliJ. So I can't help you with that.
Tomcat is very easy to use  by itself.  You can install a stand alone instance on your desktop.

Anyway, I can comment on a couple things.
>Is there any additional configuration I should be aware of?
In eclipse and netbeans, there is option to create a web application. I guess there must be something like that in IntelliJ but I am just guessing.  
>I have another IntelliJ project which has a web application in C:\apache-tomcat-5.5.26\webapps\ROOT
ROOT is a pre-installed web application(context).  Do you mean to say that you installed some JSPs or servlets into it ?  

>I get the dreaded error "HTTP Status 404 - /keywords/LoginHandler  
What are typing into your browser address ?  Maybe you are trying something like
     http://localhost:8080/keywords/LoginHandler  
Since your context name is keywords and your servlet is mapped to /keywords/LoginHandler ,
you should be trying
http://localhost:8080/keywords/keywords/LoginHandler 


0
yac678Author Commented:
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.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

rrzCommented:
>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.
0
yac678Author Commented:
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?
0
rrzCommented:
>The new application is now on /usr/tomcat/apache-tomcat-5.5.28/webapps/KeywordsWeb.
Did you try accessing  
[my domain]/keywordsWeb/home.jsp  
?
0
yac678Author Commented:
Sage, I also tried what you suggested: I created a war using IntelliJ and copied it to webapps. When tomcat started it indeed opened it and a new Web directory was created. Still, no luck with accessing /keywords/home.jsp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yac678Author Commented:
It worked! I changed the directory to "keywords" and now all the internal references work too. Thanks for your patience with me :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.