Unable to locate Spring NamespaceHandler for XML schema namespace [http://jax-ws.dev.java.net/spring/servlet]

Problem

Integrate Spring with JAX-WS, according to this link: http://jax-ws-commons.java.net/spring/ . When start the web application, get this exception :


org.springframework.beans.factory.parsing.BeanDefinitionParsingException: 
Configuration problem: Unable to locate Spring NamespaceHandler 
for XML schema namespace [http://jax-ws.dev.java.net/spring/servlet]

Here’s the Spring + JAX-WS configuration file.


<?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.dev.java.net/spring/core.xsd
        http://jax-ws.dev.java.net/spring/servlet
        http://jax-ws.dev.java.net/spring/servlet.xsd"
>

    <wss:binding url="/hello">
        <wss:service>
            <ws:service bean="#helloWs"/>
        </wss:service>
    </wss:binding>

    <!-- Web service methods -->
    <bean id="helloWs" class="com.mkyong.ws.HelloWorldWS">
    </bean>
    
</beans>

Solution

The link : http://jax-ws-commons.java.net/spring/is lacking of information, you need jaxws-spring.jar to integrate Spring with JAX-WS.

  1. Get it from java.net Maven repository directly.
  2. For Maven, declare jaxws-spring in pom.xml, like this

<project ...>

  <repositories>
    <repository>
      <id>java.net</id>
      <url>http://download.java.net/maven/2</url>
    </repository>
  </repositories>
   
  <dependencies>
    
 	<!-- Exclude some unnecessary libraries --> 
	<dependency>
		<groupId>org.jvnet.jax-ws-commons.spring</groupId>
		<artifactId>jaxws-spring</artifactId>
		<version>1.8</version>
		<exclusions>
			<exclusion>
           		<groupId>org.springframework</groupId>
      			<artifactId>spring-core</artifactId>
        	</exclusion>
        	<exclusion>
           		<groupId>org.springframework</groupId>
      			<artifactId>spring-context</artifactId>
        	</exclusion>
        	<exclusion>
           		<groupId>com.sun.xml.stream.buffer</groupId>
      			<artifactId>streambuffer</artifactId>
        	</exclusion>
        	<exclusion>
           		<groupId>org.jvnet.staxex</groupId>
      			<artifactId>stax-ex</artifactId>
        	</exclusion>
		</exclusions>
	</dependency>
	
  </dependencies>
  <build>
    <finalName>web services</finalName>
    <plugins>
       <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
           <version>2.3.1</version>
           <configuration>
               <source>1.6</source>
               <target>1.6</target>
           </configuration>
       </plugin>
    </plugins>
  </build>
</project>

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
3 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
Dick BiekartGajendraJAX-WS Tutorials Recent comment authors
newest oldest most voted
trackback
JAX-WS Tutorials

[…] Unable to locate Spring NamespaceHandler for XML schema namespace [http://jax-ws.dev.java.net/spring… Common error message to integrate JAX-WS with Spring framework. […]

Gajendra
Guest
Gajendra

Hi Sir, I am new to webservice(Restful with cxf) ,I have copied code from one site but I am getting following error please help me. SEVERE: Context initialization failed org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://cxf.apache.org/jaxws] Offending resource: ServletContext resource [/WEB-INF/cxf.xml] at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68) at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:284) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1335) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1328) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at… Read more »

Dick Biekart
Guest
Dick Biekart

Still finding these JAX-WS tutorials quite useful, despite their age. Using Spring 2.5.6 on JDK 1.6 for these examples as I’m used to these versions. For solving the problem discussed here, I first installed the most recent version of jaxws-spring.jar, which is version 1.9 of November 2013. This turns out to have a compatibility problem with the rest of my jars, most likely with Spring 2.5.6. The message is: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘com.sun.xml.ws.transport.http.servlet.SpringBinding#0’ defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean ‘helloWs’ while setting bean property ‘service’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with… Read more »