5

error message:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [config/spring/Hibernate-ctx.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IncompatibleClassChangeError: Implementing class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2820)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1150)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
    at java.lang.Class.getConstructor0(Class.java:2714)
    at java.lang.Class.getDeclaredConstructor(Class.java:2002)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:78)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newConfiguration(LocalSessionFactoryBean.java:772)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:517)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
    ... 23 more

Using tomcat 7 and maven build.

mvn dependency:tree -Dverbose gives following message:

C:\project>mvn dependency:tree -Dverbose
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ------------------------------------------------------------------------
[INFO] Building home-app
[INFO]    task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] [dependency:tree {execution: default-cli}]
[INFO] com.home.app:home-app:war:0.0.1
[INFO] +- org.springframework:spring-orm:jar:3.0.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
[INFO] |  |  \- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- org.springframework:spring-jdbc:jar:3.0.5.RELEASE:compile
[INFO] |  |  +- (org.springframework:spring-beans:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  |  +- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  |  \- (org.springframework:spring-tx:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  \- (org.springframework:spring-tx:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] +- log4j:log4j:jar:1.2.14:runtime (scope not updated to compile)
[INFO] +- mysql:mysql-connector-java:jar:5.1.17:compile
[INFO] +- org.hibernate:ejb3-persistence:pom:3.3.2.Beta1:compile
[INFO] +- org.hibernate:hibernate-core:jar:3.6.7.Final:compile
[INFO] |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  +- commons-collections:commons-collections:jar:3.1:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO] |  |  \- (org.slf4j:slf4j-api:jar:1.5.8:compile - omitted for conflict with 1.6.1)
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] |  +- javax.transaction:jta:jar:1.1:compile
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.6.1:compile - omitted for conflict with 1.5.8)
[INFO] +- commons-dbcp:commons-dbcp:jar:1.2.2:compile
[INFO] |  \- commons-pool:commons-pool:jar:1.3:compile
[INFO] +- org.springframework:spring-hibernate3:jar:2.0.8:compile
[INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.1:compile
[INFO] |  |  +- (log4j:log4j:jar:1.2.12:compile - omitted for conflict with 1.2.14)
[INFO] |  |  +- logkit:logkit:jar:1.0.1:compile
[INFO] |  |  +- avalon-framework:avalon-framework:jar:4.1.3:compile
[INFO] |  |  \- (javax.servlet:servlet-api:jar:2.3:compile - omitted for conflict with 3.0-alpha-1)
[INFO] |  +- org.hibernate:hibernate:jar:3.2.5.ga:compile
[INFO] |  |  +- net.sf.ehcache:ehcache:jar:1.2.3:compile
[INFO] |  |  |  +- (commons-logging:commons-logging:jar:1.0.4:compile - omitted for conflict with 1.
[INFO] |  |  |  \- (commons-collections:commons-collections:jar:2.1:compile - omitted for conflict w
[INFO] |  |  +- (javax.transaction:jta:jar:1.0.1B:compile - omitted for conflict with 1.1)
[INFO] |  |  +- (commons-logging:commons-logging:jar:1.0.4:compile - omitted for conflict with 1.1)
[INFO] |  |  +- asm:asm-attrs:jar:1.5.3:compile
[INFO] |  |  +- (dom4j:dom4j:jar:1.6.1:compile - omitted for duplicate)
[INFO] |  |  +- (antlr:antlr:jar:2.7.6:compile - omitted for duplicate)
[INFO] |  |  +- (cglib:cglib:jar:2.1_3:compile - omitted for conflict with 2.2.2)
[INFO] |  |  +- (asm:asm:jar:1.5.3:compile - omitted for conflict with 3.3.1)
[INFO] |  |  \- (commons-collections:commons-collections:jar:2.1.1:compile - omitted for conflict wi
[INFO] |  +- (org.springframework:spring-beans:jar:2.0.8:compile - omitted for conflict with 3.0.5.R
[INFO] |  +- (org.springframework:spring-context:jar:2.0.8:compile - omitted for conflict with 3.0.5
[INFO] |  +- (org.springframework:spring-core:jar:2.0.8:compile - omitted for conflict with 3.0.5.RE
[INFO] |  +- org.springframework:spring-dao:jar:2.0.8:compile
[INFO] |  |  +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
[INFO] |  |  +- (commons-logging:commons-logging:jar:1.1:compile - omitted for duplicate)
[INFO] |  |  +- (org.springframework:spring-beans:jar:2.0.8:compile - omitted for conflict with 3.0.
[INFO] |  |  +- (org.springframework:spring-context:jar:2.0.8:compile - omitted for duplicate)
[INFO] |  |  \- (org.springframework:spring-core:jar:2.0.8:compile - omitted for conflict with 3.0.5
[INFO] |  \- (org.springframework:spring-jdbc:jar:2.0.8:compile - omitted for conflict with 3.0.5.RE
[INFO] +- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
[INFO] |  \- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
[INFO] |  +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-asm:jar:3.0.5.RELEASE:compile - omitted for conflict with 3
[INFO] |  +- (org.springframework:spring-beans:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  \- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
[INFO] |  +- (org.springframework:spring-aop:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-beans:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-expression:jar:3.0.5.RELEASE:compile - omitted for duplicat
[INFO] |  \- (org.springframework:spring-asm:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-tx:jar:3.0.5.RELEASE:compile
[INFO] |  +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-aop:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-beans:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-context:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  \- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
[INFO] |  +- (org.springframework:spring-asm:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.1)
[INFO] +- cglib:cglib:jar:2.2.2:compile
[INFO] |  \- asm:asm:jar:3.3.1:compile
[INFO] +- org.springframework:spring-test:jar:3.0.6.RELEASE:test
[INFO] +- org.springframework:spring-asm:jar:3.0.6.RELEASE:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.5.8:runtime
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.5.8:runtime - omitted for conflict with 1.6.1)
[INFO] +- org.slf4j:slf4j-api:jar:1.5.8:runtime (scope not updated to compile)
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.8:runtime
[INFO] |  +- (org.slf4j:slf4j-api:jar:1.5.8:runtime - omitted for duplicate)
[INFO] |  \- (log4j:log4j:jar:1.2.14:runtime - omitted for duplicate)
[INFO] +- junit:junit:jar:4.9:compile
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.1:compile
[INFO] +- javassist:javassist:jar:3.12.1.GA:compile
[INFO] +- com.sun.faces:jsf-impl:jar:2.1.3:compile
[INFO] +- com.sun.faces:jsf-api:jar:2.1.3:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- javax.inject:javax.inject:jar:1:compile
[INFO] +- javax.servlet:servlet-api:jar:3.0-alpha-1:provided (scope not updated to compile)
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.2.1-b03:provided
[INFO] +- com.sun.el:el-ri:jar:1.0:provided
[INFO] \- org.springframework:spring:jar:2.5.6.SEC03:compile
[INFO]    \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.1)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Sun Sep 25 23:21:18 CEST 2011
[INFO] Final Memory: 16M/39M
[INFO] ------------------------------------------------------------------------

This is problem with duplicate of hibernate jar file. But i am not sure which one is duplicating here. My test class is executing fine. ie problem with tomcat.

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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.home.app</groupId>
    <artifactId>home-app</artifactId>
    <version>0.0.1</version>
    <packaging>war</packaging>

    <name>home-app</name>
    <url>http://maven.apache.org</url>
    <properties>
        <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
    </properties>
    <dependencyManagement>
        <dependencies>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <version>1.1</version>
                <configuration>
                    <url>http://localhost:8080/manager/html</url>
                    <server>myserver</server>
                    <path>/home-app</path>
                    <warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.17</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>


        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>ejb3-persistence</artifactId>
            <version>3.3.2.Beta1</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.7.Final</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-hibernate3</artifactId>
            <version>2.0.8</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>${org.springframework.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework.version}</version>
            <exclusions>
                <exclusion>
                    <artifactId>commons-logging</artifactId>
                    <groupId>commons-logging</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <type>jar</type>
            <version>${org.springframework.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.2.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>3.0.6.RELEASE</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-asm</artifactId>
            <version>3.0.6.RELEASE</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.5.8</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.5.8</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.8</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.9</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.12.1.GA</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.1.3</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.1.3</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>3.0-alpha-1</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.2.1-b03</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.el</groupId>
            <artifactId>el-ri</artifactId>
            <version>1.0</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>2.5.6.SEC03</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>jboss</id>
            <name>JBoss repository</name>
            <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
        </repository>
    </repositories>

</project>
TechFind
  • 3,696
  • 18
  • 47
  • 62

2 Answers2

3
[INFO] +- org.hibernate:hibernate-core:jar:3.6.7.Final:compile
[INFO] |  +- org.hibernate:hibernate:jar:3.2.5.ga:compile

These are (at least) mutually exclusive. I use "at least" since after you have put in place the exclusion rule you need to recheck your dependencies.

I would exclude the older 3.2.5.ga. Using the maven exclude mechanism inside the dependency for org.springframework:spring-hibernate3:jar:2.0.8:compile.

Darryl Miles
  • 4,576
  • 1
  • 21
  • 20
  • i have done for spring-hibernate3 like: hibernate org.hibernate but it is not working. – TechFind Sep 25 '11 at 22:34
  • You are going to need to post your whole pom.xml to make progress on that. When configured correctly the exclusions would work something like you indicate but Maven is a complexity unto itself and users of Maven often make simple mistakes in their configurations. If I was doing the work first hand it would be possible to achieve the necessary exclusion. – Darryl Miles Sep 25 '11 at 23:14
  • You have a mix of some spring versions "3.0.5.RELEASE" and "3.0.6.RELEASE" and some use of ${org.springframework.version}. [Don't mix versions use same version specifier]. You have a mix of it is normal for all things to be "compile" except for "mysql-connector-java" and various servlet specification JAR (these would be "provided" and found in the $CATALINA_BASE/lib of the tomcat install directory). It is very unusual to see "runtime" I think all these should be "compile". With the version information fixed for springframework yes the for the top entry should work. – Darryl Miles Sep 26 '11 at 11:37
  • 1
    Note you would have manually copied the mysql-connector-java-X.Y.Z-bin.jar into the $CATALINA_BASE/lib in order for provided to work. This is how I use SQL driver but it is possible to bundle them inside the WEB-INF/lib providing your understand the caveats to doing that. servlet-api, el-api, jsp-api are all correct being scope=provided. I see yet a 4th version of spring being used 2.5.6.SEC03 in the last entry, again use 3.0.6.RELEASE for all entries with *spring* in the name. – Darryl Miles Sep 26 '11 at 11:44
  • Add the exclusion to both the entries: org.springframeworkspring-orm... and also org.springframeworkspring-hibernate3 that should remove it from the dependency:tree but you need to fix all *spring* JARs to a single version 3.0.6.RELEASE looks best. (2.0.8 and 2.5.6.SEC03 really are causing you grief here) HTH – Darryl Miles Sep 26 '11 at 11:50
  • Re: junit test class is running ? I presume this is about changing scope=runtime have a look at the definitions for scope at http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope the "compile" is the most prevasive. If in doubt use "compile". "provided" is stuff the JDK or container provides from $CATALINA_BASE/lib. "runtime" is still not needed for compiling but the runtime might auto-detect, its unusual to use this and if you do you generally know what you are doing. Java Activation Framework might be something like this or SPI services. – Darryl Miles Sep 26 '11 at 11:58
  • 1)mysql driver made as provided. didnot copy jar to tomcat server lib since it is already present. 2) im using m2e plugin with eclipse, decides automatic scope for jar file( ie runtime/compile/provide/..), i didnt change other than tomcat container library ie(servlet-api,jsp-api, el-ri) to provided instead of compile. 3)http://mvnrepository.com/artifact/org.springframework all spring jar file doesn't have same version. some we need to use specific like spring-hibernate3(2.0.8) and spring(2.5.6.SEC03) which used 4 contextloaderlistner in web.xml file. 4) added exclude as u informed above. – TechFind Sep 26 '11 at 20:38
  • you can't mix spring versions, you need to resolve that some way first. all versions of artifactId that have "spring" in the name need to read the same version, best to go with something recent, 2.0.8 is really old now. I'm not sure m2e knows whats best, haha, thats never been the case for me when using it. maybe use the official spring repo at http://ebr.springsource.com/repository/app/library?query=S There is another non-obvious matter both springn and hibernate have changed their internal structures a lot over the range of versions your dependancies display.Read relevant release notes. – Darryl Miles Sep 26 '11 at 20:50
  • For example you may find if you look inside the 3.0.6.RELEASE JAR for spring-orm that is contains all the packages and classes that the older spring-orm and spring-hibernate3 (from 2.0.8 and 2.5.6.SECxx) had. Also the same kind of thing is true of hibernate-core and hibernate3. So you are mixing chalk with cheese. comment out all deps and see what breaks. Then reintroduce the most recent version of the component / artifactId to fix that eclipse error you see. Use 3.0.6.RELEASE if possible I can not believe you application is that complex to not work with this. – Darryl Miles Sep 26 '11 at 20:51
  • ok, if i replace for Spring(2.5.6.SEC03) and spring-hibernate3(2.0.8) with ${org.springframework.version}, pom.xml gives error message for install/build.( even maven repository shows 2.0.8 in my link given above) if you find dependency for above jar with 3.0.6 I will update directly in POM.xml instead of m2e dependency – TechFind Sep 26 '11 at 21:07
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/3804/discussion-between-darryl-miles-and-kasim) – Darryl Miles Sep 26 '11 at 21:31
1

i have the same problem

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class

to fix it replace

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate</artifactId>
        <version>3.2.6.ga</version>
    </dependency>

with

        <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.6.10.Final</version>
    </dependency>
nizar ouerghi
  • 1,721
  • 2
  • 14
  • 12