Strange behavior in Spring3 JPA and Hibernate
Hi Friends I am getting this exception in my envt. and it is not fix when it will cause. I am using Spring 3, JPA and Hibernate and we use the EntityManager provided by server and the transaction is also provided by server. But the method which throws this exception does not annotated with @Transaction and no transaction is used. See the ex开发者_运维百科ception below
java.lang.NullPointerException
2011-04-27 13:10:56,141 ERROR [STDERR] at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.nextTimestamp(RegionFactoryCacheProviderBridge.java:85)
2011-04-27 13:10:56,141 ERROR [STDERR] at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:573)
2011-04-27 13:10:56,141 ERROR [STDERR] at org.hibernate.ejb.EntityManagerImpl.getRawSession(EntityManagerImpl.java:87)
2011-04-27 13:10:56,141 ERROR [STDERR] at org.hibernate.ejb.EntityManagerImpl.getSession(EntityManagerImpl.java:67)
2011-04-27 13:10:56,141 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:436)
2011-04-27 13:10:56,151 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:82)
2011-04-27 13:10:56,151 ERROR [STDERR] at org.hibernate.ejb.EntityManagerImpl.<init>(EntityManagerImpl.java:61)
2011-04-27 13:10:56,151 ERROR [STDERR] at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:39)
2011-04-27 13:10:56,151 ERROR [STDERR] at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:34)
2011-04-27 13:10:56,151 ERROR [STDERR] at org.jboss.jpa.injection.InjectedEntityManagerFactory.createEntityManager(InjectedEntityManagerFactory.java:82)
2011-04-27 13:10:56,177 ERROR [STDERR] at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:234)
<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for dev profile -->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="myPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/myDatasource</jta-data-source>
<!--Here I have my list of entity beans -->
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
<property name="jboss.entity.manager.factory.jndi.name" value="persistence-units/myPU"/>
</properties>
</persistence-unit>
</persistence>
Spring configuration
<context:annotation-config />
<context:component-scan base-package="my.package.name" />
<tx:annotation-driven transaction-manager="txManager"/>
<jee:jndi-lookup id="entityManagerFactory" jndi-name="persistence-units/myPU"/>
<bean
class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor" />
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManagerName" value="java:/TransactionManager"/>
<property name="userTransactionName" value="UserTransaction"/>
</bean>
精彩评论