嗨朋友们 我在我的环境中得到了这个例外。它会导致它无法修复。我使用Spring 3,JPA和Hibernate,我们使用服务器提供的EntityManager,服务器也提供事务。但是抛出此异常的方法没有使用@Transaction注释,也没有使用任何事务。请参阅以下例外
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配置
<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>