Я попытался перенести проект из GlassFish в Weblogic 12c.Weblogic 12c with Hibernate 4.2.17 Ошибка JTA
Я использую Hibernate 4.2.17, и я получил следующую ошибку , когда мой код вызывается для создания EntityManager в контейнере.
Caused By: java.lang.NullPointerException
at org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory.isJoinableJtaTransaction(CMTTransactionFactory.java:63)
at org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory.isJoinableJtaTransaction(CMTTransactionFactory.java:39)
at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.isTransactionJoinable(TransactionCoordinatorImpl.java:311)
at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1215)
at org.hibernate.ejb.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:178)
at org.hibernate.ejb.EntityManagerImpl.<init>(EntityManagerImpl.java:89)
at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:193)
at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:188)
at weblogic.persistence.PersistenceContextWrapper.<init>(PersistenceContextWrapper.java:26)
at weblogic.persistence.TransactionalEntityManagerProxyImpl.newPersistenceContext(TransactionalEntityManagerProxyImpl.java:152)
at weblogic.persistence.TransactionalEntityManagerProxyImpl.getPersistenceContext(TransactionalEntityManagerProxyImpl.java:128)
at weblogic.persistence.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:94)
at weblogic.persistence.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:164)
at weblogic.persistence.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:86)
at com.sun.proxy.$Proxy346.createNamedQuery(Unknown Source)
at rpm.jpa.crudservice.RpmJPAServiceImpl.findByNamedQuerySingle(RpmJPAServiceImpl.java:302)
persistence.xml:
<persistence-unit name="My_JPA_UNIT" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>MyDS</jta-data-source>
<class>....</class>
<class>....</class>
<properties>
<property name="hibernate.generate_statistics" value="false" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.level" value="ALL" />
<property name="hibernate.logging.level" value="ALL" />
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServer2008Dialect" />
<property name="hibernate.transaction.jta.platform" value="org.hibernate.engine.transaction.jta.platform.internal.WebLogicJtaPlatform" />
</properties>
</persistence-unit>
Мой код:
@Stateless
@Local(RpmJPAService.class)
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class RpmJPAServiceImpl implements RpmJPAService
{
@PersistenceContext(unitName = "My_JPA_UNIT")
EntityManager em;
@SuppressWarnings("unchecked")
@Override
public <T>T findByNamedQuerySingle(final String queryName, final Object... parameters) throws PsAccessException
{
logQueryNameAndParameters(queryName, parameters);
try
{
(line 302) final Query q = setQueryParameters(em.createNamedQuery(queryName), parameters);
return (T) q.getSingleResult();
}
catch(final NoResultException nre)
{
return null;
}
catch(final PersistenceException pe)
{
throw handleQuerySingleException(pe);
}
}
}
Любой испытал эту ошибку?