<< Back to previous view

[JAX_RS_SPEC-330] JAX-RS application Failed to load and run, when using jersey Application servlet class defined inside the web.xml (v3). Created: 04/Jan/13  Updated: 18/Jun/13  Resolved: 07/Jan/13

Status: Closed
Project: jax-rs-spec
Component/s: model api, server
Affects Version/s: 2.0
Fix Version/s: None

Type: Bug Priority: Blocker
Reporter: Mohamed Taman Assignee: Unassigned
Resolution: Invalid Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7 Professional SP1.
GlassFish 4_b69


Tags: adoptajsr
Participants: Mohamed Taman and Santiago Pericas-Geertsen

 Description   

When I was testing the section 2.3.2 Servlet for the first part which dictates:

• If no Application subclass is present, JAX-RS implementations are REQUIRED to dynamically add a servlet and set its name to
javax.ws.rs.core.Application

and to automatically discover all root resource classes and providers which MUST be packaged with the application. Additionally, the application MUST be packaged with a web.xml that specifies a servlet mapping for the added servlet. An example of such a web.xml file is:

1 <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
4 http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
5 <servlet>
6 <servlet-name>javax.ws.rs.core.Application</servlet-name>
7 </servlet>
8 <servlet-mapping>
9 <servlet-name>javax.ws.rs.core.Application</servlet-name>
10 <url-pattern>/myresources/*</url-pattern>
11 </servlet-mapping>
12 </web-app>

The following JAX-RS2 app bellow was failed to be registered and run by the Glassfish v4_b69, while it runs on Glassfish 3.2.1.1, by raising the following info message _"[failed to localize] jersey.app.registered.classes(javax.ws.rs.core.Application, [])|#]"_ which it should be error not info message also.

Full error:

[#|2013-01-05T00:29:37.121+0200|INFO|glassfish4.0|org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer|_ThreadID=35;_ThreadName=admin-listener(1);_TimeMillis=1357338577121;_LevelValue=800;|[failed to localize] jersey.app.registered.classes(javax.ws.rs.core.Application, [])|#]

[#|2013-01-05T00:29:37.142+0200|INFO|glassfish4.0|javax.enterprise.web|_ThreadID=35;_ThreadName=admin-listener(1);_TimeMillis=1357338577142;_LevelValue=800;_MessageID=AS-WEB-00324;|Loading application [JAX-RS_v2.0_Test] at [/rs2/test]|#]

Application Details:
--------------------

Web.xml

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

Resource Class:

package eg.taman.jcp.specs.rs2.test.app;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

/**

  • Created with IntelliJ IDEA.
  • User: mohamed_taman
  • Date: 1/4/13
  • Time: 11:44 PM
  • This class intended to test that there is no application sub class exists and the jax-rs 2 implementation should serve this
  • resource, by adding in the web.xml the Application class and its servlet mappings.
    */

@Path("hello")
public class GreeterResource {

@GET
@Produces("text/plain")
public String greeting(){ return "Hello world"; }
}



 Comments   
Comment by Santiago Pericas-Geertsen [ 07/Jan/13 02:46 PM ]

This is not an issue on the JAX-RS specification but on the RI (Jersey). It should be filed at jersey.java.net.

Generated at Mon Apr 21 07:52:41 UTC 2014 using JIRA 4.0.2#472.