Could not open JPA EntityManager for transaction

阅读更多
Spring2.5+JPA+Struts1.3 整合开发出现了:Could not open JPA EntityManager for transaction;

总结了一下几点
1.数据库方言的问题 下列是各数据库方言
DB2  org.hibernate.dialect.DB2Dialect 
DB2 AS/400  org.hibernate.dialect.DB2400Dialect 
DB2 OS390  org.hibernate.dialect.DB2390Dialect 
PostgreSQL  org.hibernate.dialect.PostgreSQLDialect 
MySQL  org.hibernate.dialect.MySQLDialect 
MySQL with InnoDB  org.hibernate.dialect.MySQLInnoDBDialect 
MySQL with MyISAM  org.hibernate.dialect.MySQLMyISAMDialect 
Oracle (any version)  org.hibernate.dialect.OracleDialect 
Oracle 9i/10g  org.hibernate.dialect.Oracle9Dialect 
Sybase  org.hibernate.dialect.SybaseDialect 
Sybase Anywhere  org.hibernate.dialect.SybaseAnywhereDialect 
Microsoft SQL Server  org.hibernate.dialect.SQLServerDialect 
SAP DB  org.hibernate.dialect.SAPDBDialect 
Informix  org.hibernate.dialect.InformixDialect 
HypersonicSQL  org.hibernate.dialect.HSQLDialect 
Ingres  org.hibernate.dialect.IngresDialect 
Progress  org.hibernate.dialect.ProgressDialect 
Mckoi SQL  org.hibernate.dialect.MckoiDialect 
Interbase  org.hibernate.dialect.InterbaseDialect 
Pointbase  org.hibernate.dialect.PointbaseDialect 
FrontBase  org.hibernate.dialect.FrontbaseDialect 
Firebird  org.hibernate.dialect.FirebirdDialect

2.导入的jar包可能错误################################
dist\spring.jar  
dist\modules\spring-webmvc-struts.jar  
lib\jakarta-commons\commons-logging.jar、commons-dbcp.jar、commons-pool.jar  
lib\aspectj\aspectjweaver.jar、aspectjrt.jar  
lib\cglib\cglib-nodep-2.1_3.jar  
lib\j2ee\common-annotations.jar  
lib\log4j\log4j-1.2.15.jar  
 
加入jpa的hibernate的实现包  
 
这里JPA的实现采用hibernate,需要使用到下面的jar文件  
 
Hiberante核心包(8个文件)  
hibernate-distribution-3.3.1.GA  
---------------------------------------------  
hibernate3.jar  
lib\bytecode\cglib\hibernate-cglib-repack-2.1_3.jar  
lib\required\*.jar  
 
Hiberante注解包(3个文件):hibernate-annotations-3.4.0.GA  
------------------------------------------------------------------------------------  
hibernate-annotations.jar  
lib\ejb3-persistence.jar、hibernate-commons-annotations.jar  
 
Hibernate针对JPA的实现包(3个文件):hibernate-entitymanager-3.4.0.GA  
------------------------------------------------------------------------------------------------------  
hibernate-entitymanager.jar  
lib\test\log4j.jar、slf4j-log4j12.jar  

3.注意persistence.xml#####################

  
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">  
      
        
           
           
           
           
           
           
           
     
  
 
  


4.applicationContext.xml##################
  
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:context="http://www.springframework.org/schema/context" 
       xmlns:aop="http://www.springframework.org/schema/aop" 
       xmlns:tx="http://www.springframework.org/schema/tx" 
       xsi:schemaLocation="http://www.springframework.org/schema/beans  
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd  
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd  
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">  
      
       
       
       
  
     

  
    
  
      
 
  
    
  

你可能感兴趣的:(hibernate,spring,jpa,struts,sql)