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>开发者_如何学Python
<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>
[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.
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>
精彩评论