0
votes

I am trying to bind already functional JAXWS web service deployed on IBM WAS Liberty 8.5.5.4 using JDK 1.7 but getting following error when binding the service as per applicationContext.xml. It is a simple web application with nothing other than web service, spring version is 4.1.0

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 <xsd:schema>.

[ERROR ] Context initialization failed Line 30 in XML document from ServletContext resource [/META-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 30; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'wss:binding'.

[ERROR ] SRVE0283E: Exception caught while initializing context: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 30 in XML document from ServletContext resource [/META-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 30; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'wss:binding'. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)

Caused by: org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 30; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'wss:binding'. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

I searched existing issues and found same exception in an issue active a year ago old issue link . As per the solution I have

  1. jaxws-rt.jar version 2.2.7 in the classpath - the applicationContext.xml does find it and resolves the binding tag at compile time but gives problem at runtime
  2. I have updated the xsd location as mentioned in the issue and also verified that xsd does exist at http://jax-ws.java.net/spring/servlet.xsd

Below is applicationContext.xml contents

<?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-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.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">

<bean id="viewResolver"class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="cache" value="false" />
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />

<bean id="mathService" class="com.adp.sbs.jaxws.service.MathServiceImpl" />

<wss:binding url="/math">
<wss:service>
    <ws:service bean="#mathService" />
</wss:service>

</beans>

Any ideas why do I still get the exception?

1

1 Answers

0
votes

I had similar problems on WAS 6, WAS couldn't find resources located in other Jars. In my case, it couldn't find the spring-namespacehandlers (located in META-INF/spring...) of spring-integration, but spring itself worked. So my problem was similar to yours :)

I turned my WAS to debug level for all spring classes, which caused really long output. But i could find out, that no BeanConfigurator can't find the handler files to handle the spring-integration-xsd.

But what does spring do to start your application context? (background information)

The basic spring.jar does not contain all parsers to create contextes. It is checking for context-definitions (e.g. xmlns:ws="http://jax-ws.dev.java.net/spring/core") and tries to find a resolver for it. Therefore it is checking all jars if they contain /META-INF/spring.handler and META-INF/spring.schemas. The spring.handler contains the path to an implementation of the NamespaceHandler interface. Those class is responsible to redirect to the specific AbstractBeanDefinitionParser. The other class contains aliases for xsd-names.

I can think of 2 possible solutions without knowing more about your application:

First, jax-ws does not contain those spring.handler file, plus the necessary implementation of the namespaceHandler. So you would need a third-party jax-ws-spring.jar, which contains those classes. I can't tell if this would match your problem, because you didn't append your dependencies.

Second solution would be to extract the files (spring.handler, or the xsd) from the jar and add them to your application. Luckily, you don't need to do that manually after each build, there is a maven plugin.

<plugin>

  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>extract-jaxws-stuff</id>
      <phase>generate-resources</phase>
      <goals>
        <goal>unpack</goal>
      </goals>
      <configuration>
        <artifactItems>
          <artifactItem>
            <groupId>jax-ws-groupid</groupId>
            <artifactId>jax-ws-artifactId</artifactId>
            <version>${jax-ws.version}</version>
            <outputDirectory>src/main/resources</outputDirectory>
            <includes>path/to/the/resource</includes>
          </artifactItem>
        </artifactItems>
      </configuration>
    </execution>
  </executions>
</plugin>

Update:

Open your jaxws-spring.jar and find the spring.handlers and spring.schemas files in the META-INF folder. Copy the files in your applications META-INF folder.
If this didn't work too: Merge the spring.handlers and spring.schemas files with the exisiting files in your spring-context.jar.

Good luck, or give feedback to find other problems.