I’m trying to configure a Spring config (xml) file and am trying to add a namespace for a valid schema file that I have living locally inside my project. The reason is that I don’t have a “real” URL (web server, etc.), so I’m trying to just use a local schema that I will provide under WEB-INF/:
MyProject/
src/
java/
config/
MySchema.xsd
spring-config.xml
build.xml
Inside my spring-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:ms="http://myproject.org/MySchema.xsd"
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.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
Project is building & deploying fine, but when I go to run it I get:
org.xml.sax.SAXException: Failed to locate XSD resource '/META-INF/MySchema.xsd' on
classpath. Namespace: 'http://myproject.org/MySchema.xsd'.
Ultimately I’d like both spring-config.xml and MySchema.xsd stored under WEB-INF/, so I’m not sure why Spring is looking inside META-INF/… any ideas?
The URL http://myproject.org/MySchema.xsd is not a real URL, just giving the schema its own namespace. Thanks in advance!
There is no “definition” (I don’t know the correct term) of the http://myproject.org/MySchema.xsd in the xsi:schemaLocation attribute. Try something like this: