Issue
I am getting error :
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 5 in XML document from URL [jar:file:/<File path>/.m2/repository/org/mule/modules/mule-module-spring-config/3.9.2/mule-module-spring-config-
3.9.2.jar!/registry-bootstrap-mule-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 5; columnNumber: 122; cvc-elt.1.a: Cannot find the declaration of element 'beans'.
at <TestclassPath>.<init>(<ClassName>.java:32)
while using mule-module-spring-config-3.9.2.jar and spring bean version 5.3.22.
but same code passes when we use Spring-bean version as 4.3.18.RELEASE.
SpringBeanTest.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd ">
....
</beans>
MuleTest.xml
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ajax="http://www.mulesoft.org/schema/mule/ajax"
xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:jdbc="http://www.mulesoft.org/schema/mule/ee/jdbc"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:core="http://www.mulesoft.org/schema/mule/core" version="CE-3.3.1"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:email="http://www.mulesoft.org/schema/mule/email"
xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp"
xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/3.3/mule-json.xsd
http://www.mulesoft.org/schema/mule/ajax http://www.mulesoft.org/schema/mule/ajax/3.3/mule-ajax.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/3.3/mule-jdbc-ee.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.3/mule-jms.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.3/mule-vm.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/3.3/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/3.3/mule-email.xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd
http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd">
<spring:beans>
<spring:import resource="classpath:SpringBeanTest.xml"/>
</spring:beans>
...
</mule>
I am new to spring , Could nayone help me in solving this issue.
Solution
Mule 3.x doesn't allow to use a different Spring Framework version than the one that is included in its distribution. Mule 3.9.2 includes for example includes Spring 4.1.9. Using a different version of Spring than the one included in the Mule version can cause unexpected errors -as you are experiencing- and is not supported. Mule 3.9.5, the final Mule 3.x release, supports Spring 4.3.29.
In particular Spring 5 is not supported by any version of Mule 3.x. See https://help.mulesoft.com/s/article/Spring-versions-throughout-each-version-of-Mule for more information of the Spring versions supported until Mule 3.9.2.
Mule 4 isolates the version of Spring used by the runtime from the one that is used by applications through the Spring Module, however it is not compatible with Mule 3 applications.
Answered By - aled
Answer Checked By - Cary Denson (JavaFixing Admin)