[jbosstools-issues] [JBoss JIRA] (JBIDE-10645) Validate servlet name 'javax.ws.rs.core.Application' or any subtype

Xavier Coulon (JIRA) jira-events at lists.jboss.org
Wed Jan 18 16:44:19 EST 2012


    [ https://issues.jboss.org/browse/JBIDE-10645?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12660331#comment-12660331 ] 

Xavier Coulon commented on JBIDE-10645:
---------------------------------------

Hi Viacheslav,

I'm a bit confused now.. The [JBoss AS/JAX-RS Reference Guide|https://docs.jboss.org/author/display/AS7/JAX-RS+Reference+Guide] gave somehow simpler rules than what I wrote in a previous comment, and after rechecking and doing more tests, I realized that the spec extract was taken from the 1.0 version, not the 1.1 one.. 
I'm really sorry about that :-/

So, the deployment works in the two following cases:
{code}
<web-app version="3.0" 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">
	
  <servlet-mapping>
    <servlet-name>org.jboss.as.quickstarts.poh5helloworld.MyApplication</servlet-name>
    <url-pattern>/hello/*</url-pattern>
  </servlet-mapping>
</web-app>
{code}
and if the application does not contain any subclass of javax.ws.rs.core.Application
:
{code}
<web-app version="3.0" 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">

  <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>/hello/*</url-pattern>
  </servlet-mapping>
</web-app>
{code}

but it does *not* work in that case:
{code}
<web-app version="3.0" 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">

  <servlet>
    <servlet-name>org.jboss.as.quickstarts.poh5helloworld.MyApplication</servlet-name>
    <servlet-class>org.jboss.as.quickstarts.poh5helloworld.MyApplication</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
	
  <servlet-mapping>
    <servlet-name>org.jboss.as.quickstarts.poh5helloworld.MyApplication</servlet-name>
    <url-pattern>/hello/*</url-pattern>
  </servlet-mapping>
</web-app>
{code}

So the issue should be reduced to 2 cases:
{quote}
1. As you wrote:  A non-JAX-RS aware servlet container is used; user provides his implementation of Application.
<servlet>/<servlet-class> traditionally implements javax.servlet.Servlet; an init-param traditionally configures the servlet; <servlet-mapping>/<servlet-name> references the name of that servlet.
2. A JAX-RS aware servlet container is used; user does not provide his implementation of Application or does not.
<servlet-mapping>/<servlet-name> is equal to javax.ws.rs.core.Application (or its subtype), which is not necessarily declared by any <servlet>/<servlet-name>. 
{quote}

This is conform to the section 2.3.2 of the [JAX-RS 1.1 spec|http://jsr311.java.net/nonav/releases/1.1/spec/spec.html]:
{quote}
1.If no Application subclass is present the added servlet MUST be named: javax.ws.rs.core.Application
2.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
{quote} 


BTW, Jersey, the JAX-RS 1.1 RI also seems to support the same kind of deployment options, according to the [doc|http://jersey.java.net/nonav/documentation/latest/jax-rs.html#d4e186]



Once agains, sorry for the confusion in the previous comment, I hope this is more clear now.

Xavier
                
> Validate servlet name 'javax.ws.rs.core.Application' or any subtype
> -------------------------------------------------------------------
>
>                 Key: JBIDE-10645
>                 URL: https://issues.jboss.org/browse/JBIDE-10645
>             Project: Tools (JBoss Tools)
>          Issue Type: Bug
>          Components: JSF
>    Affects Versions: 3.3.0.M5
>            Reporter: Xavier Coulon
>            Assignee: Viacheslav Kabanovich
>              Labels: jax-rs, validation, web, web_xml
>             Fix For: 3.3.0.Beta1
>
>
> The 'JAX-RS Application' is the top level fragment of the URI Path Templates of the JAX-RS Endpoints. 
> One way to configure it is in the webapp's deployment descriptor, with something like this:
> {code}
> <web-app 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">
>     <servlet-mapping>
>         <servlet-name>javax.ws.rs.core.Application</servlet-name>
>         <url-pattern>/*</url-pattern>
>     </servlet-mapping>
> </web-app>
> {code}
> see [JBossAS 7 / JAX-RS docs here|https://docs.jboss.org/author/display/AS7/Java+API+for+RESTful+Web+Services+(JAX-RS)#JavaAPIforRESTfulWebServices%28JAX-RS%29-Packageandbuildtheendpoint]
> Hélas, the web.xml validator reports an error (or a warning) with the following message
> {quote}
> servlet-name references to javax.ws.rs.core.Application that is not a servlet	
> {quote}
>  
> For sure, the validation level could be set to ignore, but could this JAX-RS specific rule be implemented by default ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the jbosstools-issues mailing list