Search code examples
mavendependenciesjavabeansspring-integration

Maven downloading incorrect Spring jar versions


I have been trying to find a way to resolve this issue for a while now without any success. The Namespaces I am using in my bean xml are as follows:

<?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:int="http://www.springframework.org/schema/integration"
   xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
   xsi:schemaLocation="http://www.springframework.org/schema/integration
    http://www.springframework.org/schema/integration/spring-integration.xsd
    http://www.springframework.org/schema/integration/jdbc
    http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/security 
    http://www.springframework.org/schema/security/spring-security.xsd">



<beans profile="dev, local">
    <bean id="emailVerificationMessageStore" class="org.springframework.integration.store.SimpleMessageStore"/>
</beans>
<beans profile="production, staging">
    <int-jdbc:message-store id="emailVerificationMessageStore" data-source="dataSource" region="emailVerification"/>
</beans>

The profile elements are at the end of the file as shown above. When I deploy to my tomcat server I am seeing the following errors:

 Line 58 in XML document from URL [file:/var/lib/tomcat6/webapps/project/WEB-INF/classes/META-INF/spring/context.xml]
 is invalid; nested exception is org.xml.sax.SAXParseException; 
 lineNumber: 58; columnNumber: 33;
 cvc-complex-type.2.4.a: Invalid content was found starting with element 'beans'.
 One of '{"http://www.springframework.org/schema/beans":import,
 "http://www.springframework.org/schema/beans":alias, 
 "http://www.springframework.org/schema/beans":bean, 
 WC[##other:"http://www.springframework.org/schema/beans"]}' is expected.

I ran mvn dependency:tree to see that maven was downloading the correct jar versions, it seems that even though i have specified the latest versions in Pom.Xml it is downloading 3.0.0 jars:

 --- maven-dependency-plugin:2.8:tree (default-cli) @ services ---
 Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-aop/3.0.0.RC3/spring-aop-3.0.0.RC3.jar
 Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-context/3.0.0.RC3/spring-context-3.0.0.RC3.jar
 Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-asm/3.0.0.RC3/spring-asm-3.0.0.RC3.jar
 Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-core/3.0.0.RC3/spring-core-3.0.0.RC3.jar
 Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-beans/3.0.0.RC3/spring-beans-3.0.0.RC3.ja

how can i force maven to download a later version of the jar?


Solution

  • found the answer to this using eclipse's Dependancy hierarchy tool , it seems importing a Jersey jar includes Spring 3.0.0 and therefore overrides my other jars.

    Adding this has resolved the issue:

    <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-spring</artifactId>
            <version>1.8</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-web</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context</artifactId>
                </exclusion>
            </exclusions>
        </dependency>