Tuesday, July 2, 2013

IncompatibleClassChangeError in spring mvc


Sometime while doing the spring mvc projects we may run with the problems as specified.


java.lang.IncompatibleClassChangeError: org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor



In order to solve this we should apply the little tricks. i.e the error is due to the mismatch of the spring version meaning that we are dealing with spring 3.1 and 3.2 on the class path. So the best way to solve this by using maven is to define the version in the properties.


<properties>
    <spring.version>3.1.0.RELEASE</spring.version>
</properties>

    <dependencies>
        <!-- Spring core & mvc -->
        <dependency>
            <groupid>org.springframework</groupid>
            <artifactid>spring-context</artifactid>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupid>org.springframework</groupid>
            <artifactid>spring-webmvc</artifactid>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupid>org.springframework</groupid>
            <artifactid>spring-orm</artifactid>
            <version>${spring.version}</version>
        </dependency>

</dependencies>