These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]

Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate and OSGI - No Persistence provider for EntityManag
PostPosted: Tue May 03, 2016 11:05 am 

Joined: Tue May 03, 2016 11:02 am
Posts: 2
I have a standalone JavaSE application and java 8.

I use osgi framework and these are the bundles I install:
    <bundle name="hibernate-core-5.1.0.Final.jar"/>
    <bundle name="hibernate-jpa-2.1-api-1.0.0.Final.jar"/>
    <bundle name="hibernate-entitymanager-5.1.0.Final.jar"/>

This is my persistence.xml file which is located in META-INF folder of my bundle:
<?xml version="1.0" encoding="UTF-8"?>
<persistence    xmlns="http://xmlns.jcp.org/xml/ns/persistence"
                xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
  <persistence-unit name="myPersistenceUnit" transaction-type="RESOURCE_LOCAL">
      <!-- Configuring JDBC properties -->
    <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
    <property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://localhost//home/data/database"/>
    <property name="javax.persistence.jdbc.user" value="sa"/>
    <property name="javax.persistence.jdbc.password" value=""/>
      <!-- Hibernate properties -->
      <property name="hibernate.show_sql" value="true" />
      <property name="hibernate.format_sql" value="true" />
      <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
      <property name="hibernate.hbm2ddl.auto" value="validate" />
      <!-- Configuring Connection Pool -->
      <property name="hibernate.c3p0.min_size" value="5" />
      <property name="hibernate.c3p0.max_size" value="20" />
      <property name="hibernate.c3p0.timeout" value="500" />
      <property name="hibernate.c3p0.max_statements" value="50" />
      <property name="hibernate.c3p0.idle_test_period" value="2000" />

This is the way I create EntityManagerFactory:
EntityManagerFactory emf=Persistence.createEntityManagerFactory("myPersistenceUnit");

In my pom I have:

And this is what I get
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named myPersistenceUnit

How to fix it?

I even tried in karaf:
feature:install transaction
feature:install jpa
feature:install hibernate

after that I install and start my bundle. The same result.

Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.