Hi Nicolas,

maybe you can take a look on:

https://github.com/jbonofre/acna15/tree/master/persistence

It shows the use of persistence.xml in a bundle to create the entity manager and expose a DAO as service.

Especially you have to define the persistence.xml in the MANIFEST using the following configuration statement to the maven-bundle-plugin:

<Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>

Regards
JB

On 05/28/2017 10:29 AM, Nicolas_cage wrote:
friends I'm new to Karaf, I'm trying to create entity manager factory using
the below code but unable to create it

Code:
  new HibernateOgmPersistence().createEntityManagerFactory("MY_PU", props);

persistence.xml:

        <persistence-unit name="MY_PU" transaction-type="RESOURCE_LOCAL">
                
                
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
                <class>internal_class</class>
                <properties>
                        <property name="hibernate.ogm.datastore.provider"
                        
value="org.hibernate.ogm.datastore.cassandra.impl.CassandraDatastoreProvider"
/>
                        <property name="hibernate.ogm.datastore.host" 
value="localhost" />
                        <property name="hibernate.ogm.datastore.port" value="9142" 
/>
                        <property name="hibernate.ogm.datastore.database" 
value="ALPHA" />
                        <property name="hibernate.ogm.datastore.grid_dialect"
                                
value="org.hibernate.ogm.datastore.cassandra.CassandraDialect" />
                </properties>
        </persistence-unit>

My persistence.xml file location is in
src/main/resources/META-INF/persistence.xml, However if I try using
Persistence.createEntityManagerFactory, I get

Exception in thread "main" javax.persistence.PersistenceException: No
Persistence provider for EntityManager named MY_PU. Please help how I can
overcome this issue

I tried below options:

1. Placed  META-INF/persistence.xml under src/main/java.
2. Made configuration changes in eclipse to remove the resource folder's
excluded list from *.* to None.
3. Tried creating entity manager using new
PersistenceProvider().createEntityManagerFactory("MY_PU")
4. Tried with Eclipselink

But none of the above steps solved my issue. How can I make Karaf identify
the persistence.xml file location and make it read the persistence units. I
saw some post on making ConfigAdmin service configuration, can someone
thrown some light on ConfigAdmin service with sample code.

Thanks





--
View this message in context: 
http://karaf.922171.n3.nabble.com/Unable-to-create-EntityManagerFactory-tp4050478.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.


--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to