1
votes

I'm just upgrading from Spring 3.0.6 to 3.1 and there seems to be an issue with running it on a Tomcat. Appearently it has a Spring 3.0.6 dependency and will try to use it when started. That however conflicts with my Spring 3.1 app. I get this when trying to deploy via

mvn clean package tomcat:run

as well as when trying to run it in a Tomcat 7 (via Eclipse or by just copying it to the tomcat webapps folder)

What's the solution here? Might upgrading to Maven 3 help? What about the maven Tomcat-plugin? 1.1 is released so far but version 2 seems to be still under development. Does anyone have a pom setup that uses a 2.x version of the tomcat plugin?

(My current error log basicly says this:

java.lang.NoClassDefFoundError: org/springframework/core/annotation/AnnotationAttributes

which appearently is a version conflict between Spring 3.1 and 3.0.x)

I'm quite lost on this one, been trying all day to work my way through the dependency mess in my modules to upgrade them to 3.1, all the tests run and now I can't run it on Tomcat.. :(


edit: my spring dependency tree:

 module1:jar:1.0-SNAPSHOT:compile
 +- modul2:jar:1.0-SNAPSHOT:compile
 |  +- module3:jar:1.1-SNAPSHOT:compile
 |  |  +- org.springframework:spring-context:jar:3.1.1.RELEASE:compile
 |  |  +- org.springframework:spring-beans:jar:3.1.0.RELEASE:compile
 |  |  +- org.springframework:spring-aop:jar:3.1.0.RELEASE:compile
 |  |  +- org.springframework:spring-aspects:jar:3.1.0.RELEASE:compile
 |  |  +- org.springframework:spring-orm:jar:3.1.0.RELEASE:compile
 |  |  |  +- org.springframework:spring-jdbc:jar:3.1.0.RELEASE:compile
 |  |  |  \- org.springframework:spring-tx:jar:3.1.0.RELEASE:compile
 |  |  \- org.springframework:spring-core:jar:3.1.0.RELEASE:compile
 |  +- org.springframework:spring-webmvc:jar:3.1.0.RELEASE:compile
 |  |  +- org.springframework:spring-asm:jar:3.1.0.RELEASE:compile
 |  |  +- org.springframework:spring-context-support:jar:3.1.0.RELEASE:compile
 |  |  +- org.springframework:spring-expression:jar:3.1.0.RELEASE:compile
 |  |  \- org.springframework:spring-web:jar:3.1.0.RELEASE:compile
 |  \- org.springframework:spring-test:jar:3.1.0.RELEASE:compile
 \- org.springframework:spring-test-mvc:jar:1.0.0.BUILD-SNAPSHOT:test

edit 2:

For some curious reason, when I delete all Spring 3.0.6 libs from my .m2 folder and then package the webapp, it will download all the 3.0.6 jars again. The dependency tree however is the one above. I assume it has to do with spring-security which has some issue with the version and requires me to override the transient dependencies in my security module pom so it won't use the older ones...


edit 3:

It's spring-data-jpa. Appearently the latest version still depends on Spring 3.0.6. I can get it to play along with Spring 3.1 by overriding the dependencies in the pom, so the tests run through. When integrating my data module into my webapp however it will try to use Spring 3.0.6... No idea how to get around that problem. Even the latest Realase Candidate for spring-data-jpa (version 1.1.0.RC1) still depends on Spring 3.0.7...

2
Spring security has a different groupId and is hence not matched by org.springframework. see my updateSean Patrick Floyd
Ah, my bad. I meant spring-data-jpa. Spring security is fine.. Going module by module now, to catch the culprit.. Thank's for the maven and tomcat info though.. Another SO post suggests that there might be a tomcat problem (stackoverflow.com/questions/9496413/…)Pete

2 Answers

3
votes

On the console, execute this:

mvn dependency:tree -Dincludes=org.springframework,org.springframework.security

This will list all dependency paths to Spring artifacts. I am pretty sure you have a transitive dependency to some Spring 3.0.x artifact in there somewhere. Neither Maven nor Tomcat have any Spring dependencies!

Another thing you could check is the folder

src/main/webapp/WEB-INF/lib

If it exists (which it usually shouldn't in a maven webapp) it may contain an old Spring Jar. Delete that.

1
votes

So I figured it out.. The problem is that mvn dependency:tree doesn't really show the transient dependencies.

Spring-Data-Jpa 1.0.3.RELEASE has some Spring 3.0.6 dependencies. I have to override them explicitly in my data provider module to get the tests to run. That also keeps them from appearing in the dependency tree but it does not keep them out of my web app! I have to override all spring dependencies AGAIN in the web app and then it will work.

Not sure why that is.. Hopefully spring-data-jpa will upgrade to Spring 3.1 soon.. Maybe Maven 3 can handle those transient dependencies better but it will still use the old dependency:tree so in my case they wouldn't show..

parts of my webapp pom.xml:

<properties>
    <org.springframework-version>3.1.0.RELEASE</org.springframework-version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-asm</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>