File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes The requested resource (/servletTestApp/) is not available Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "The requested resource (/servletTestApp/) is not available" Watch "The requested resource (/servletTestApp/) is not available" New topic
Author

The requested resource (/servletTestApp/) is not available

hiteshi kalani
Greenhorn

Joined: Aug 31, 2011
Posts: 10
i am trying to run a servlet on tomcat 6

defined the directory structure in the following manner
-webapps
-servletTestApp
-WEB-INF
-web.xml
-classes
-testServletPackage contains class file-testServlet.class

i believe i have set the classpath correctly both for java and servlet-api.jar. I can also see the application nae /servletTestApp when i open the manager in the browser...but when i click on it..i get a 404 error-cant find resource

HTTP Status 404 - /servletTestApp/

type Status report

message /servletTestApp/

description The requested resource (/servletTestApp/) is not available.

web.xml looks like this

<?xml version="1.0" encoding="UTF-8" ?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">

<servlet>
<servlet-name>testServlet</servlet-name>
<servlet-class>testServletPackage.testServlet</servlet-class>
</servlet>


<servlet-mapping>
<servlet-name>testServlet</servlet-name>
<url-pattern>/testServlet</url-pattern>
</servlet-mapping>
</web-app>

and the servlet is as follows-

package testServletPackage;

import javax.servlet.*;
import java.io.*;

import javax.servlet.http.*;

public class testServlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Hello World!</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello World!</h1>");
out.println("</body>");
out.println("</html>");
}
}

finally the log file for localhost-its pretty long but i guess bold will help


1 Sep, 2011 12:12:19 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
1 Sep, 2011 12:12:19 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
1 Sep, 2011 12:15:10 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
1 Sep, 2011 12:15:10 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
1 Sep, 2011 12:39:46 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
1 Sep, 2011 12:39:46 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
1 Sep, 2011 12:40:46 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet testServlet as unavailable
1 Sep, 2011 12:40:46 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet testServlet
java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class testServletPackage.testServlet with modifiers ""
at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
at java.lang.Thread.run(Unknown Source)
1 Sep, 2011 12:48:19 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
1 Sep, 2011 12:48:19 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
1 Sep, 2011 12:57:47 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
1 Sep, 2011 12:57:47 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
1 Sep, 2011 1:13:44 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
1 Sep, 2011 1:13:44 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
1 Sep, 2011 1:14:42 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
1 Sep, 2011 1:14:42 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
1 Sep, 2011 1:19:27 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
1 Sep, 2011 1:19:27 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
1 Sep, 2011 1:19:32 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
1 Sep, 2011 1:19:32 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
1 Sep, 2011 1:36:09 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet testServlet as unavailable
1 Sep, 2011 1:36:09 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet testServlet
java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class testServletPackage.testServlet with modifiers ""
at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)

at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
at java.lang.Thread.run(Unknown Source)
1 Sep, 2011 1:52:02 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
1 Sep, 2011 1:52:02 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
1 Sep, 2011 1:52:38 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
1 Sep, 2011 1:52:38 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
1 Sep, 2011 1:53:04 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet testServlet as unavailable
1 Sep, 2011 1:53:04 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet testServlet
java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class testServletPackage.testServlet with modifiers ""
at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
at java.lang.Thread.run(Unknown Source)

PLease help..tried to search the errors on the net..in vain.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61762
    
  67

HTTP Status 404 - /servletTestApp/

That URL does not match what you've mapped in the deployment descriptor.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
hiteshi kalani
Greenhorn

Joined: Aug 31, 2011
Posts: 10
Bear Bibeault wrote:
HTTP Status 404 - /servletTestApp/

That URL does not match what you've mapped in the deployment descriptor.


tried that too..http://localhost:8080/testServlet at the browser but it gives 404...

also tried to change servlet mapping to /servletTestApp/testServlet and wrote this on the browser http://localhost:8080//servletTestApp/testServlet
but it still gives 404...the problem is that when i click on the /servletTestApp link in the list of applications tomcat manager...t gives 404..so if it cant find my webapp..i cant expect it to find the servlet file...can't understand why it's not working out when my webapp is listed in the list of applications in tomcat manger??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61762
    
  67

If the Tomcat manager is not showing the app as running that means that the app never started so of course it won't respond.

Look in the logs for the reason for the failure.
hiteshi kalani
Greenhorn

Joined: Aug 31, 2011
Posts: 10
Bear Bibeault wrote:If the Tomcat manager is not showing the app as running that means that the app never started so of course it won't respond.

Look in the logs for the reason for the failure.


bear boss..u'r right i just noticed the tomcat manager flag is false in the running column...which log am i supposed to see? i have posted one of them above..and it was localhost.date in my logs folder..
hiteshi kalani
Greenhorn

Joined: Aug 31, 2011
Posts: 10
hiteshi kalani wrote:
Bear Bibeault wrote:If the Tomcat manager is not showing the app as running that means that the app never started so of course it won't respond.

Look in the logs for the reason for the failure.


bear boss..u'r right i just noticed the tomcat manager flag is false in the running column...which log am i supposed to see? i have posted one of them above..and it was localhost.date in my logs folder..


ok so i set the servlet mappng to /servletTestApp/testServlet and the running column showed true...but the 404 doesnt go..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61762
    
  67

hiteshi kalani wrote:ok so i set the servlet mappng to /servletTestApp/testServlet and the running column showed true...but the 404 doesnt go..

The servlet mapping should not include the context path. The URL should include the context path.
hiteshi kalani
Greenhorn

Joined: Aug 31, 2011
Posts: 10
Bear Bibeault wrote:
hiteshi kalani wrote:ok so i set the servlet mappng to /servletTestApp/testServlet and the running column showed true...but the 404 doesnt go..

The servlet mapping should not include the context path. The URL should include the context path.


I had added that in the URL only under the servlet mapping tag.
<url-pattern></url-pattern>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The requested resource (/servletTestApp/) is not available