Get your CodeRanch badge!*
The moose likes Servlets and the fly likes Status 404 error coming up while making the servlet app run on the tomcat server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Status 404 error coming up while making the servlet app run on the tomcat server" Watch "Status 404 error coming up while making the servlet app run on the tomcat server" New topic
Author

Status 404 error coming up while making the servlet app run on the tomcat server

Rahall Agarwal
Greenhorn

Joined: Jun 27, 2010
Posts: 7

Hey can anybody help me with Status 404 error thing..Here's my prob:-
there is this servlet app that i'm trying to deploy on tomcat server.I have gotten rid of all the warnings coz they end up turning into runtime errors often.Now the thing is evrytime i deploy a particular servlet file on the webserver i receive an error which says-"HTTP Status 404 /MajorProject/servlet/search_query1"
and below that is an error message that reads-"The requested resource (/MajorProject/servlet/search_query1) is not available/"

By the way-I'm using eclipse IDE(helios). Although i see all the class files(compiled files) in the workspace of the eclipse under the build directory(in the file system), i don't see any class files under the build folder when open te eclipse app..Is this normal or something wrong?

One more thing- I didn't even touch the web.xml file ..Do i need to set it up or something? Do i need to map every servlet in my directory in the xml?

Please assist.. Anybody..Thanks in case there's a solution from anyone
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

You need to set up the servlet and servlet mapping in the deployment descriptor (web.xml).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rahall Agarwal
Greenhorn

Joined: Jun 27, 2010
Posts: 7

Could you please tell me how should i do that..Because i have around 10 servlet files..So do i need to map every one of them in the DD?Could i somehow show you the page..like with the help of a screen shot or some attachment?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Please do not attach screen shots -- I will not download them. Use code tags to post code.

Servlet mapping is well-described in the Servlet Specification -- you should have a copy open on your desktop.

And yes, each servlet must be declared and mapped.

An example servlet declaration and mapping:
Rahall Agarwal
Greenhorn

Joined: Jun 27, 2010
Posts: 7

Ok ..i would try that the next day.. I need to sleep now..Its 12 mid night hereThanks for giving a crucial advice..I will definitely look forward to your replies in case i get some more problems in my servlet work..And sorry for abbreviating things..
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

Yes there is a need to do the servlet mapping for each and every servlet.
Do like what above said..


SCJP6.0,My blog Ranchers from Delhi
Rahall Agarwal
Greenhorn

Joined: Jun 27, 2010
Posts: 7

Here is what i did-




I tried doing the mapping .I started out with just two servlets..Can anyone tell me if the above way is the correct procedure to map..

In above case search_query1.java is the actual file name with class file as search_query1.class.I have changed the name of the servlet(<servlet-name> tag) to "QuerySearch1".With the second servlet-formserve12.java the class file is formserve12.class and i have changed the name of the servlet to "FormServer12" .

Also please tell if the url mapping has been done the right way or not? If its okay,then i'd do the same for all other servlets.

I have a feeling that there would only be one pair of servlet tag (<servlet>---</servlet>) in which ALL the servlets would have there own <servlet-name>--</servlet-name> and <servlet-class>---</servlet-class>..Like that there would be only one <servlet-mapping>--</servlet-mapping> within which ALL the servlets could be mapped..Is this true? Or the above scenario is true?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Firstly, follow conventions. It makes things much easier to read and understand. Class names should start with uppercase and be in mixed case. In other words: SearchQuery, not search_query.

Secondly, your servlets must be in a package other than the default.

Make these changes and let's look at it again.
Rahall Agarwal
Greenhorn

Joined: Jun 27, 2010
Posts: 7

I did make all the changes (including following the camel-case naming convention) and also i mapped all of my servlets in the DD..
Now my servlet pages are running but one of the servlet page is making an HTTP Status 500 error while it is run on the web server.Here is the error-

"description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Wrapper cannot find servlet class FormServer12 or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:680)
root cause

java.lang.ClassNotFoundException: FormServer12
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:680)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs."

Sorry for posting the whole error page but its never happened before..But everytime i ran the particular servlet,i would encounter the above http error.Please assist..

Also..should i take this current message to different post subject because this time the error is not HTTP Status 404 thats wat this message has been posted under?I mean do i need to have a new subject like "Status 500 error" where i need to post this latest post?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65


This means that your code is referencing a class named FormServer12 that is not in the web app's classpath.
Rahall Agarwal
Greenhorn

Joined: Jun 27, 2010
Posts: 7

So is there a quick fix to this problem..I mean i have mapped it in DD..What makes it come up?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Status 404 error coming up while making the servlet app run on the tomcat server
 
Similar Threads
Tomcat 4.1.24 cannot find Servlets
help with tomcat - 404 cannot find servlets
Unable to login to manager GUI
applet and servlet not communicating... any ideas?
404 error on servlet due to "requested resource not available"