I am able to compile and start my Spring project using Maven:
mvn -e clean compile exec:java -Dexec.mainClass=de.fraunhofer.fkie.tet.vmware.manager.Test
I've found the root problem for this as per the reply of axtavt, and I've reported it as a ?bug? in Spring: https://jira.springsource.org/browse/SPR-8368 - a workaround to generate your own merged copies of these files is included there. For posterity the code is here as well:
//IOUtils and FileUtils come from Apache Commons IO
for(String s : new String[] {"spring.schemas", "spring.handlers", "spring.tooling"}) {
Enumeration<?> e = Test.class.getClassLoader().getResources("META-INF/"+s);
StringBuilder out = new StringBuilder();
while(e.hasMoreElements()) {
URL u = (URL) e.nextElement();
out.append(IOUtils.toString(u.openStream())).append("\n");
}
File outf = new File(s);
FileUtils.writeStringToFile(outf, out.toString(), "UTF-8");
}
I suspect your spring config file is missing the context
XML namespace. It should be added to the root element of your spring config file like this:
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="com.abc.xyz" />
</beans>
As it suggests there is a problem with the parsing either in Request or in Response. This error can occur if the RestTemplate client is expecting particular kind of Response from the Resource, but the Resource is returning something entirely. I got this error for a POST RestTemplate client that was related to change in the Response returned.
For e.g. Initial RestTemplate that was returning an Entity 'MyClass' changed and stared returning String so the Parser started giving error
ResponseEntity<MyClass> postResponseEntity = restTemplate.postForEntity(postEndPoint, httpRequestEntity, MyClass.class);
MyClass postResponseBody = postResponseEntity.getBody();
Changed to
ResponseEntity<String> postResponseEntity = restTemplate.postForEntity(postEndPoint, httpRequestEntity, String.class);
String postResponseBody = postResponseEntity.getBody();
As the response type changed from the entity to String the parser started giving error when processing the Response. Changed it to correct Response type (which in my case was String) and it started working.
Spring namespace handlers are resolved using files /META-INF/spring.schemas
and /META-INF/spring.handlers
. Because files with these names exist in different Spring jars, probably only one of them remains in target jar after maven-assembly-plugin
.
Perhaps you may merge these files manually and somehow configure maven-assembly-plugin
to overwrite file in target jar with this merged file.
I believe there are 3 solutions to this problem
What spring dependencies do you have in your pom? You may get xml parsing errors due to some spring jar files not being on the class path. In spring 3 the library was split up into many jar files. Check out this post to see what you need, specifically:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>