SPRING MVC 3.2.2 + SPRING SECURITY 3.1.3不兼容性java.lang.IncompatibleClassChangeError

时间:2013-04-25 11:03:18

标签: java spring maven spring-mvc spring-security


我已将应用程序中的spring security的版本从3.2.0.M1更改为3.1.3但是当Tomcat启动我的应用程序时出错。 异常堆栈的第一行如下:

2013-04-25 11:33:12,893 [localhost-startStop-1] ERROR org.springframework.web.context.ContextLoader - org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [C:\Users\daniele\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Ice-Cream-Webapp\WEB-INF\classes\com\myprj\app\web\controller\FrontPagesController.class]; nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class

我的pom.xml是:

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company</groupId>
<artifactId>myprj-Webapp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>

<name>myprj-Webapp</name>
<url>http://www.company.com</url>

<properties>
    <org.springframework.version>3.2.2.RELEASE</org.springframework.version>
    <org.springframework.test.version>3.2.2.RELEASE</org.springframework.test.version>
    <org.springframework.security.version>3.1.3.RELEASE</org.springframework.security.version>
    <org.springframework.security.oauth.version>1.0.2.RELEASE</org.springframework.security.oauth.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
        <version>${org.springframework.security.version}</version>
    </dependency>

    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security.oauth</groupId>
        <artifactId>spring-security-oauth2</artifactId>
        <version>${org.springframework.security.oauth.version}</version>
    </dependency>

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

    <dependency>
        <groupId>net.sourceforge.findbugs</groupId>
        <artifactId>annotations</artifactId>
        <version>1.3.2</version>
    </dependency>

    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-servlet-api</artifactId>
        <version>7.0.34</version>
        <scope>provided</scope>
    </dependency>

    <!-- Test dependencies -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${org.springframework.test.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>org.springframework.maven.milestone</id>
        <name>Spring Maven Milestone Repository</name>
        <url>http://maven.springframework.org/milestone</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

<build>
    <finalName>myprj-Webapp</finalName>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

有一天我正在研究这个问题,我仍然不知道造成这种冲突的家属是哪一个。
有什么想法吗?

3 个答案:

答案 0 :(得分:2)

使用mvn dependency:tree查找您正在获取的依赖项。

看起来你的spring-asm jar因为帖子3.2导致了这个问题,所有这些都合并到了spring-core

答案 1 :(得分:2)

从spring-security依赖项中排除spring asm

<exclusions>
    <exclusion>
        <groupId>org.springframework</groupId>
        <artifactId>spring-asm</artifactId>
    </exclusion>
</exclusions>

答案 2 :(得分:1)

进入类似问题,通过添加

解决了问题
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${org.springframework.version}</version>
</dependency>