I am on a Spring 4, java 8 project trying to pick up the pieces from previous mis-handling.
I am tasked with restoring a version of web services missing from source control. I am doing this by de-compiling the war and putting the changes back in the source. While doing this, I found the following lines in applicationContext.xml.
<mvc:cors>
<mvc:mapping path="/**"
allowed-origins="*"
allowed-methods="POST, GET, PUT, OPTIONS, DELETE"
allowed-headers="*"
allow-credentials="false"
max-age="4800" />
</mvc:cors>
And I copied them into my applicationContext.xml. I Immediately got the following error.
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 67 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 67; columnNumber: 13; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:cors'.
The beans definitions with the xmlns are identical between the versions:
<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"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:mybatis="http://mybatis.org/schema/mybatis-spring"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://mybatis.org/schema/mybatis-spring
http://mybatis.org/schema/mybatis-spring.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd"
>
I looked in the spring-mvc def, but there was nothing about cors there.
I did some searching, and while there's sites that tell you how to use cors like this, none of them specify the namespace to use to bring this in.
Does anyone have any advice?
@M.Deinum's comments (despite being patronizing) were spot on. In addition to the lost source, they also evidently made changes to the build and I was building with the wrong libraries. Correcting that fixed my issue.