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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:08:48+00:00 2026-05-15T23:08:48+00:00

The JAX-RS 1.1 specification says on page 6: If no Application subclass is present

  • 0

The JAX-RS 1.1 specification says on page 6:

If no Application subclass is present
the added servlet MUST be named:

javax.ws.rs.core.Application

What is the added servlet? Could it be an arbitrary servlet?

If an Application subclass is present
and there is already a servlet defined
that has a servlet initialization
parameter named:

javax.ws.rs.Application

Again, what is “a servlet” here?

If an Application subclass is present
that is not being handled by an
existing servlet then the servlet
added by the ContainerInitializer MUST
be named with the fully qualified name
of the Application subclass.

Does “the servlet added by the ContainerInitializer” mean that the servlets is added automatically? How would a configuration look like?

At the moment I use neither an Application class nor a web.xml and it works (with GlassFish 3.1). Does this deployment mechanism require a full class path scan, which could be slow with big libraries?

How to deploy on a Servlet container?

There is a confusing number of configuration options around in the web. See this example with context params in the web.xml (doesn’t work for me!). What is the preferred way to deploy a JAX-RS application?

  • 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-05-15T23:08:49+00:00Added an answer on May 15, 2026 at 11:08 pm

    There are a number of options for deploying into a Java EE 6 container (more specifically a Servlet 3.0 implementation):

    The simplest is:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app 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_3_0.xsd" version="3.0">
        <servlet>
            <servlet-name>javax.ws.rs.core.Application</servlet-name>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>javax.ws.rs.core.Application</servlet-name>
            <url-pattern>/rest/*</url-pattern>
        </servlet-mapping>
    </web-app>
    

    Then all the @Path and @Provider classes found in your web application will be available in the “default” JAX-RS application with a servlet URL pattern of "/rest/*".

    If you have one or more classes that extends javax.ws.rs.core.Application, you can specify like so:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app 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_3_0.xsd" version="3.0">
        <servlet>
            <servlet-name>com.example.jaxrs.MyApplication</servlet-name>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>com.example.jaxrs.MyApplication</servlet-name>
            <url-pattern>/rest/*</url-pattern>
        </servlet-mapping>
    </web-app>
    

    You may want to do the above in case you wish to only return specific sets of @Path/@Provider classes on a URL (so you could have a second MyApplication2 with a different URL pattern above).

    You can also skip the whole web.xml altogether and just annotate your MyApplication class wih @ApplicationPath which will serve as the URL pattern. I would recommend keeping the web.xml in any case because you will probably have to add other information about the web application there anyway.

    If you’re wondering where the servlet-class comes from, it is automatically added in by the environment. You can get an idea by looking at the Servlet 3.0 ServletContext.

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

Sidebar

Related Questions

My server side code:- @ApplicationPath(/externalpartnerws) public class ExternalPartnerApplication extends javax.ws.rs.core.Application { public Set<Class<?>> getClasses()
I have a pure JAX-RS application both in Glassfish and in jetty-servlet. I'm trying
I have specified my JAX-RS Application in the web.xml as follows: <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class>
Are there any implementations of the WS-Discovery specification for JAX-WS RI, Axis2, CXF or
JAX-RS is a specification that helps you develop restful web services in Java. But
I am deploying a JAX-WS client as part of a Java EE application on
I'm using JAX-RS in my web application to return my own object. I want
I am writing a JAX-RS (Jersey+Maven) application that does some tricky things (eg call
I'm using Jersey (jax-rs), to build a REST rich application. Everything is great, but
We have an application that uses a JAX-RPC client library and is running on

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.