Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: "schemaLocation value *** must have even number of URI's." on namespaces in spring dispatcher

I was getting following error

<Ignored XML validation warning> org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 55; SchemaLocation: schemaLocation value = 'http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx' must have even number of URI's. 

and my dispatcher servlet was having following namespaces

<beans xmlns="http://www.springframework.org/schema/beans"        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xmlns:p="http://www.springframework.org/schema/p"        xmlns:aop="http://www.springframework.org/schema/aop"        xmlns:tx="http://www.springframework.org/schema/tx"        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">   

and i replaced all above by following

<beans xmlns="http://www.springframework.org/schema/beans"               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"               xsi:schemaLocation="http://www.springframework.org/schema/beans               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">   

And my error got disappeared.
How it happened can any one tell??

like image 350
Nagappa L M Avatar asked May 21 '13 05:05

Nagappa L M


1 Answers

The schemaLocation attribute references an XML Schema document for a namespace.

Basically when you type:

xmlns:expns="http://www.example.com" xsi:schemaLocation="http://www.example.com                     http://www.example.com/schema/example.xsd" 

You are saying: "I'm going to use the prefix expns for the elements of the namespace http://www.example.com. Also, so you can validate those elements, get the XSD Schema file for http://www.example.com in http://www.example.com/schema/example.xsd"

So, in other words, the format is:

xsi:schemaLocation="namespace-a   where_to_get_the_xsd_for_namespace-a                     namespace-b   where_to_get_the_xsd_for_namespace-b                     namespace-c   where_to_get_the_xsd_for_namespace-c" 

And so on.

That's why it must me an even number.


More info and examples can be found here.

like image 125
acdcjunior Avatar answered Sep 20 '22 09:09

acdcjunior