Application Managed EntityManager JBoss AS 7.1.1
mbuamuh Apr 12, 2013 10:16 AMHi,
i am using an application managed Entity manager and get it using the following code:
private static String persistenceUnitName="eccore-ejb";
private EntityManager getEntityManager() {
EntityManagerFactory entityManagerFactory = Persistence .createEntityManagerFactory(persistenceUnitName);
EntityManager entityManager = entityManagerFactory .createEntityManager();
return entityManager;
}
But i keep getting an exception that there is no persistent provider. However my server logs show that the default persistence provider org.hibernate.ejb.HibernatePersistence is being used for that Persistence Unit. Following is my persistence.xml content and the error message. Does anyone have an idea what i might be doing wrong or come across this and how did they solve it?
persistence:persistence version="2.0" xmlns:persistence="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_2_0.xsd "
>
<persistence:persistence-unit name="eccore-ejb" transaction-type="JTA"
>
<persistence:provider>org.hibernate.ejb.HibernatePersistence</persistence:provider
>
<persistence:jta-data-source>java:jboss/datasources/ECPM_DEV</persistence:jta-data-source
>
<persistence:jar-file>com.ec.eccore-ejb-0.0.1-SNAPSHOT</persistence:jar-file
>
<persistence:class>com.ec.eccore.util.resourcebundle.model.entities.BasisLanguageEntity</persistence:class
>
<persistence:class>com.ec.eccore.util.resourcebundle.model.entities.LanguageSourceEntity</persistence:class
>
<persistence:class>com.ec.eccore.util.resourcebundle.model.entities.LanguageTargetEntity</persistence:class
>
<persistence:shared-cache-mode>ENABLE_SELECTIVE</persistence:shared-cache-mode
>
<persistence:properties
>
<persistence:property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"
/>
<persistence:property name="hibernate.show_sql" value="true"
/>
<persistence:property name="hibernate.cache.provider_class" value="org.hibernate.cache.SingletonEhCacheProvider"
/>
<persistence:property name="hibernate.cache.use_second_level_cache" value="true"
/>
<persistence:property name="hibernate.cache.use_query_cache" value="true"
/>
<!-- The region factory property is the "new" property (for Hibernate
3.3 and above) -->
<!--property name="hibernate.cache.region.factory_class" value="net.sf.ehcache.hibernate.EhCacheRegionFactory"/ -->
</persistence:properties
>
</persistence:persistence-unit
>
</
persistence:persistence
>
Caused by:
javax.persistence.PersistenceException
: No Persistence provider for EntityManager named eccore-ejb
at javax.persistence.Persistence.createEntityManagerFactory(
Persistence.java:69
) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at javax.persistence.Persistence.createEntityManagerFactory(
Persistence.java:47
) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at com.ec.eccore.util.security.ObjectAccessInfoVer3.getEntityManager(
ObjectAccessInfoVer3.java:78
) [com.ec.eccore-ejb-0.0.1-SNAPSHOT.jar:]