jersey
  1. jersey
  2. JERSEY-2158

Jersey ignores @ApplicationPath annotation

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Invalid
    • Affects Version/s: 2.3.1
    • Fix Version/s: 2.4
    • Component/s: containers
    • Labels:
      None
    • Environment:

      Mac OS X 10.8.5, Apple Java 1.6.0_51, Jersey 2.3.1, Maven Jetty Plugin 8.1.13.v20130916, Servlet 2.5

      Description

      I've 2 Application classes annotated with @ApplicationPath, both configured in web.xml as shown below. Jersey ignores the @ApplicationPath annotations for some reason. Using those paths in the request URL throws 404.
      I believe the problem should be apparent from the code snippets; however, if you still need deployable code, I can provide that.

      RestfulAdage.java
      @ApplicationPath("/resourcesA")
      public class RestfulAdage extends Application {
      	@Override
      	public Set<Class<?>> getClasses() {
      		Set<Class<?>> set = new HashSet<Class<?>>();
      		set.add(Adages.class);
      		return set;
      	}
      }
      
      RestfulPrediction.java
      @ApplicationPath("/resourcesP")
      public class RestfulPrediction extends Application {
      	@Override
      	public Set<Class<?>> getClasses() {
      		Set<Class<?>> set = new HashSet<Class<?>>();
      		set.add(PredictionsRS.class);
      		return set;
      	}
      }
      
       
      <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
      	      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      	version="2.5">
      	<display-name>Java Web Services: Up and Running, 2e, chapter 2,
      		practice code</display-name>
      
      	<servlet>
      		<servlet-name>JerseyWebApplication</servlet-name>
      		<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
      		<init-param>
      			<param-name>jersey.config.server.provider.packages</param-name>
      			<param-value>adages;predictions3</param-value>
      		</init-param>
      		<load-on-startup>1</load-on-startup>
      	</servlet>
      
      	<servlet-mapping>
      		<servlet-name>JerseyWebApplication</servlet-name>
      		<url-pattern>/*</url-pattern>
      	</servlet-mapping>
      </web-app>
      

        Activity

        Hide
        Marek Potociar added a comment -

        You cannot have 2 applications deployed on a same servlet. You need separate servlets for both apps. Closing as invalid.

        Show
        Marek Potociar added a comment - You cannot have 2 applications deployed on a same servlet. You need separate servlets for both apps. Closing as invalid.

          People

          • Assignee:
            Unassigned
            Reporter:
            abhi0123
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: