0
votes

I have a spring config to create a client with cxf using jaxws. when I run my testcase from a main class with this code:

ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:spring/client-context.xml");
return (VisitService) ctx.getBean("client");

I get this exception

org.xml.sax.SAXParseException; lineNumber: 21; columnNumber: 71; schema_reference.4: Failed to read schema document 'http://cxf.apache.org/schema/jaxws.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .

I understand the exception and found this in the documentation of cxf http://cxf.apache.org/docs/embedding-cxf-inside-spring.html

Include     <import resource="classpath:META-INF/cxf/cxf.xml" />

When I include the context.xml that is described in the documentation, I just get the same error. Spring validates its schema's before it loads this xml. Wrapping the application context would probably solve my problem, but it seems a inferior solution. I know the xsd should be on my classpath, and it is, in the cxf-rt-frontend-jaxws jar.

2

2 Answers

1
votes

The cxf documentation sometimes uses http://cxf.apache.org/schema/jaxws.xsd and sometimes uses http://cxf.apache.org/schemas/jaxws.xsd Cxf3 needs http://cxf.apache.org/schemas/jaxws.xsd

0
votes

This may also happen when Spring related libs that define their own namespace are not actually in the classpath. Spring doesn't find Namespace Handler (which is placed in META-INF/spring.handlers of such lib) and therefore it cannot parse custom namespace.

But yes, if namespace is defined incorrectly, then Spring won't ever find the required Namespace Handler :)