Pawan
Pawan

Reputation: 32331

JAX-WS SPRING INTEGRATION Issue

My applicationcontext.xml file is

<?xml version="1.0" encoding="UTF-8"?>
<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.2.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
        https://jax-ws.dev.java.net/spring/servlet.xsd">
    <wss:binding url="/details">
        <wss:service>
            <ws:service bean="#Accountimpl" />
        </wss:service>
    </wss:binding>

    <!-- Web service methods -->
    <bean id="accountimpl" class="com.webservice.spring.Accountimpl" />
</beans>

Jars I used

My web.xml

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
    <display-name>Spring-Webservice</display-name>
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    <servlet>
        <servlet-name>Details</servlet-name>
        <servlet-class>
            com.sun.xml.ws.transport.http.servlet.WSSpringServlet
        </servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>Details</servlet-name>
        <url-pattern>/details</url-pattern>
    </servlet-mapping>
</web-app>

In my web.xml file showing warning as listener-class references to non-existent class org.springframework.web.context.ContextLoaderListener servlet-class references to non-existent class "com.sun.xml.ws.transport.http.servlet.WSSpringServlet"

When iam deploying in jboss server i getting below exception

    17:13:09,569 WARN  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-8) Ignored XML validation warning: org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-3.2.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:196)
    at org.apache.xerces.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:97)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:322)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:281)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaWarning(XSDHandler.java:2529)
17:13:09,624 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-3) Context initialization failed: org.springframework.beans.factory.BeanDefinitionStoreException: Line -1 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Premature end of file.
Caused by: org.xml.sax.SAXParseException: Premature end of file.
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:283)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1653)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:324)
    at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:845)
    at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:768)
17:13:09,631 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-8) Context initialization failed: org.springframework.beans.factory.BeanDefinitionStoreException: Line 11 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:417) [spring-2.0.jar:2.0]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:357) [spring-2.0.jar:2.0]
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:196)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:132)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:390)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:322)


17:13:09,667 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Spring-Webservice]] (MSC service thread 1-3) Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanDefinitionStoreException: Line -1 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Premature end of file.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:417) [spring-2.0.jar:2.0]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:357) [spring-2.0.jar:2.0]

Caused by: org.xml.sax.SAXParseException: Premature end of file.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:196)
    at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:175)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:394)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:322)
    at org.apache.xerces.impl.XMLErrorReporter.reportError

17:13:09,695 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/SpringWebService]] (MSC service thread 1-8) Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanDefinitionStoreException: Line 11 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:417) [spring-2.0.jar:2.0]

When changed my applicationContex.xml file as

<?xml version="1.0" encoding="UTF-8"?>
<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-2.5.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
        https://jax-ws.dev.java.net/spring/servlet.xsd">
    <wss:binding url="/details">
        <wss:service>
            <ws:service bean="#Accountimpl" />
        </wss:service>
    </wss:binding>

    <!-- Web service methods -->
    <bean id="accountimpl" class="com.webservice.spring.Accountimpl" />

</beans>

Iam getting error in xmlfile as below cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'wss:binding'. - schema_reference.4: Failed to read schema document 'https://jax-ws.dev.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 .

Iam unable to resolve this issue can any one help me in solving this issue.

Thanks

Upvotes: 0

Views: 7106

Answers (1)

M. Deinum
M. Deinum

Reputation: 125252

There are a couple of things wrong

  1. Missing jars (you at least need spring-web.jar and probably also spring-webmvc.jar)
  2. Wrong xsd in your configuration.

Add the missing jars, instead of searching the internet yourself I strongly suggest you use something like maven or gradle to manage your dependencies, that will save you a lot of headaches and googling for the right jar file combinations.

Regarding the XSD it is adviced to use the XSD files WITHOUT a version, spring will automatically use the latest version available. So use spring-beans.xsd insteadof spring-beans-3.2.0.xsd in your configuration header.

As you are using Spring 3.2 (judging from yuor list of jars files) I suggest you use version 1.9 of the jaxws-spring integration jar which was build for 3.2, 1.8 has a dependency on Spring 2.0.

Finally, according to the documentation, your xsd for jax-ws is declared wrong. You should use http://jax-ws.java.net/spring/servlet.xsd and http://jax-ws.java.net/spring/core.xsd instead of what you have now (a combination of https and dev namespace.).

So basically your header should look something like this

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

Note that the referenced documentation is wrong it binds to http://jax-ws.java.net/spring/core and then suddenly tries to use http://jax-ws.dev.java.net/spring/core that isn't going to work.

Upvotes: 1

Related Questions