{"id":4958,"date":"2014-03-30T17:12:19","date_gmt":"2014-03-30T17:12:19","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/spring-schemalocation-fails-when-there-is-no-internet-connection-collection-of-common-programming-errors\/"},"modified":"2014-03-30T17:12:19","modified_gmt":"2014-03-30T17:12:19","slug":"spring-schemalocation-fails-when-there-is-no-internet-connection-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/spring-schemalocation-fails-when-there-is-no-internet-connection-collection-of-common-programming-errors\/","title":{"rendered":"Spring schemaLocation fails when there is no internet connection-Collection of common programming errors"},"content":{"rendered":"<p>There is no need to use the classpath: protocol in your schemaLocation URL if the namespace is configured correctly and the XSD file is on your classpath.<\/p>\n<p>Spring doc &#8220;Registering the handler and the schema&#8221; shows how it should be done.<\/p>\n<p>In your case, the problem was probably that the spring-context jar on your classpath was not 2.1. That was why changing the protocol to classpath: and putting the specific 2.1 XSD in your classpath fixed the problem.<\/p>\n<p>From what I&#8217;ve seen, there are 2 schemas defined for the main XSD contained in a spring-* jar. Once to resolve the schema URL with the version and once without it.<\/p>\n<p>As an example see this part of the spring.schemas contents in spring-context-3.0.5.RELEASE.jar:<\/p>\n<pre><code>http\\:\/\/www.springframework.org\/schema\/context\/spring-context-2.5.xsd=org\/springframework\/context\/config\/spring-context-2.5.xsd\nhttp\\:\/\/www.springframework.org\/schema\/context\/spring-context-3.0.xsd=org\/springframework\/context\/config\/spring-context-3.0.xsd\nhttp\\:\/\/www.springframework.org\/schema\/context\/spring-context.xsd=org\/springframework\/context\/config\/spring-context-3.0.xsd\n<\/code><\/pre>\n<p>This means that (in xsi:schemaLocation)<\/p>\n<pre><code>http:\/\/www.springframework.org\/schema\/context\/spring-context-2.5.xsd \n<\/code><\/pre>\n<p>will be validated against<\/p>\n<pre><code>org\/springframework\/context\/config\/spring-context-2.5.xsd \n<\/code><\/pre>\n<p>in the classpath.<\/p>\n<pre><code>http:\/\/www.springframework.org\/schema\/context\/spring-context-3.0.xsd \n<\/code><\/pre>\n<p>or<\/p>\n<pre><code>http:\/\/www.springframework.org\/schema\/context\/spring-context.xsd\n<\/code><\/pre>\n<p>will be validated against<\/p>\n<pre><code>org\/springframework\/context\/config\/spring-context-3.0.xsd \n<\/code><\/pre>\n<p>in the classpath.<\/p>\n<pre><code>http:\/\/www.springframework.org\/schema\/context\/spring-context-2.1.xsd\n<\/code><\/pre>\n<p>is not defined so Spring will look for it using the literal URL defined in schemaLocation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is no need to use the classpath: protocol in your schemaLocation URL if the namespace is configured correctly and the XSD file is on your classpath. Spring doc &#8220;Registering the handler and the schema&#8221; shows how it should be done. In your case, the problem was probably that the spring-context jar on your classpath [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4958","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4958","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4958"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4958\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}