Spring + jax-ws : ‘#xxx’ is not a valid value for ‘NCName’

Problem

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="/ws/OrderWs">
        <wss:service>
            <ws:service bean="#orderWs"/>
        </wss:service>
    </wss:binding>

    <!-- this bean implements web service methods -->
    <bean id="#orderWs" class="com.mkyong.order.ws.OrderWS">
        <property name="orderBo" ref="OrderBo" />
    </bean>

</beans>

During server start up, it hits following error message :


Caused by: org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.1: 
	'#orderWs' is not a valid value for 'NCName'.

Solution

The SAX parser’s error message is misleading, it should be ‘#orderWs’ is not exists‘!. A very common typo mistake, an extra ‘#’ in the Spring’s bean configuration. The correct configuration should be like this :


    <wss:binding url="/ws/OrderWs">
        <wss:service>
            <ws:service bean="#orderWs"/>
        </wss:service>
    </wss:binding>

    <!-- orderWs, not #orderWs -->
    <bean id="orderWs" class="com.mkyong.order.ws.OrderWS">
        <property name="orderBo" ref="OrderBo" />
    </bean>

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
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
sssvenkateswaraSarah S Recent comment authors
newest oldest most voted
Sarah S
Guest
Sarah S

Hi Everyone, First time poster and glad to be a part of the group.

venkateswara
Guest
venkateswara

Hi Yong,

Below is the conent from my XSD file. When i am using the below elements with the name like cim:Asset.AssetContainer ….etc . getting the error as “s4s-att-invalid-value: Invalid attribute value for ‘name’ in element ‘element’. Recorded reason: cvc-datatype-valid.1.2.1:
‘cim:Asset.facilityStatus’ is not a valid value for ‘NCName’.”

could you please help me out!!!!

sss
Guest
sss

Bean id starting with a number also gave me the same error.
Renamed the bean name by removing the number and it worked fine.
looks like there are some special characters which are not accepted as bean names..