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 8818947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:13:54+00:00 2026-06-14T05:13:54+00:00

I have used eclipse + glassfish to deploy my first web-service from eclipse. I

  • 0

I have used eclipse + glassfish to deploy my first web-service from eclipse.
I have the following class:

package com.restfully.shop.services;

import javax.ws.rs.core.*;
import java.util.*;

public class ShoppingApplication extends Application {

    private Set<Object> singletons = new HashSet<Object>();
    private Set<Class<?>> empty = new HashSet<Class<?>>();

    public ShoppingApplication() {
        singletons.add(new CustomerResource());
    }

    @Override
    public Set<Class<?>> getClasses() {
        return empty;
    }

    @Override
    public Set<Object> getSingletons() {
        return singletons;
    }


}

and the following web.xml:

<?xml version="1.0" ?>
<web-app>
 <servlet>
        <servlet-name>Rest</servlet-name>
        <servlet-class>com.restfully.shop.services.ShoppingApplication</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Rest</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

As long as I read that jersey is already included with the glassfish – id didnt put anything into the lib folder of the web project.

but hten when I start the app in the browser:

Exception

javax.servlet.ServletException: PWC1403: Class com.restfully.shop.services.ShoppingApplication is not a Servlet
root cause

java.lang.ClassCastException: com.restfully.shop.services.ShoppingApplication cannot be cast to javax.servlet.Servlet

The glassfish version is 3.1.1

I also wrote a simple client which connects to the service throught java.io.URL,
but that one returns:

404
Location:null

What is wrong with the service and how can I fix it?
+ would be very appreciated – how a services tested??? Is it always like that – writing a test class which uses those URL connections or are there any standard ways to test web services?

  • 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-14T05:13:55+00:00Added an answer on June 14, 2026 at 5:13 am

    I have no experience with Glassfish but v3 seems to be JAX-RS aware.

    This means a sub-class of javax.ws.rs.core.Application is not needed.

    Just deploy your JAX-RS annotated class with a web.xml as follows

    <servlet>  
        <servlet-name>ServletAdaptor</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>ServletAdaptor</servlet-name>  
        <url-pattern>/resources/*</url-pattern>  
    </servlet-mapping>
    

    Your REST application can subsequently be accessed by adding /resources/ to the context root.

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

Sidebar

Related Questions

Right now i have used SOAP method to consume web service from android eclipse.
I have two Java interfaces and one implementing class. (I have used Eclipse to
I come from Java Background and so used to Debugging using Eclipse but have
While evaluating ICEfaces I have used Eclipse and its Web Page Editor to visually
I m executing following: db2 -tvsf ./sql/update_product.sql I have used eclipse for editing update_product.sql
My Eclipse Axis2 Service Archiver plugin is no longer working properly. I have used
I am new to Java (and Eclipse) but I have used .NET (and Visual
I have used some jquery components in my web site, Suddenly i'm getting an
i have used eclipse, android sdk and phonegap to create a small application. I
I have used file search functionality in eclipse to replace a specific occurrence of

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.