Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4220

After loading XSDs from links in WADL, JAX-RS get all for all resources fail with 400

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.2
    • 2.5.3, 2.6
    • None
    • None
    • Linux

    • Unknown

    Description

      We use a CustomCXFNonSpringJaxrsServlet with one overriding method in order to use our hand written WADL.
      @Override
      protected void setSchemasLocations(JAXRSServerFactoryBean bean, ServletConfig servletConfig)
      {
      super.setSchemasLocations(bean, servletConfig);

      // Set the WADL document location
      if(servletConfig.getInitParameter(JAXRSUtils.DOC_LOCATION) != null)

      { bean.setDocLocation(servletConfig.getInitParameter(JAXRSUtils.DOC_LOCATION)); }

      }

      In the web.xml of the user resource, the XSDs are referenced as follows -
      <init-param>
      <param-name>jaxrs.schemaLocations</param-name>
      <param-value>
      classpath:schemas/xml.xsd
      classpath:schemas/atom.xsd
      classpath:schemas/user.xsd
      classpath:schemas/user-role.xsd
      </param-value>
      </init-param>

      In the wadl file, the grammar section is as follows -
      <grammars>
      <include href="xml.xsd" />
      <include href="atom.xsd" />
      <include href="user.xsd" />
      <include href="user-role.xsd" />
      </grammars>

      Here are the steps to reproduce the error -

      1. Verify get all and get a single resource work for all resources including user.
      2. Access user wadl from https://server:port/api/rest/users?_wadl successfully but the grammar section is changed to -
      <grammars>
      <include href="https://server:8443/api/rest/users//xml.xsd" />
      <include href="https://server:8443/api/rest/users//atom.xsd" />
      <include href="https://server:8443/api/rest/users//user.xsd" />
      <include href="https://server:8443/api/rest/users//user-role.xsd" />
      </grammars>
      3. Repeat step 1. Result is good.
      4. Click the first link and view xml.xsd from a browser. Note xml.xsd is availale from the internet and does not have a schemaLocation tag.
      5. Repeat step 1. Result is good.
      6. Click the link to atom.xsd or any of rest of the links and the XSD loads correctly. Note all those XSDs are only available in the classpath of user.war.
      Below is an excerpt of how schema is referenced in the XSD -
      <xs:import namespace="urn:api:rest:user-role" schemaLocation="https://server:8443/api/rest/users//" />
      <xs:import namespace="http://www.w3.org/2005/Atom" schemaLocation="https://server:8443/api/rest/users//" />
      7. Do a get all request using https://server:8443/api/rest/users and get the following error -
      400: Bad Request
      org.xml.sax.SAXParseException: Premature end of file.
      8. Do a get all request to other resources and get the same 400.
      9. Restart JBoss and problem goes away.

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            joanneli77 Joanne Kubischta
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: