[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5585
  • Last Modified:

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.
0
yac678
Asked:
yac678
  • 5
  • 3
3 Solutions
 
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now