Search code examples
javaweb-servicesspringjax-ws

JAX-WS Schema http://jax-ws.dev.java.net/spring/servlet.xsd not able to be found


I am implementing JAX-WS with Spring framework.

The following is my Spring applicationContext.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://jax-ws.dev.java.net/spring/core
    http://jax-ws.dev.java.net/spring/core.xsd
    http://jax-ws.dev.java.net/spring/servlet
    http://jax-ws.dev.java.net/spring/servlet.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    ">

However, Eclipse is complaining:

Referenced file contains errors (http://jax-ws.dev.java.net/spring/servlet.xsd).

After investigation, I find the URL: http://jax-ws.dev.java.net/spring/servlet.xsd Does not exist. Instead, it seems be move to: http://jax-ws.java.net/spring/servlet.xsd (You can open this link in the brower)

Therefore, I updated XSD schema URL from http://jax-ws.dev.java.net/spring/servlet.xsd to http://jax-ws.java.net/spring/servlet.xsd

Now my applicationContext.xml looks like this:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://jax-ws.dev.java.net/spring/core
    http://jax-ws.java.net/spring/core.xsd
    http://jax-ws.dev.java.net/spring/servlet
    http://jax-ws.java.net/spring/servlet.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    ">

Actually with this change the Eclipse error goes away. The problem is after launching the web service in Tomcat 7, I get the following runtime error instead:

org.xml.sax.SAXParseException; lineNumber: 20; columnNumber: 29; schema_reference.4: Failed to read schema document 'http://jax-ws.java.net/spring/servlet.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not . at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:99) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:433)

Please advise.

Thank you very much. Regards,


Solution

  • Your problem is that you change the location from http://jax-ws.dev.java.net/spring/servlet.xsd to http://jax-ws.java.net/spring/servlet.xsd. Even though the latter one is the right url, it does not match what is defined in your jaxws-spring.jar META-INF/spring.schema file. That file should have the following content

    http\://jax-ws.dev.java.net/spring/core.xsd=spring-jax-ws-core.xsd
    http\://jax-ws.dev.java.net/spring/servlet.xsd=spring-jax-ws-servlet.xsd
    http\://jax-ws.dev.java.net/spring/local-transport.xsd=spring-jax-ws-local-transport.xsd
    

    Spring uses this mapping to search the schema in the classpath rather than to internet. Those schema files are located at the root of the jaxws-spring.jar file.

    Please take a look Registering the handler and the schema