Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Servlet not found exception

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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



 
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic