-->
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 
Newbie

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:
Code:
    <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:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence    xmlns="http://xmlns.jcp.org/xml/ns/persistence"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
                version="2.1">
  <persistence-unit name="myPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <class>com.temp.MyEntity</class>
    <properties>
      <!-- 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" />
    </properties>
  </persistence-unit>
</persistence>

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

In my pom I have:
Code:
  <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.1.0.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>5.1.0.Final</version>
   </dependency>

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

How to fix it?

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

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


Top
 Profile  
 
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.