• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet not found exception  RSS feed

 
navneet rajput
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to run one simple web application. I have imported required jar in which i have defined my servlet class.
and defined servlet name and complete path of class. But when I am running my web application on tomcat it gives me errror like servlet not found.

Please give me some pointers it will be appreciated. Thanks in advance.

Thanks
Navneet


The web.xml file is as below

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>HelloRest</display-name>

<servlet>
<servlet-name>JerseyTest</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JerseyTest</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

</web-app>


I have checked location of following class in my jar it is fine.
com.sun.jersey.spi.container.servlet.ServletContainer



 
Vijitha Kumara
Saloon Keeper
Posts: 3998
42
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have checked location of following class in my jar it is fine. com.sun.jersey.spi.container.servlet.ServletContainer


Where is this located inside the container (directory layout)? Give more details about your environment etc.. And how you access the servlet. Check the server logs after you deployed the app to see any errors if any.
 
navneet rajput
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply.

Actually I have putted that jar under source folder and I am trying to run application in eclipse, run as->run on server
I don't know what is written inside that ServletContainer class because it is .class file. Basically I have written one sample Web service in JAX-rs
and I wanted to call Web service but it fail to run servlet itself. Please give me some pointer.

Thanks
Navneet
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Jersey library does not do anything useful with HTTP requests, unless you configure at least one REST resource using an @Path annotation in a resource class. And then the URL would most likely not be the root URL, since you'd generally want to deploy more than one resource class, each configured for a different URL.

Do you see messages in the log file like "INFO: Root resource classes found:
class HelloWorldResource"?

As an aside, note that jar files go into the WEB-INF/lib directory of the web app for live deployments.
 
navneet rajput
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have copied all jars in lib folder, now it found servlet container class but it gives some errors.
Please help me I am new to all these things,please find the attachment for error logs.

And I am tring to host following web-service

package com.jersey;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@Path ("/helloworld")
public class HelloWorldResource {

@GET
@Produces ("text/plain")
public String sayHello() {
return "Hello World";
}
}
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What errors are those? Post short, relevant excerpts of them here (note that you can't attach text files).

Also, which URL are you hitting?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!