Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7737519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:01:15+00:00 2026-06-01T08:01:15+00:00

How to create simple webserver in Java using Eclipse, Tomcat and Jersey i.e steps

  • 0

How to create simple webserver in Java using Eclipse, Tomcat and Jersey i.e steps to follow?

We are creating simple webserver using the below links:

  • http://www.ibm.com/developerworks/web/library/wa-aj-tomcat/
  • http://www.vogella.de/articles/REST/article.html

but we got an error like this:

java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:01:16+00:00Added an answer on June 1, 2026 at 8:01 am

    Have maven running. Then run this command(press enter if it asks sth):

    mvn archetype:generate -DgroupId=com.test.rest -DartifactId=test -DarchetypeArtifactId=maven-archetype-webapp
    

    It will create you a simple webapp. Now create the source package as src/main/java/com/test/rest, and create a simple class as following with a name “test” in it:

     package com.test.rest;
    
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.PathParam;
    import javax.ws.rs.core.Response;
    
    @Path("/test")
    public class test{
    
    @GET
    @Path("/{param}")
    public Response getMsg(@PathParam("param") String msg) {
    
        String output = "Jersey say : " + msg;
    
        return Response.status(200).entity(output).build();
    
        }
    
    }
    

    At that point you should get errors, resolve them by adding this dependency to your pom:

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.8</version>
        </dependency>
    

    you can run a dummy “mvn clean install” so that maven will download the repository and your errors will disappear.

    Now, go to webapp/WEB-INF and configure your web.xml as follows:

    <web-app id="WebApp_ID" version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Restful Web Application</display-name>
    
    <servlet>
        <servlet-name>jersey-serlvet</servlet-name>
        <servlet-class>
                     com.sun.jersey.spi.container.servlet.ServletContainer
                </servlet-class>
        <init-param>
             <param-name>com.sun.jersey.config.property.packages</param-name>
             <param-value>com.test.rest</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>jersey-serlvet</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
    

    here we said which classes to be loaded and also gave a small prefix with “/rest”. so your webservice will start with this prefix.

    Now you are ready, build the app, and add the jar file under tomcat/webapps folder. when you run your tomcat you can reach to your webservice via:

    (url_to_tomcat_server/jar_name/prefix_at_web_xml/prefix_at_java_rest_class/dummy_text_requested_byclass)

    localhost:8080/test/rest/test/blabla
    

    Note: tested and running

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a simple http client server using java. It will show
I am creating a simple Indy webserver using TIdHTTPServer . On almost all request
I'm using JCarousellite to create simple carousels on a Drupal site. In my template
I am using JBoss 6.0. I am running a simple webserver using the jboss.resteasy
I've written a simple Java Console Application in Eclipse that references a WCF web
I'm using python and CherryPy to create a simple internal website that about 2
I'm new to Java and Android development and try to create a simple app
I want to create an extremely simple web server for development purposes in Ruby
I need to create simple reusable javascript object publishing several methods and parameterized constructor.
I know how to create simple object and add dynamically properties to it. object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.