<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=ianso" rel="nofollow">Ian Sollars</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-8368?redirect=false" rel="nofollow">SPR-8368</a></strong> and commented</p>
<p dir="auto">With the splitting of Spring Framework into multiple jar files in v3.0, there are now several files named "META-INF/spring.handlers", "spring.schemas" and "spring.tooling". This is not a problem when running in a normal servlet container, but poses problems when e.g. creating an executable JAR file from a webapp using an embedded web server such as Jetty, or running GWT in "Dev Mode", which uses a custom class loader.</p>
<p dir="auto">In the former scenario, a typical approach is to use a Maven assembly to extract all .class files from the project dependencies and merge them into one hierarchy, as a way of packaging all the dependencies and the webapp itself into one JAR file.</p>
<p dir="auto">However, in this case only one copy of "spring.handlers/schemas/tooling" can exist, and so any schemas that are used and /not/ in the one copy cannot be validated. This leads to exceptions such as this one:</p>
<p dir="auto">org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 65 in XML document from class path resource [spring/beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.<br>
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)<br>
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)<br>
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)<br>
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:218)<br>
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:147)</p>
<p dir="auto">Other people reporting similar problems can be found at Stack Overflow here and here.</p>
<p dir="auto">The workaround is to construct your own "custom" version of these three files, merging all the copies into one like so:</p>
<p dir="auto">//IOUtils and FileUtils come from Apache Commons IOfor(String s : new String[] {"spring.schemas", "spring.handlers", "spring.tooling"}) {<br>
Enumeration&lt;?&gt; e = Test.class.getClassLoader().getResources("META-INF/"+s);<br>
StringBuilder out = new StringBuilder();while(e.hasMoreElements()) {<br>
URL u = (URL) e.nextElement();<br>
out.append(IOUtils.toString(u.openStream())).append("\n");<br>
}<br>
File outf = new File(s);<br>
FileUtils.writeStringToFile(outf, out.toString(), "UTF-8");<br>
}</p>
<p dir="auto">However, the proper fix would be to use a different file-name for each instance of the schemas/handlers/tooling files. For example, inside "org.springframework.aop-3.0.5.RELEASE.jar/META-INF" you would find "spring-aop.schemas", "spring-aop.handlers" and "spring-aop.tooling".</p>
<p dir="auto">I'm afraid I'm not sufficiently up-to-speed with the Spring code-base to give you a patch to do this, however a brief investigation shows that "spring.handlers" and "spring.schemas" are specified in org.springframework.beans.factory.xml.PluggableSchemaResolver and DefaultNamespaceHandlerResolver, and that constructors exist for specifying different locations for these files. I hope you find this information useful.</p>
<p dir="auto">Best regards,</p>
<ul dir="auto">
<li>Ian</li>
</ul>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0.5</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398113528" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13175" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13175/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13175">#13175</a> META-INF/spring.handlers are hidden resources when running with special isolated ClassLoader, for example as osgi Netbeans plugins or javawebstart (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto">1 votes, 4 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=vpernin" rel="nofollow">Vladislav Pernin</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-8256?redirect=false" rel="nofollow">SPR-8256</a></strong> and commented</p>
<p dir="auto">The documentation of the great Cache Abstraction feature has some errors :</p>
<ul dir="auto">
<li>the namespace declaration <a href="http://www.springframework.org/schema/cache/spring-cache.xsd" rel="nofollow">http://www.springframework.org/schema/cache/spring-cache.xsd</a> does not exists, replace with <a href="http://www.springframework.org/schema/cache/spring-cache-3.1.xsd" rel="nofollow">http://www.springframework.org/schema/cache/spring-cache-3.1.xsd</a></li>
<li>duplicate block description of proxy-target-class with the note</li>
<li>the <code class="notranslate">@Cacheable</code> and <code class="notranslate">@CacheEvict</code> annotation key attribute must start with #, as already corrected in the blog <a href="http://blog.springsource.com/2011/02/23/spring-3-1-m1-caching/" rel="nofollow">http://blog.springsource.com/2011/02/23/spring-3-1-m1-caching/</a></li>
</ul>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1 M1</p>