You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Willard, Jonathan" <Jo...@ca.com> on 2010/06/08 18:40:53 UTC

CXFNonSpringJaxrsServlet and xml validation

Hi,

 

I are using the CXFNonSpringJaxrsServlet / Application to register our RESTful servlet similar to this example below from the section 'Configuring JAX-RS services in container without Spring'

 

The document says that we can do this

<servlet>

 <servlet-name>CXFServlet</servlet-name>

 <display-name>CXF Servlet</display-name>

 <servlet-class>

   org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet

 </servlet-class>

 <init-param>

  <param-name>jaxrs.serviceClasses</param-name>

  <param-value>

    org.apache.cxf.systest.jaxrs.BookStore1

    org.apache.cxf.systest.jaxrs.BookStore2                     

  </param-value>

 </init-param>

 <init-param>

  <param-name>jaxrs.providers</param-name>

  <param-value>

    org.apache.cxf.systest.jaxrs.BookStoreProvider1

    org.apache.cxf.systest.jaxrs.BookStoreProvider2                     

  </param-value>

 </init-param>

 <!-- enables schema validation -->

 <init-param>

  <param-name>jaxrs.schemaLocations</param-name>

  <param-value>

    classpath:/WEB-INF/schemas/schema1.xsd

    classpath:/WEB-INF/schemas/schema2.xsd                

  </param-value>

 </init-param> 

However the CXFNonSpringJaxrsServlet does this:

    public void loadBus(ServletConfig servletConfig) throws ServletException {

        super.loadBus(servletConfig);

        

        String applicationClass = servletConfig.getInitParameter(JAXRS_APPLICATION_PARAM);

        if (applicationClass != null) {

            createServerFromApplication(applicationClass);

  à        return; ß Never get to the code to setSchemasLocations

        }

It does not seem to use the schemaLocations init-param, only the javax.ws.rs.Application.  Is this an oversight?

 

Thanks,

 

Jon

 

 

 


Re: CXFNonSpringJaxrsServlet and xml validation

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi yes, it is a bug which I fixed locally the other day (haven't merged yet)
to address an issue with jaxrs.in/outInterceptors being ignored when
Application was used.
As a workaround, please use jaxrs.serviceClasses (as opposed to Application)
and list the root resource classes, similarly to jaxrs.providers

cheers, Sergey

On Tue, Jun 8, 2010 at 5:40 PM, Willard, Jonathan
<Jo...@ca.com>wrote:

> Hi,
>
>
>
> I are using the CXFNonSpringJaxrsServlet / Application to register our
> RESTful servlet similar to this example below from the section 'Configuring
> JAX-RS services in container without Spring'
>
>
>
> The document says that we can do this
>
> <servlet>
>
>  <servlet-name>CXFServlet</servlet-name>
>
>  <display-name>CXF Servlet</display-name>
>
>  <servlet-class>
>
>   org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
>
>  </servlet-class>
>
>  <init-param>
>
>  <param-name>jaxrs.serviceClasses</param-name>
>
>  <param-value>
>
>    org.apache.cxf.systest.jaxrs.BookStore1
>
>    org.apache.cxf.systest.jaxrs.BookStore2
>
>  </param-value>
>
>  </init-param>
>
>  <init-param>
>
>  <param-name>jaxrs.providers</param-name>
>
>  <param-value>
>
>    org.apache.cxf.systest.jaxrs.BookStoreProvider1
>
>    org.apache.cxf.systest.jaxrs.BookStoreProvider2
>
>  </param-value>
>
>  </init-param>
>
>  <!-- enables schema validation -->
>
>  <init-param>
>
>  <param-name>jaxrs.schemaLocations</param-name>
>
>  <param-value>
>
>    classpath:/WEB-INF/schemas/schema1.xsd
>
>    classpath:/WEB-INF/schemas/schema2.xsd
>
>  </param-value>
>
>  </init-param>
>
> However the CXFNonSpringJaxrsServlet does this:
>
>    public void loadBus(ServletConfig servletConfig) throws ServletException
> {
>
>        super.loadBus(servletConfig);
>
>
>
>        String applicationClass =
> servletConfig.getInitParameter(JAXRS_APPLICATION_PARAM);
>
>        if (applicationClass != null) {
>
>            createServerFromApplication(applicationClass);
>
>  à        return; ß Never get to the code to setSchemasLocations
>
>        }
>
> It does not seem to use the schemaLocations init-param, only the
> javax.ws.rs.Application.  Is this an oversight?
>
>
>
> Thanks,
>
>
>
> Jon
>
>
>
>
>
>
>
>