ClassCastException异常InjectedDataSourceConnectionProvider弹簧3.1.0,休眠4,JPA EntityManagerFactory的
使用:ClassCastException异常InjectedDataSourceConnectionProvider弹簧3.1.0,休眠4,JPA EntityManagerFactory的
- 弹簧3.1.0
- 休眠4
- JPA 2
- GWT 2.3.0。
[类似于Exception in GWT Dev Mode + Spring 3.1 + Hibernate 4.0.1]
当运行一个非常简单的GWT应用程序(使用问候服务)并添加一个弹簧配置,以应用程序(通过web.xml和相关的弹簧的配置文件),异常系统以gwt dev模式启动时(从Eclipse内部和命令行(mvn gwt:run))启动。
例外如下:
[WARN]嵌套在org.springframework.beans.factory.BeanCreationException:错误创建具有名称豆 'jgkgwtclasscastissueEntityManagerFactory' 在ServletContext的资源定义[/ WEB-INF /类/spring-main-config.xml]:调用init方法失败;嵌套异常是javax.persistence.PersistenceException:[PersistenceUnit:jgkgwtclasscastissue-PU]无法构建EntityManagerFactory:java.lang.ClassCastException:org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider无法转换为org.hibernate.service.jdbc.connections。 spi.ConnectionProvider
的pom.xml
<?xml version="1.0" encoding="UTF-8"?> <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">
<!-- POM file generated with GWT webAppCreator -->
<modelVersion>4.0.0</modelVersion>
<groupId>com.gs</groupId>
<artifactId>jgkgwtclasscastissue</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>GWT Maven Archetype</name>
<properties>
<gwtVersion>2.3.0</gwtVersion>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName} </webappDirectory>
<antlr.version>2.7.6</antlr.version>
<aopalliance.version>1.0</aopalliance.version>
<c3p0.version>0.9.1.2</c3p0.version>
<cglib.version>2.2.2</cglib.version>
<commons-beanutils.version>1.8.3</commons-beanutils.version>
<commons-collections.version>3.1</commons-collections.version>
<commons-logging.version>1.1.1</commons-logging.version>
<ojdbc6.version>11.1.0.7.0</ojdbc6.version>
<commons-dbcp.version>1.4</commons-dbcp.version>
<dom4j.version>1.6.1</dom4j.version>
<ehcache.version>2.4.6</ehcache.version>
<javassist.version>3.9.0.GA</javassist.version>
<javax.inject.version>1.0-PFD-1</javax.inject.version>
<javax.transaction.version>1.1</javax.transaction.version>
<junit.version>4.9</junit.version>
<log4j.version>1.2.16</log4j.version>
<slf4j-api.version>1.6.1</slf4j-api.version>
<slf4j-log4j12.version>1.6.1</slf4j-log4j12.version>
<org.aspectj.version>1.6.10</org.aspectj.version>
<org.hibernate.version>4.0.0.Final</org.hibernate.version>
<org.hibernate-commons-annotations.version>4.0.1.Final</org.hibernate-commons-annotations.version>
<org.hibernate.hibernate-validator.version>4.1.0.Final</org.hibernate.hibernate-validator.version>
<org.hibernate.jpamodelgen.version>1.1.1.Final</org.hibernate.jpamodelgen.version>
<org.springframework.version>3.1.0.RELEASE</org.springframework.version>
<org.springframework.data.version>1.0.1.RELEASE</org.springframework.data.version>
<wagon-ssh.version>1.0-beta-6</wagon-ssh.version>
</properties>
<dependencies>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-api.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j-log4j12.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.3.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>${org.hibernate-commons-annotations.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${org.hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${org.hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>${org.hibernate.version}</version>
</dependency>
<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-aspects</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</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-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</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-jms</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</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>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>${aopalliance.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${org.aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-instrument</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-instrument-tomcat</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>${org.springframework.data.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons-core</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>${ojdbc6.version}</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>${commons-beanutils.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${org.hibernate.jpamodelgen.version}</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>${commons-dbcp.version}</version>
</dependency>
</dependencies>
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<plugins>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.3.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>i18n</goal>
<goal>generateAsync</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>jgkgwtclasscastissue.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<i18nMessagesBundle>com.gs.client.Messages</i18nMessagesBundle>
</configuration>
</plugin>
<!-- Copy static web files before executing gwt:run -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
目前尚不清楚问题的所在。有什么建议么?
回答:
尝试Hibernate(3.3)和Spring(3.0.7)的最早版本。通常不可能一起使用最新版本 - 发生不可思议的异常。
回答:
我记得有时候会有相同的问题,在我的lib /我有ejb3-persistence.jar与hibernate-jpa-2.0-api-1.0.1.Final.jar冲突,通过升级到休眠4引入和Spring 3.1.1,我摆脱了ejb3-persistence.jar并且对javax.persistence.PersistenceException: [PersistenceUnit: jgkgwtclasscastissue-PU] Unable to build EntityManagerFactory: java.lang.ClassCastException
进行了排序。
尝试Hibernate(3.3)和Spring(3.0.7)的最早版本。通常不可能一起使用最新版本 - 发生不可思议的异常。这里
回答:
同样的问题发现:Exception in GWT Dev Mode + Spring 3.1 + Hibernate 4.0.1
它来自于Hibernate的类加载器的问题,这似乎与GWT /码头壳模式不兼容。该错误仍然在Hibernate上打开,但您可以应用补丁(请参阅https://hibernate.onjira.com/browse/HHH-7084)
以上是 ClassCastException异常InjectedDataSourceConnectionProvider弹簧3.1.0,休眠4,JPA EntityManagerFactory的 的全部内容, 来源链接: utcz.com/qa/266713.html