No Persistence Provider For EntityManager named

1,135 views
Skip to first unread message

Emrah Çetinkaya

unread,
Jun 25, 2015, 3:44:29 AM6/25/15
to op...@googlegroups.com
Hi all,

despite there are lots of examples and suggestions about jpa-osgi integration, I couldn't get rid of this error: "No Persistence Provider For EntityManager named deneme".

I am using karaf-4.0.0.M2 and try to integrate hibernate. In log file, I can see mapping is done succesfully. 

HHH000204: Processing PersistenceUnitInfo [  name: deneme     ...]
HHH000412: Hibernate Core {4.3.6.Final}
HHH000206: hibernate.properties not found
HHH000021: Bytecode provider name : javassist
Hibernate Commons Annotations {4.0.4.Final}
HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
HHH000397: Using ASTQueryTranslatorFactory
HHH000229: Running schema validator
HHH000102: Fetching database metadata
HHH000261: Table found: NBSDEV.DENEME
HHH000037: Columns: [aaa, sssorj


I got two bundles. One includes .xhtml pages and other one includes entity(called "Deneme") and beans. In entity-bean bundle, I got persistence and blueprint xml files under src/main/resources directory.
I also have "datasource-oracle.xml" in deploy folder. 


persistence.xml:
<persistence version="2.0"
<persistence-unit name="deneme" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/oracleds)</jta-data-source>
<class>jpa.entity.Deneme</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.hbm2ddl.auto" value="validate" />
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@//test11g-cluster/deneme" />
<property name="hibernate.show_sql" value="true" />
                        <property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
</persistence>


blueprint.xml:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint default-activation="eager"
<bean id="denemeService" class="jpa.entity.impl.DenemeServiceImpl">
<jpa:context unitname="deneme" property="entityManager" />
<tx:transaction method="*" value="Required" />
</bean>
<service ref="denemeService" interface="jpa.entity.DenemeService"/>
</blueprint>


I got the error when I try to create EntityManagerFactory object:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("deneme", System.getProperties());

I also used "JPA-PersistenceUnits" and "Meta-Persistence" tags  in manifest file as suggested.

Thanks for the help...



Charlie Mordant

unread,
Jun 25, 2015, 4:52:45 AM6/25/15
to op...@googlegroups.com

--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Charlie Mordant

Full OSGI/EE stack made with Karaf: https://github.com/OsgiliathEnterprise/net.osgiliath.parent

Christian Schneider

unread,
Jun 25, 2015, 5:16:58 AM6/25/15
to op...@googlegroups.com
The example configs provided point to that aries jpa is used. There the blueprint looks correct.
I think the reason is that aries jpa finds no suitable persistence provider.

In persistence.xml the persistence provider is set to "org.hibernate.jpa.HibernatePersistenceProvider".
So perhaps there is no suitable persistence provider installed.

You can use "service:list PersistenceProvider" to see which providers are installed.
This is what it shows for me:
[javax.persistence.spi.PersistenceProvider]
-------------------------------------------
 javax.persistence.provider = org.hibernate.jpa.HibernatePersistenceProvider
 service.id = 601
 service.bundleid = 275
 service.scope = bundle
Provided by :
 hibernate-osgi (275)

The service property "javax.persistence.provider" will have to match the name given in persistence.xml.
So
It should work if you do feature:install hibernate/4.3.6.Final .

Christian
-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Emrah Çetinkaya

unread,
Jun 25, 2015, 7:16:32 AM6/25/15
to op...@googlegroups.com
Hi,

 thanks for the suggestions. When I type "service:list PersistenceProvider", karaf shows me:

[javax.persistence.spi.PersistenceProvider]
-------------------------------------------
 javax.persistence.provider = org.hibernate.jpa.HibernatePersistenceProvider
 service.id = 160
Provided by : 
 hibernate-osgi (459)

I can't see "service.bundleid" and "service.scope" attributes and don't know whether they are necessary.

I also tired "@Setter" annotation for my entitymanager propery. I got "NullPointerException" during the "getCriteriaBuilder()" method call.

Emrah Çetinkaya

unread,
Jun 26, 2015, 3:29:36 AM6/26/15
to op...@googlegroups.com

Hi,

I solved my problem by doing two things:

Firstly, I imported "org.hibernate.jpa" package into my bundles(xhtml bundle and entity-bean bundle). I also imported "org.hibernate.ejb" into my xhtml bundle after getting "Class Not Found Exception."
After this, I got "Null Pointer Exception" at "org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus" method. So secondly, I changed my persistence.xml and get rid of the problem:

<persistence-unit name="deneme" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<non-jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/oracleds)</non-jta-data-source>
<class>jpa.entity.Deneme</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.hbm2ddl.auto" value="validate" />
<property name="hibernate.show_sql" value="true" />
                        <property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
</persistence>

I changed value of "transaction-type" attribute from "JTA" to "RESOURCE_LOCAL" and "jata-data-source" attibute to "non-jta-data-source". 

Christian Schneider

unread,
Jun 26, 2015, 3:38:47 AM6/26/15
to op...@googlegroups.com
Good you solved the problem so you can proceed with your code.

I am pretty sure though that there is some error in how you work with jpa. You should not need to import the provider specific packages into your own bundles as long as you just use jpa in an OSGi compatible way.

If you could provide a small example of how you use jpa to a github repo I am willing to look into the code to see if there is some problem.

Christian
--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages