You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by smunro <st...@gmail.com> on 2017/06/06 09:47:28 UTC

Hibernate, JPA and Karaf 4

Hello,

I am trying to get JPA & Hibernate working in a OSGI bundle, deployed on
Karaf 4.0.8. 
Regardless of what tutorials or guides I follow, I am met with the following
log entry:

org.desolateplanet.authentication-db-impl/0.0.9.SNAPSHOT is waiting for
namespace handlers [http://aries.apache.org/xmlns/jpa/v1.0.0]

The entity manager is never injected via blueprint as the breakpoint I set
is never hit. 

I'd had more success with direct JDBC, but I don't want to resort to that
just yet in case I'm missing something silly. I've attached the
blueprint/pom/persistence.xml below for reference.

== POM dependencies ==
 <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>authentication-api</artifactId>              
        </dependency> 
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi</artifactId>
        </dependency> 
        
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.util.tracker</artifactId>
        </dependency>        
        
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
        </dependency>
            
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.service.cm</artifactId>
        </dependency>
                 
        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>javax.transaction-api</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.174</version>
        </dependency>
        
       
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.enterprise</artifactId>
            <version>4.2.0</version>
        </dependency>
       

        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <version>1.0.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.3.6.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-osgi</artifactId>
            <version>4.3.6.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.3.6.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate.common</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>4.0.4.Final</version>
        </dependency>
    </dependencies>

== Persistence.xml ==
<persistence version="2.1" 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">
  <persistence-unit name="authentication" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>osgi:service/authentication</jta-data-source>
    <properties>
      <property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect"/>
    </properties>
  </persistence-unit>
</persistence>

== blueprint.xml ==
<blueprint default-activation="eager"
           xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
           xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
           
    

    <bean id="accountStore"
class="org.desolateplanet.security.impl.AccountStoreImpl">     
        <jpa:context unitname="authentication" property="entityManager"/>
        <tx:transaction method="*" value="Required"/>
    </bean>
  

</blueprint>







--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
jpa                  | 2.3.0            |          | Started |
enterprise-4.0.8
        | OSGi Persistence Container
hibernate            | 3.3.2.GA         |          | Started |
enterprise-4.0.8
        | Hibernate 3.x JPA persistence engine support
hibernate            | 4.3.6.Final      |          | Started |
enterprise-4.0.8
        | Hibernate 4.3.x JPA persistence engine support



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050575.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Can you paste the output of:

feature:list -i|grep -i jpa

?

Thanks,
Regards
JB

On 06/06/2017 01:15 PM, smunro wrote:
> Hello jbonofre,
> 
> Thanks for the swift reply. Not sure if this answers your question, but I
> have the following feature running:
> 
> hibernate                     | 4.3.6.Final      | x        | Started
> enterprise-4.0.8         | Hibernate 4.3.x JPA persistence engine support
> 
> And my feature file has the following entries:
> 
>              <feature>jndi</feature>
>              <feature>jdbc</feature>
>              <feature>pax-jdbc-h2</feature>
>              <feature>pax-jdbc-pool-dbcp2</feature>
>              <feature>pax-jdbc-config</feature>
>              <feature>jpa</feature>
>              <feature>hibernate</feature>
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050572.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Updated blueprint:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"
           xmlns:tx="http://aries.apache.org/xmlns/transactions/v2.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
           http://aries.apache.org/xmlns/jpa/v2.0.0
           http://aries.apache.org/xmlns/transactions/v2.0.0">
           
    
    <jpa:enable/>
    <tx:enable/>
    
    <bean id="accountStore"
class="org.desolateplanet.auth.security.db.impl.AccountStoreImpl">     
        
    </bean>
  

</blueprint>



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050577.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Hi,

Stephen,I'm new to Karaf. 

I though  if I wrap the bundle it will available to the container.
<bundle>wrap:...</bundle>

I have removed the zip file and I have checked-in all the folders and files
in to GitHub.

Link @ https://github.com/JackMic/Hibernate-Postgressql-Karaf-4.1.0

I took fresh Karaf and deployed my kar file, but even though I'm not able to
find the datasource. I could able to find persistence providers using this
command "service:list PersistenceProvider "

Let me figure out how datasource can make available to the container.
Ideally I place my datasource file in etc folder of Karaf, it should make
available to the container.
<http://karaf.922171.n3.nabble.com/file/n4050654/Datasource.png> 






--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050654.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
What you have done with the <bundle>wrap:...</bundle> is load the jdbc driver
into karaf, but the pax-jdbc-postgresql provides the capability to register
a postgres data source, so that's something different (at least to my
knowledge).

When you added this feature and deployed to karaf, was the data source
available?

As a minor thing, can you do a karaf clean just to make sure your starting
from a fresh setup.

I can offer a bit more help later, but it might be better if you change your
git project to remove the zip file and just check in the project folders.
It'll be easier for someone to change and submit a pull request.

I'd begin with trying to workout why the data source is not listed in karaf,
that's certainly your first problem.  Looking at the previous error logs,
hibernate cannot connect as there is no data source available, so take a
step back and look at your data source setup.



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050651.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Jack,

See here:
https://ops4j1.jira.com/wiki/display/PAXJDBC/Create+DataSource+from+config

It's not username. The parameter is user.



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050658.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Stephen,

I have already created Schema, inspite of this i'm getting this error.

I'm suspecting their is some problem with this error "Unexpected problem
updating configuration org.apache.aries.jpa.store".

Let me figure out.



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050668.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Jack,

The logs clearly show that the database hasn't been created:
""localhost:5432:TEST" does not exist"

Try creating the schema in postgres then re-run.



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050661.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
thanks Stephen, I made correction. Now i'm not seeing the error

thanks schneider for making the changes, after building and deploying the
kar file, the application status shows in grace period and in the log I can
see this error

waiting for dependencies
[(&(osgi.unit.name=store)(objectClass=javax.persistence.EntityManager))]

log.txt <http://karaf.922171.n3.nabble.com/file/n4050660/log.txt>  


list.PNG <http://karaf.922171.n3.nabble.com/file/n4050660/list.PNG>  



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050660.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Christian Schneider <ch...@die-schneider.net>.
I did a PR with some fixes.

https://github.com/JackMic/Hibernate-Postgressql-Karaf-4.1.0/pull/1

Christian

On 10.06.2017 11:08, Jack wrote:
> Stephen, I have shared all the code here
> https://github.com/JackMic/Hibernate-Postgressql-Karaf-4.1.0
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050657.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


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

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


Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Stephen, I have shared all the code here
https://github.com/JackMic/Hibernate-Postgressql-Karaf-4.1.0



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050657.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Jack, the first error in the logs is the following:

org.ops4j.pax.jdbc.config - 1.0.0 | Unsupported property name: username
org.postgresql.util.PSQLException: Unsupported property name: username

Can you share your data source config?



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050656.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Hi Schneider,

Thanks for the information.

I have made the changes to the datasource config file,osgi.jdbc.driver.class
= org.postgresql.Driver .

After building and deploying the kar file in Karaf, datasource is not
available. But persistence providers are available. I'm not sure what wrongs
with the config file.

<http://karaf.922171.n3.nabble.com/file/n4050655/Datasource.png> 






--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050655.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Christian Schneider <ch...@die-schneider.net>.
This looks better now. Your bundle is now waiting for the EntityManager 
service:

DemoProject.DemoData/0.0.1.SNAPSHOT due to unresolved dependencies
[(&(osgi.unit.name=store)(objectClass=javax.persistence.EntityManager))]

This is created by aries jpa from the information in the persistence.xml.
Things you need to check now:
Is your persistence.xml picked up? You should see this in the log.

Do you have a suitable PersistenceProvider service?
service:list PersistenceProvider

Do you have a suitable DataSource service?
service:list DataSource

Christian

On 09.06.2017 12:53, Jack wrote:
> Hi Stephen,
>
> I have removed <jpa:context> and <tx:transaction> tags in xml file and added
>
> <jpa:enable/> and <tx:enable/>
>
> Below is my blueprint file
>
> <?xml version="1.0" encoding="UTF-8"?>
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>             xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"
>             xmlns:tx="http://aries.apache.org/xmlns/transactions/v2.0.0"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>             xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
> https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
>             http://aries.apache.org/xmlns/jpa/v2.0.0
>             http://aries.apache.org/xmlns/transactions/v2.0.0">
>             
>       <jpa:enable/>
>      <tx:enable/>
> 	
> 	<bean id="storeDaoImpl" class="com.data.dao.impl.StoreDaoImpl" >
> 	
> 	</bean>
> 	
> 	<service id="storeDao" ref="storeDaoImpl"
> interface="com.data.dao.api.StoreDao" />
> 	
> 	<bean id="addCmd" class="com.data.dao.cli.StoreAddCommand">
> 		<property name="storeDao" ref="storeDao" />
> 	</bean>
> 	
> 		
> </blueprint>
>
>
> When I build and run in container, below exception is throwing
>
> java.lang.IllegalArgumentException: No matching bundles
> 	at
> org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:59)
> [22:org.apache.karaf.bundle.core:4.1.0]
> 	at
> org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:54)
> [22:org.apache.karaf.bundle.core:4.1.0]
> 	at
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
> [43:org.apache.karaf.shell.core:4.1.0]
> 	at
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:67)
> [43:org.apache.karaf.shell.core:4.1.0]
> 	at
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:82)
> [43:org.apache.karaf.shell.core:4.1.0]
> 	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:552)
> [43:org.apache.karaf.shell.core:4.1.0]
> 	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:478)
> [43:org.apache.karaf.shell.core:4.1.0]
> 	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:367)
> [43:org.apache.karaf.shell.core:4.1.0]
> 	at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
> [43:org.apache.karaf.shell.core:4.1.0]
> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
> [43:org.apache.karaf.shell.core:4.1.0]
> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
> [43:org.apache.karaf.shell.core:4.1.0]
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
> 	at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> [?:?]
> 	at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> [?:?]
> 	at java.lang.Thread.run(Thread.java:745) [?:?]
> 2017-06-09T15:29:26,814 | ERROR | Blueprint Extender: 1 |
> BlueprintContainerImpl           | 12 - org.apache.aries.blueprint.core -
> 1.7.1 | Unable to start blueprint container for bundle
> DemoProject.DemoData/0.0.1.SNAPSHOT due to unresolved dependencies
> [(&(osgi.unit.name=store)(objectClass=javax.persistence.EntityManager))]
> java.util.concurrent.TimeoutException
> 	at
> org.apache.aries.blueprint.container.BlueprintContainerImpl$1.run(BlueprintContainerImpl.java:371)
> [12:org.apache.aries.blueprint.core:1.7.1]
> 	at
> org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
> [12:org.apache.aries.blueprint.core:1.7.1]
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> [?:?]
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
> 	at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
> [?:?]
> 	at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
> [?:?]
> 	at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> [?:?]
> 	at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> [?:?]
> 	at java.lang.Thread.run(Thread.java:745) [?:?]
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050643.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


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

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


Re: Hibernate, JPA and Karaf 4

Posted by Christian Schneider <ch...@die-schneider.net>.
Your log shows this:
2017-06-09T15:24:26,909 | INFO | pool-5-thread-1 | DataSourceTracker | 
415 - org.apache.aries.jpa.container - 2.5.0 | Tracking DataSource for 
punit store with filter
(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=store))

I think your datasource config is wrong. You should use:
osgi.jdbc.driver.class = org.postgresql.Driver

Christian

On 09.06.2017 13:33, Jack wrote:
> Hi Stephen,
>
> I have attached complete log file
> log.txt <http://karaf.922171.n3.nabble.com/file/n4050646/log.txt>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050646.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


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

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


Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Thanks for pointing to this point : pax-jdbc-postgresql in your feature file?

I don't have pax-jdbc-postgresql  in feature file, i have added to it. After
making changes and deploying in karaf, no changes in the log file.

If you see my feature file i have wrapped postgressql driver to the karaf
container.

<bundle>wrap:mvn:postgresql/postgresql/9.1-901.jdbc4</bundle>.








--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050650.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Just thought of something,

Do you have: pax-jdbc-postgresql in your feature file? I didn't see it in
the sample you uploaded?
My example uses h2 at the moment, but you'll need to load the specific
driver into karaf.

Then try re-running the command to confirm whether or not the data source is
available.



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050649.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Stephen,

I have removed shell command reference in pom.xml and tried building it, but
this time in log I 'm seeing the below exception

"Could not obtain connection to query metadata : null"

see the complete log here  log.txt
<http://karaf.922171.n3.nabble.com/file/n4050648/log.txt>  

When I run the command "service:list DataSource " in karaf, i'm not able to
see any datasource displayed. I have placed org.ops4j.datasource-store.cfg
in etc folder of karaf.

I'm attaching org.ops4j.datasource-store.cfg file here 

org.cfg <http://karaf.922171.n3.nabble.com/file/n4050648/org.cfg>  

In feature file I have all the dependency you have mentioed it.



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050648.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Seems the error is being thrown by the Karaf Shell. I've never created any
shell commands, so I'm not sure if there is an issue with that.  You could
try by making just a simple pojo with the entity manager injected and remove
any references to the karaf shell (including your maven manifest). This
might not help, but since you've had this problem for over a week, I'd be
inclined to work with the bare minimum.

Before doing what I've suggested, can you confirm your features file has the
following:

<feature>transaction</feature>
<feature>jndi</feature>
<feature>jdbc</feature>
<feature>pax-jdbc-h2</feature>
<feature>pax-jdbc-pool-dbcp2</feature>
<feature>pax-jdbc-config</feature>
<feature>jpa</feature>
<feature>hibernate-orm</feature>

Secondly, can you run the following command in karaf:
service:list DataSource 

The logs showed the source being registered, but I just want to double
check.



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050647.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Hi Stephen,

I have attached complete log file
log.txt <http://karaf.922171.n3.nabble.com/file/n4050646/log.txt>  




--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050646.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Still unsure, I've seen the second error before, but I'm curious about the
IllegalArgumentException, can you attach the full log file? I'm not sure if
the two are related.



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050645.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Hi Stephen,

I have removed <jpa:context> and <tx:transaction> tags in xml file and added 

<jpa:enable/> and <tx:enable/>

Below is my blueprint file

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"
           xmlns:tx="http://aries.apache.org/xmlns/transactions/v2.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
           http://aries.apache.org/xmlns/jpa/v2.0.0
           http://aries.apache.org/xmlns/transactions/v2.0.0">
           
     <jpa:enable/>
    <tx:enable/>
	
	<bean id="storeDaoImpl" class="com.data.dao.impl.StoreDaoImpl" >
	
	</bean>
	
	<service id="storeDao" ref="storeDaoImpl"
interface="com.data.dao.api.StoreDao" />
	
	<bean id="addCmd" class="com.data.dao.cli.StoreAddCommand">
		<property name="storeDao" ref="storeDao" />
	</bean>
	
		
</blueprint>


When I build and run in container, below exception is throwing

java.lang.IllegalArgumentException: No matching bundles
	at
org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:59)
[22:org.apache.karaf.bundle.core:4.1.0]
	at
org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:54)
[22:org.apache.karaf.bundle.core:4.1.0]
	at
org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
[43:org.apache.karaf.shell.core:4.1.0]
	at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:67)
[43:org.apache.karaf.shell.core:4.1.0]
	at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:82)
[43:org.apache.karaf.shell.core:4.1.0]
	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:552)
[43:org.apache.karaf.shell.core:4.1.0]
	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:478)
[43:org.apache.karaf.shell.core:4.1.0]
	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:367)
[43:org.apache.karaf.shell.core:4.1.0]
	at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
[43:org.apache.karaf.shell.core:4.1.0]
	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
[43:org.apache.karaf.shell.core:4.1.0]
	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
[43:org.apache.karaf.shell.core:4.1.0]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[?:?]
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[?:?]
	at java.lang.Thread.run(Thread.java:745) [?:?]
2017-06-09T15:29:26,814 | ERROR | Blueprint Extender: 1 |
BlueprintContainerImpl           | 12 - org.apache.aries.blueprint.core -
1.7.1 | Unable to start blueprint container for bundle
DemoProject.DemoData/0.0.1.SNAPSHOT due to unresolved dependencies
[(&(osgi.unit.name=store)(objectClass=javax.persistence.EntityManager))]
java.util.concurrent.TimeoutException
	at
org.apache.aries.blueprint.container.BlueprintContainerImpl$1.run(BlueprintContainerImpl.java:371)
[12:org.apache.aries.blueprint.core:1.7.1]
	at
org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
[12:org.apache.aries.blueprint.core:1.7.1]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
[?:?]
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
[?:?]
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[?:?]
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[?:?]
	at java.lang.Thread.run(Thread.java:745) [?:?]




--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050643.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Hello Jack,

As I said previously, your namespace is referencing JPA 2, so you cannot use
the <jpa:context> and <tx:transaction> tags in your xml (at least to my
knowledge). The key is in your log file:

*The matching wildcard is strict, but no declaration can be found for
element 'jpa:context'. *

To get round this problem, remove both the jpa:context and tx:transaction
and put <tx:enable/> and <tx:enable/> outside the bean definitions.

Re-run this after you have made the changes and show me the log file.



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050641.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Hi jb,

This is my blueprint file

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"
           xmlns:tx="http://aries.apache.org/xmlns/transactions/v2.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
           http://aries.apache.org/xmlns/jpa/v2.0.0
           http://aries.apache.org/xmlns/transactions/v2.0.0">
           
    

	
	<bean id="storeDaoImpl" class="com.data.dao.impl.StoreDaoImpl" >
	 <jpa:context property="entityManager" unitname="store"/>
        <tx:transaction method="*" value="Required"/>
	</bean>
	
	<service id="storeDao" ref="storeDaoImpl"
interface="com.data.dao.api.StoreDao" />
	
	<bean id="addCmd" class="com.data.dao.cli.StoreAddCommand">
		<property name="storeDao" ref="storeDao" />
	</bean>
	
		
</blueprint>



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050640.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
It seems the jpa schema/namespace is not well defined.

Regards
JB

On 06/09/2017 11:33 AM, Jack wrote:
> Now im getting this error
> 
> org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to
> validate xml
> 	at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)
> ~[?:?]
> 	at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)
> ~[?:?]
> 	at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)
> ~[?:?]
> 	at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)
> ~[?:?]
> 	at
> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:300)
> ~[?:?]
> 	at
> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:269)
> ~[?:?]
> 	at
> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:265)
> ~[?:?]
> 	at
> org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:255)
> ~[?:?]
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)
> ~[?:?]
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)
> ~[?:?]
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)
> ~[?:?]
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)
> ~[?:?]
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)
> ~[?:?]
> 	at
> org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1179)
> ~[?:?]
> 	at
> org.apache.felix.framework.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:730)
> ~[?:?]
> 	at
> org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:485)
> ~[?:?]
> 	at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4541) ~[?:?]
> 	at org.apache.felix.framework.Felix.startBundle(Felix.java:2172) ~[?:?]
> 	at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) ~[?:?]
> 	at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984) ~[?:?]
> 	at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1281)
> ~[?:?]
> 	at
> org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:890)
> ~[?:?]
> 	at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1170)
> ~[?:?]
> 	at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$0(FeaturesServiceImpl.java:1069)
> ~[?:?]
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
> 	at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> [?:?]
> 	at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> [?:?]
> 	at java.lang.Thread.run(Thread.java:745) [?:?]
> Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The
> matching wildcard is strict, but no declaration can be found for element
> 'jpa:context'.
> 	at
> org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
> Source) ~[?:?]
> 	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) ~[?:?]
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> ~[?:?]
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> ~[?:?]
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> ~[?:?]
> 	at
> org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown
> Source) ~[?:?]
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown
> Source) ~[?:?]
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
> Source) ~[?:?]
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
> Source) ~[?:?]
> 	at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown
> Source) ~[?:?]
> 	at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown
> Source) ~[?:?]
> 	at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown
> Source) ~[?:?]
> 	at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)
> ~[?:?]
> 	at javax.xml.validation.Validator.validate(Unknown Source) ~[?:?]
> 	at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)
> ~[?:?]
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050638.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Now im getting this error

org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to
validate xml
	at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)
~[?:?]
	at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)
~[?:?]
	at
org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)
~[?:?]
	at
org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)
~[?:?]
	at
org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:300)
~[?:?]
	at
org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:269)
~[?:?]
	at
org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:265)
~[?:?]
	at
org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:255)
~[?:?]
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)
~[?:?]
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)
~[?:?]
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)
~[?:?]
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)
~[?:?]
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)
~[?:?]
	at
org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1179)
~[?:?]
	at
org.apache.felix.framework.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:730)
~[?:?]
	at
org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:485)
~[?:?]
	at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4541) ~[?:?]
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2172) ~[?:?]
	at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) ~[?:?]
	at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984) ~[?:?]
	at
org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1281)
~[?:?]
	at
org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:890)
~[?:?]
	at
org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1170)
~[?:?]
	at
org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$0(FeaturesServiceImpl.java:1069)
~[?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[?:?]
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[?:?]
	at java.lang.Thread.run(Thread.java:745) [?:?]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The
matching wildcard is strict, but no declaration can be found for element
'jpa:context'.
	at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
Source) ~[?:?]
	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) ~[?:?]
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
~[?:?]
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
~[?:?]
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
~[?:?]
	at
org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown
Source) ~[?:?]
	at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown
Source) ~[?:?]
	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
Source) ~[?:?]
	at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
Source) ~[?:?]
	at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown
Source) ~[?:?]
	at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown
Source) ~[?:?]
	at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown
Source) ~[?:?]
	at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)
~[?:?]
	at javax.xml.validation.Validator.validate(Unknown Source) ~[?:?]
	at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)
~[?:?]



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050638.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Sorry attached wrong log.

log.txt <http://karaf.922171.n3.nabble.com/file/n4050637/log.txt>  

I enable the jndi, hibernate-orm etc.



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050637.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Jack,

Your log file is chock full of errors!

Connection refused: connect, Could not transfer artifact
toshibacommerce-rma:toshibacommerce-rma-kar:xml:features:0.0.1-SNAPSHOT
from/to ops4j.sonatype.snapshots.deploy
(https://oss.sonatype.org/content/repositories/ops4j-snapshots/): Connect to
oss.sonatype.org:443 [oss.sonatype.org/107.23.166.173,
oss.sonatype.org/52.22.249.229] failed: Connection refused: connect]

Karaf is unable to load the bundle due to a toshibacommerce module it cannot
find, you are getting a bunch of "connection refused" errors.

When I say "enable", I meant, uncomment the commented out entries in the
feature.xml file.



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050636.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Hi,

how to enable the jndi, hibernate-orm ?

karaf.log <http://karaf.922171.n3.nabble.com/file/n4050635/karaf.log>  

I have removed below two lines, even though my application shows in grace
period only.

<jpa:enable/>
    <tx:enable/>



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050635.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Hello Jack,

It might have been easier if you just committed the src rather than archive
it as a zip :)

A few things I noticed that might be causing you trouble:

  <jpa:enable/>
    <tx:enable/>
	
	<bean id="storeDaoImpl" class="com.data.dao.impl.StoreDaoImpl" >
	 <jpa:context property="entityManager" unitname="store"/>
        <tx:transaction method="*" value="Required"/>
	</bean>

If your using JPA 2, I don't think the <jpa:context> <tx:transaction>
sections will work (they didn't for me) and I had to use <jpa:enable/>,
<tx:enable>.

Secondly,

your feature file has jndi, hibernate-orm etc disabled. I think you'll want
to enable those.

Can you start up the application and send the log file over. Even if you
don't see anything obvious, I find it hard to believe there is nothing in
the logs when the bundle is stopped in the GracePeriod state.






--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050634.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Hi added my project in below location

https://github.com/JackMic/hibernate---postgres--karaf.4.1.0

If some can download the project and solve my problem.

I'm almost trying from two weeks to resolve this issue.

Note : i'm using karaf 4.1.0




--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050629.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by "Allan C." <al...@gmail.com>.
Hi JB,

Using the sample provided by Stephen, I am able to reproduce the issue.
Indeed the bundle would remain in grace period and the log is printing
namespace handler for aries transaction 2.0.0. I look back into what I did,
I went back to using jpa 1.0. Thanks guys, now I can update it to 2.0.

Also works for postgresql after installing pax-jdbc-postgresql.

Obviously I've mixed this issue with another issue I still have, which I
will start another thread. Thanks!

Regards,
Allan



On 8 June 2017 at 20:02, Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:

> Hi Allan,
>
> that would be great if you can reproduce and share your project. Then, I
> will take a look.
>
> Thanks !
> Regards
> JB
>
> On 06/08/2017 01:55 PM, Allan C. wrote:
>
>> It was kind of an early setup + POC. The log files have been deleted but
>> I can try to reproduce this issue with 4.0.5. No promise though. Will get
>> back to you.
>>
>> Regards, Allan.
>>
>> Sent from Gmail mobile.
>>
>> On 8 Jun 2017 19:36, "Jean-Baptiste Onofré" <jb@nanthrax.net <mailto:
>> jb@nanthrax.net>> wrote:
>>
>>     You should have the cause of the grace period in the log.
>>
>>     I bet on the namespace. Can you check that ?
>>
>>     Regards
>>     JB
>>
>>     On 06/08/2017 01:04 PM, Allan C. wrote:
>>
>>         I've encountered something similar to what you're facing now. I'm
>> not
>>         quite certain what caused the bundle not starting but IIRC I
>> think the
>>         Dao bundle in grace period is resolved after trying with several
>>         different hibernate versions.
>>
>>         I wish I could be more of help.
>>
>>         Regards, Allan.
>>
>>         Sent from Gmail mobile.
>>
>>         On 8 Jun 2017 18:40, "Jack" <sshetty4u@gmail.com
>>         <ma...@gmail.com> <mailto:sshetty4u@gmail.com
>>
>>         <ma...@gmail.com>>> wrote:
>>
>>              No error in the logs, but the status of the bundle shows
>> "Grace Period"
>>
>>              Below is my blueprint file
>>
>>              <?xml version="1.0" encoding="UTF-8"?>
>>              <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0
>>         <http://www.osgi.org/xmlns/blueprint/v1.0.0>
>>              <http://www.osgi.org/xmlns/blueprint/v1.0.0
>>         <http://www.osgi.org/xmlns/blueprint/v1.0.0>>"
>>                          xmlns:jpa="http://aries.apach
>> e.org/xmlns/jpa/v2.0.0
>>         <http://aries.apache.org/xmlns/jpa/v2.0.0>
>>              <http://aries.apache.org/xmlns/jpa/v2.0.0
>>         <http://aries.apache.org/xmlns/jpa/v2.0.0>>"
>>                                 xmlns:tx="http://aries.apache.
>> org/xmlns/transactions/v2.0.0
>>         <http://aries.apache.org/xmlns/transactions/v2.0.0>
>>              <http://aries.apache.org/xmlns/transactions/v2.0.0
>>         <http://aries.apache.org/xmlns/transactions/v2.0.0>>"
>>                          xmlns:xsi="http://www.w3.org/
>> 2001/XMLSchema-instance
>>         <http://www.w3.org/2001/XMLSchema-instance>
>>              <http://www.w3.org/2001/XMLSchema-instance
>>         <http://www.w3.org/2001/XMLSchema-instance>>"
>>                                 xsi:schemaLocation="http://www
>> .osgi.org/xmlns/blueprint/v1.0.0
>>         <http://www.osgi.org/xmlns/blueprint/v1.0.0>
>>              <http://www.osgi.org/xmlns/blueprint/v1.0.0
>>         <http://www.osgi.org/xmlns/blueprint/v1.0.0>>
>>         https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
>>         <https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd>
>>              <https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
>>         <https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd>>
>>         http://aries.apache.org/xmlns/jpa/v2.0.0
>>         <http://aries.apache.org/xmlns/jpa/v2.0.0>
>>              <http://aries.apache.org/xmlns/jpa/v2.0.0
>>         <http://aries.apache.org/xmlns/jpa/v2.0.0>>
>>         http://aries.apache.org/xmlns/transactions/v2.0.0
>>         <http://aries.apache.org/xmlns/transactions/v2.0.0>
>>              <http://aries.apache.org/xmlns/transactions/v2.0.0
>>         <http://aries.apache.org/xmlns/transactions/v2.0.0>>">
>>
>>
>>                   <jpa:enable/>
>>                   <tx:enable/>
>>
>>                       <bean id="storeDaoImpl"
>>         class="com.data.dao.impl.StoreDaoImpl" >
>>                        <jpa:context property="entityManager"
>> unitname="toshibarma"/>
>>                       <tx:transaction method="*" value="Required"/>
>>                       </bean>
>>
>>                       <service id="storeDao" ref="storeDaoImpl"
>>              interface="com.rma.data.dao.St <http://com.rma.data.dao.St
>> >oreDao" />
>>
>>              </blueprint>
>>
>>
>>
>>              --
>>              View this message in context:
>>         http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-
>> tp4050569p4050614.html
>>         <http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-
>> 4-tp4050569p4050614.html>
>>                     <http://karaf.922171.n3.nabble
>> .com/Hibernate-JPA-and-Karaf-4-tp4050569p4050614.html
>>         <http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-
>> 4-tp4050569p4050614.html>>
>>              Sent from the Karaf - User mailing list archive at
>> Nabble.com.
>>
>>
>>
>>     --     Jean-Baptiste Onofré
>>     jbonofre@apache.org <ma...@apache.org>
>>     http://blog.nanthrax.net
>>     Talend - http://www.talend.com
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Re: Hibernate, JPA and Karaf 4

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Allan,

that would be great if you can reproduce and share your project. Then, I will 
take a look.

Thanks !
Regards
JB

On 06/08/2017 01:55 PM, Allan C. wrote:
> It was kind of an early setup + POC. The log files have been deleted but I can 
> try to reproduce this issue with 4.0.5. No promise though. Will get back to you.
> 
> Regards, Allan.
> 
> Sent from Gmail mobile.
> 
> On 8 Jun 2017 19:36, "Jean-Baptiste Onofré" <jb@nanthrax.net 
> <ma...@nanthrax.net>> wrote:
> 
>     You should have the cause of the grace period in the log.
> 
>     I bet on the namespace. Can you check that ?
> 
>     Regards
>     JB
> 
>     On 06/08/2017 01:04 PM, Allan C. wrote:
> 
>         I've encountered something similar to what you're facing now. I'm not
>         quite certain what caused the bundle not starting but IIRC I think the
>         Dao bundle in grace period is resolved after trying with several
>         different hibernate versions.
> 
>         I wish I could be more of help.
> 
>         Regards, Allan.
> 
>         Sent from Gmail mobile.
> 
>         On 8 Jun 2017 18:40, "Jack" <sshetty4u@gmail.com
>         <ma...@gmail.com> <mailto:sshetty4u@gmail.com
>         <ma...@gmail.com>>> wrote:
> 
>              No error in the logs, but the status of the bundle shows "Grace Period"
> 
>              Below is my blueprint file
> 
>              <?xml version="1.0" encoding="UTF-8"?>
>              <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0
>         <http://www.osgi.org/xmlns/blueprint/v1.0.0>
>              <http://www.osgi.org/xmlns/blueprint/v1.0.0
>         <http://www.osgi.org/xmlns/blueprint/v1.0.0>>"
>                          xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0
>         <http://aries.apache.org/xmlns/jpa/v2.0.0>
>              <http://aries.apache.org/xmlns/jpa/v2.0.0
>         <http://aries.apache.org/xmlns/jpa/v2.0.0>>"
>                         
>         xmlns:tx="http://aries.apache.org/xmlns/transactions/v2.0.0
>         <http://aries.apache.org/xmlns/transactions/v2.0.0>
>              <http://aries.apache.org/xmlns/transactions/v2.0.0
>         <http://aries.apache.org/xmlns/transactions/v2.0.0>>"
>                          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
>         <http://www.w3.org/2001/XMLSchema-instance>
>              <http://www.w3.org/2001/XMLSchema-instance
>         <http://www.w3.org/2001/XMLSchema-instance>>"
>                         
>         xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
>         <http://www.osgi.org/xmlns/blueprint/v1.0.0>
>              <http://www.osgi.org/xmlns/blueprint/v1.0.0
>         <http://www.osgi.org/xmlns/blueprint/v1.0.0>>
>         https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
>         <https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd>
>              <https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
>         <https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd>>
>         http://aries.apache.org/xmlns/jpa/v2.0.0
>         <http://aries.apache.org/xmlns/jpa/v2.0.0>
>              <http://aries.apache.org/xmlns/jpa/v2.0.0
>         <http://aries.apache.org/xmlns/jpa/v2.0.0>>
>         http://aries.apache.org/xmlns/transactions/v2.0.0
>         <http://aries.apache.org/xmlns/transactions/v2.0.0>
>              <http://aries.apache.org/xmlns/transactions/v2.0.0
>         <http://aries.apache.org/xmlns/transactions/v2.0.0>>">
> 
> 
>                   <jpa:enable/>
>                   <tx:enable/>
> 
>                       <bean id="storeDaoImpl"
>         class="com.data.dao.impl.StoreDaoImpl" >
>                        <jpa:context property="entityManager" unitname="toshibarma"/>
>                       <tx:transaction method="*" value="Required"/>
>                       </bean>
> 
>                       <service id="storeDao" ref="storeDaoImpl"
>              interface="com.rma.data.dao.St <http://com.rma.data.dao.St>oreDao" />
> 
>              </blueprint>
> 
> 
> 
>              --
>              View this message in context:
>         http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050614.html
>         <http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050614.html>
>             
>         <http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050614.html
>         <http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050614.html>>
>              Sent from the Karaf - User mailing list archive at Nabble.com.
> 
> 
> 
>     -- 
>     Jean-Baptiste Onofré
>     jbonofre@apache.org <ma...@apache.org>
>     http://blog.nanthrax.net
>     Talend - http://www.talend.com
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Hibernate, JPA and Karaf 4

Posted by "Allan C." <al...@gmail.com>.
It was kind of an early setup + POC. The log files have been deleted but I
can try to reproduce this issue with 4.0.5. No promise though. Will get
back to you.

Regards, Allan.

Sent from Gmail mobile.

On 8 Jun 2017 19:36, "Jean-Baptiste Onofré" <jb...@nanthrax.net> wrote:

> You should have the cause of the grace period in the log.
>
> I bet on the namespace. Can you check that ?
>
> Regards
> JB
>
> On 06/08/2017 01:04 PM, Allan C. wrote:
>
>> I've encountered something similar to what you're facing now. I'm not
>> quite certain what caused the bundle not starting but IIRC I think the Dao
>> bundle in grace period is resolved after trying with several different
>> hibernate versions.
>>
>> I wish I could be more of help.
>>
>> Regards, Allan.
>>
>> Sent from Gmail mobile.
>>
>> On 8 Jun 2017 18:40, "Jack" <sshetty4u@gmail.com <mailto:
>> sshetty4u@gmail.com>> wrote:
>>
>>     No error in the logs, but the status of the bundle shows "Grace
>> Period"
>>
>>     Below is my blueprint file
>>
>>     <?xml version="1.0" encoding="UTF-8"?>
>>     <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0
>>     <http://www.osgi.org/xmlns/blueprint/v1.0.0>"
>>                 xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0
>>     <http://aries.apache.org/xmlns/jpa/v2.0.0>"
>>                 xmlns:tx="http://aries.apache.
>> org/xmlns/transactions/v2.0.0
>>     <http://aries.apache.org/xmlns/transactions/v2.0.0>"
>>                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
>>     <http://www.w3.org/2001/XMLSchema-instance>"
>>                 xsi:schemaLocation="http://www
>> .osgi.org/xmlns/blueprint/v1.0.0
>>     <http://www.osgi.org/xmlns/blueprint/v1.0.0>
>>     https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
>>     <https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd>
>>     http://aries.apache.org/xmlns/jpa/v2.0.0
>>     <http://aries.apache.org/xmlns/jpa/v2.0.0>
>>     http://aries.apache.org/xmlns/transactions/v2.0.0
>>     <http://aries.apache.org/xmlns/transactions/v2.0.0>">
>>
>>
>>          <jpa:enable/>
>>          <tx:enable/>
>>
>>              <bean id="storeDaoImpl" class="com.data.dao.impl.StoreDaoImpl"
>> >
>>               <jpa:context property="entityManager"
>> unitname="toshibarma"/>
>>              <tx:transaction method="*" value="Required"/>
>>              </bean>
>>
>>              <service id="storeDao" ref="storeDaoImpl"
>>     interface="com.rma.data.dao.StoreDao" />
>>
>>     </blueprint>
>>
>>
>>
>>     --
>>     View this message in context:
>>     http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-
>> tp4050569p4050614.html
>>     <http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-
>> 4-tp4050569p4050614.html>
>>     Sent from the Karaf - User mailing list archive at Nabble.com.
>>
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Re: Hibernate, JPA and Karaf 4

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
You should have the cause of the grace period in the log.

I bet on the namespace. Can you check that ?

Regards
JB

On 06/08/2017 01:04 PM, Allan C. wrote:
> I've encountered something similar to what you're facing now. I'm not quite 
> certain what caused the bundle not starting but IIRC I think the Dao bundle in 
> grace period is resolved after trying with several different hibernate versions.
> 
> I wish I could be more of help.
> 
> Regards, Allan.
> 
> Sent from Gmail mobile.
> 
> On 8 Jun 2017 18:40, "Jack" <sshetty4u@gmail.com <ma...@gmail.com>> 
> wrote:
> 
>     No error in the logs, but the status of the bundle shows "Grace Period"
> 
>     Below is my blueprint file
> 
>     <?xml version="1.0" encoding="UTF-8"?>
>     <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0
>     <http://www.osgi.org/xmlns/blueprint/v1.0.0>"
>                 xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0
>     <http://aries.apache.org/xmlns/jpa/v2.0.0>"
>                 xmlns:tx="http://aries.apache.org/xmlns/transactions/v2.0.0
>     <http://aries.apache.org/xmlns/transactions/v2.0.0>"
>                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
>     <http://www.w3.org/2001/XMLSchema-instance>"
>                 xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
>     <http://www.osgi.org/xmlns/blueprint/v1.0.0>
>     https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
>     <https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd>
>     http://aries.apache.org/xmlns/jpa/v2.0.0
>     <http://aries.apache.org/xmlns/jpa/v2.0.0>
>     http://aries.apache.org/xmlns/transactions/v2.0.0
>     <http://aries.apache.org/xmlns/transactions/v2.0.0>">
> 
> 
>          <jpa:enable/>
>          <tx:enable/>
> 
>              <bean id="storeDaoImpl" class="com.data.dao.impl.StoreDaoImpl" >
>               <jpa:context property="entityManager" unitname="toshibarma"/>
>              <tx:transaction method="*" value="Required"/>
>              </bean>
> 
>              <service id="storeDao" ref="storeDaoImpl"
>     interface="com.rma.data.dao.StoreDao" />
> 
>     </blueprint>
> 
> 
> 
>     --
>     View this message in context:
>     http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050614.html
>     <http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050614.html>
>     Sent from the Karaf - User mailing list archive at Nabble.com.
> 
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Hibernate, JPA and Karaf 4

Posted by "Allan C." <al...@gmail.com>.
I've encountered something similar to what you're facing now. I'm not quite
certain what caused the bundle not starting but IIRC I think the Dao bundle
in grace period is resolved after trying with several different hibernate
versions.

I wish I could be more of help.

Regards, Allan.

Sent from Gmail mobile.

On 8 Jun 2017 18:40, "Jack" <ss...@gmail.com> wrote:

No error in the logs, but the status of the bundle shows "Grace Period"

Below is my blueprint file

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"
           xmlns:tx="http://aries.apache.org/xmlns/transactions/v2.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
           http://aries.apache.org/xmlns/jpa/v2.0.0
           http://aries.apache.org/xmlns/transactions/v2.0.0">


    <jpa:enable/>
    <tx:enable/>

        <bean id="storeDaoImpl" class="com.data.dao.impl.StoreDaoImpl" >
         <jpa:context property="entityManager" unitname="toshibarma"/>
        <tx:transaction method="*" value="Required"/>
        </bean>

        <service id="storeDao" ref="storeDaoImpl"
interface="com.rma.data.dao.StoreDao" />

</blueprint>



--
View this message in context: http://karaf.922171.n3.nabble.
com/Hibernate-JPA-and-Karaf-4-tp4050569p4050614.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
No error in the logs, but the status of the bundle shows "Grace Period"

Below is my blueprint file

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"
           xmlns:tx="http://aries.apache.org/xmlns/transactions/v2.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
           http://aries.apache.org/xmlns/jpa/v2.0.0
           http://aries.apache.org/xmlns/transactions/v2.0.0">
           
    
    <jpa:enable/>
    <tx:enable/>
	
	<bean id="storeDaoImpl" class="com.data.dao.impl.StoreDaoImpl" >
	 <jpa:context property="entityManager" unitname="toshibarma"/>
        <tx:transaction method="*" value="Required"/>
	</bean>
	
	<service id="storeDao" ref="storeDaoImpl"
interface="com.rma.data.dao.StoreDao" />
	
</blueprint>



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050614.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Sounds like your using another version of JPA. Look at the xml schema in the
persistence.xml and check your using the jpa 2.0 namespace. If your using
jpa 1, then the code below won't work, you'll need to use the jpa 1.0
solution:

 <bean id="demoBean" class="org.tramiel.demo.TestBeanl"> 
      <jpa:context unitname="my_unit" property="entityManager"/>
      <tx:transaction method="*" value="Required"/>
</bean>

What errors are shown in karaf.log?

Warm Regards,
Stephen Munro



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050613.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Hi Stephen,

I have took your code and modified my code inline with yours, but my bundles
status showing "Grace Period".

If I remove below two line then, bundles will start properly

  <jpa:enable/>
    <tx:enable/>





--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050612.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Hello Jack,

I've commented on one your previous posts as this thread is growing arms and
legs now...

The repo was posted previously in the above comments.

Stephen



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050607.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jack <ss...@gmail.com>.
Hi,

Could you please your complete project.

I'm struggling almost a week. I'm doing a sample poc with hibernate and
postgresSql.

I'm ended up with error in creating EntityManagerFactory object for my
persistence layer.

If required some help on this.





--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050604.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Christian Schneider had kindly updated my code with the solution. My original
setup had two problems:

1. The wrong provider was used,

    I should have used org.hibernate.jpa.HibernatePersistenceProvider rather
than the ejb provider (or 
    remove the provider completely as I only have one).  

2. Updated my feature file to use:
    mvn:org.ops4j.pax.jdbc/pax-jdbc-features/0.9.0/xml/features rather than
version 0.5.0
    and introduce the aries.jpa repo: 
  
<repository>mvn:org.apache.aries.jpa/jpa-features/2.6.1/xml/features</repository>

Glad I can finally put this problem to rest! 

Thanks again for all your help on this.

Stephen



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050601.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
As addendum, I checked the headers for the Aries JPA Container (see below).
The output shows 
javax.persistence;version="[1.1,3)" in red, so your theory about a missing
requirement seems valid, I'm just not sure what's missing/conflicted.

Bundle-Activator = org.apache.aries.jpa.container.impl.Activator
Bundle-Description = Implements the OSGi JPA Container from the enterprise
spec. Provider a EntityManagerFactory and EntityManagerFactoryBuilder
service
Bundle-DocURL = http://www.apache.org/
Bundle-License = http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion = 2
Bundle-Name = Apache Aries JPA container
Bundle-SymbolicName = org.apache.aries.jpa.container
Bundle-Vendor = The Apache Software Foundation
Bundle-Version = 2.3.0

Require-Capability =
        osgi.ee;filter:=(&(osgi.ee=JavaSE)(version=1.6))

Import-Package =
        javax.persistence;version="[1.1,3)",
        javax.persistence.spi;version="[1.1,3)",
        javax.sql,
        javax.xml.parsers,
        org.osgi.framework;version="[1.6,2)",
        org.osgi.framework.hooks.weaving;version="[1.0,2)",
        org.osgi.framework.wiring;version="[1.0,2)",
        org.osgi.service.cm;version="[1.4,2)",
        org.osgi.service.jdbc;version="[1.0,2)",
        org.osgi.service.jpa;version="[1.0,2)",
        org.osgi.util.tracker;version="[1.5,2)",
        org.slf4j;version="[1.7,2)",
        org.xml.sax,
        org.xml.sax.helpers




--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050600.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Hello JB,

Apologies for the delay, I ended up just creating a project from scratch
minus the sensitive work code while mirroring the configuration.  With this
project, I've duplicated the error I am getting.

Project: https://github.com/desolate-planet/osgi-jpa-demo

So, when adding the feature file to karaf I can see my jpademo sitting in a
"resolved state". I then attempt to start it and the status changes to
"graceperiod" and in the logs I see:

"org.tramiel.jpademo/1.0.0.SNAPSHOT is waiting for dependencies
[(&(osgi.unit.name=authentication)(objectClass=javax.persistence.EntityManager))]"





--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050599.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Hello JB,

Thanks for the reply. For this project, I need to strip out a lot of my
company stuff, which I will try to do shortly.  The project itself just
tries to initialize an entity manager via blueprint. 

If JPA  2 works fine, then that's one less thing I need to check :). 





--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050592.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Stephen,

JPA 2 works as well. I think the problem is that your requirements are not match.

I will do a sample to test. Would it be possible to share your project ?

Regards
JB

On 06/06/2017 09:32 PM, smunro wrote:
> Thanks for the info Tim,
> 
> The issue with this is that my company have strict rules over what we use
> and I had a hard enough time convincing them to use aries blueprint over the
> programmatic tracker api, so given my time limit, I don't think I'll be
> successfully getting any new tech added.
> 
> I'm pretty sure what I've tried should work as for all the reading I've
> done, people have got it working. I've followed those guides, but still not
> had much success.
> 
> The only thing I've not tried yet is going back from JPA 2.0 to JPA 1.0.
> 
> Stephen
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050589.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Thanks for the info Tim,

The issue with this is that my company have strict rules over what we use
and I had a hard enough time convincing them to use aries blueprint over the
programmatic tracker api, so given my time limit, I don't think I'll be
successfully getting any new tech added.

I'm pretty sure what I've tried should work as for all the reading I've
done, people have got it working. I've followed those guides, but still not
had much success.

The only thing I've not tried yet is going back from JPA 2.0 to JPA 1.0.

Stephen



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050589.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Timothy Ward <ti...@paremus.com>.
Hi,

Have you considered using OSGi Transaction Control rather than blueprint’s integration? Apache Aries has an implementation of this pre-release OSGi R7 specification, and there are fewer moving parts. You can avoid deploying the blueprint/PAX JDBC pieces, and just use:

A JPA provider (OpenJPA 2.4, Hibernate 5.x, EclipseLink 2.6), 
Aries JPA Container 2.6.0 (none of the rest of Aries JPA will be needed)
Aries Transaction Control Service Local <https://github.com/apache/aries/tree/trunk/tx-control/tx-control-service-local> (0.0.2 is available in Maven Central)
Aries Transaction Control JPA Local <https://github.com/apache/aries/tree/trunk/tx-control/tx-control-provider-jpa-local> (0.0.2 is available in Maven Central)
H2 (your database of choice?) which is already a fully paid up OSGi implementation 

If you then cut down your persistence unit to the bare essentials:

<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence <http://xmlns.jcp.org/xml/ns/persistence>"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance <http://www.w3.org/2001/XMLSchema-instance>"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence <http://xmlns.jcp.org/xml/ns/persistence>
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd <http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd>">
 <persistence-unit name=“authentication" transaction-type="JTA">
   <!-- Is this really needed, i.e. do you use Hibernate specific annotations/API? --> 
   <provider>org.hibernate.ejb.HibernatePersistence</provider>
 </persistence-unit>
</persistence>

And create a factory configuration for pid org.apache.aries.tx.control.jpa.local containing:

osgi.unit.name=authentication
osgi.jdbc.driver.class=org.h2.Driver
url=<your h2 URL in here>

You should then be able to inject the Transaction Control service and the JPAEntityManagerProvider, just like in this example <https://github.com/apache/aries/blob/trunk/tx-control/tx-control-provider-jpa-local/README.md#creating-a-resource-using-a-factory-configuration>

I hope this helps,

Regards,

Tim 

> On 6 Jun 2017, at 16:36, smunro <st...@gmail.com> wrote:
> 
> Thanks jbonofre,
> 
> Looking at the sample, the main key differences I can see if your using
> openjpa and the jpa 1.0.0 spec.
> 
> I tried using the 5.2.9 of hibernate as well as add  org.hibernate.jpa to my
> import packages. I still shows the same log entry: 
> 
> waiting for dependencies
> [(&(osgi.unit.name=authentication)(objectClass=javax.persistence.EntityManager))]
> 
> The only other change I've noticed is the log entries that appear before
> that line:
> 
> 2017-06-06 16:31:25,504 | INFO  | nsole user karaf |
> PersistenceBundleTracker         | 96 - org.apache.aries.jpa.container -
> 2.3.0 | Found persistence unit authentication in bundle
> org.desolateplanet.authentication-db-impl with provider
> org.hibernate.ejb.HibernatePersistence.
> 2017-06-06 16:31:25,507 | INFO  | nsole user karaf |
> PersistenceBundleTracker         | 96 - org.apache.aries.jpa.container -
> 2.3.0 | Persistence units added for bundle
> org.desolateplanet.authentication-db-impl event 128
> 
> At this point, I'm just about ready to give up and go back to using raw jdbc
> calls :P
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050587.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Thanks jbonofre,

Looking at the sample, the main key differences I can see if your using
openjpa and the jpa 1.0.0 spec.

I tried using the 5.2.9 of hibernate as well as add  org.hibernate.jpa to my
import packages. I still shows the same log entry: 

 waiting for dependencies
[(&(osgi.unit.name=authentication)(objectClass=javax.persistence.EntityManager))]

The only other change I've noticed is the log entries that appear before
that line:

2017-06-06 16:31:25,504 | INFO  | nsole user karaf |
PersistenceBundleTracker         | 96 - org.apache.aries.jpa.container -
2.3.0 | Found persistence unit authentication in bundle
org.desolateplanet.authentication-db-impl with provider
org.hibernate.ejb.HibernatePersistence.
2017-06-06 16:31:25,507 | INFO  | nsole user karaf |
PersistenceBundleTracker         | 96 - org.apache.aries.jpa.container -
2.3.0 | Persistence units added for bundle
org.desolateplanet.authentication-db-impl event 128

At this point, I'm just about ready to give up and go back to using raw jdbc
calls :P



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050587.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
You can also take a look on:

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

By the way, we are in the process of integrating bunch of samples in the Karaf 
distribution.

Regards
JB

On 06/06/2017 04:09 PM, smunro wrote:
> This is the only other useful source of info the the problem I'm having:
> 
> https://github.com/cschneider/Karaf-Tutorial/issues/22
> 
> Seems that upgrading hibernate to 5.2.9 might work. I'll need to give it a
> try. I'll let you know how I get on...
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050584.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
This is the only other useful source of info the the problem I'm having:

https://github.com/cschneider/Karaf-Tutorial/issues/22

Seems that upgrading hibernate to 5.2.9 might work. I'll need to give it a
try. I'll let you know how I get on...



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050584.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Sure,

<plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>                    
                       
<Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
                        <Import-Package>
                           
org.apache.felix.service.command;version="[0.6,1)",
                           
org.apache.felix.gogo.commands;version="[0.6,1)",
                           
org.apache.karaf.shell.console;version="[2.2,4.1)",
                            org.hibernate.proxy,
                            javassist.util.proxy,
                            *
                        </Import-Package>
                    </instructions>
                </configuration>
            </plugin>

The generated manifest looks like this:

Manifest-Version: 1.0
Bnd-LastModified: 1496749271882
Build-Jdk: 1.8.0_121
Built-By: smunro
Bundle-Blueprint: OSGI-INF/blueprint/blueprint.xml
Bundle-Description: A version of the SGS parent POM that doesn't build a
 n RPM installer for the project, but includes the full SGS build proces
 s and dependency suite.         This is useful for projects that are us
 ed as libraries, rather than standalone applications.
Bundle-ManifestVersion: 2
Bundle-Name: Authentication DB Impl
Bundle-SymbolicName:  org.desolateplaneti.authentication-db-i
 mpl
Bundle-Version: 0.0.9.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Import-Package: org.desolateplanet.cim.types;version="[0.0,1)",
  org.desolateplanet.security.manage;version="[0.0,1)",
org.desolateplaneti.security.model;version="[0.0,1)",javax.persist
 ence;version="[2.1,3)",javax.sql,org.osgi.service.blueprint;version="[1
 .0.0,2.0.0)",org.apache.felix.service.command;version="[0.6,1)",org.apa
 che.felix.gogo.commands;version="[0.6,1)",org.apache.karaf.shell.consol
 e;version="[2.2,4.1)",org.hibernate.proxy;version="[4.3,5)",javassist.u
 til.proxy;version="[3.18,4)"
Meta-Persistence: META-INF/persistence.xml
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.0.0.201509101326



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050579.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Can you share your MANIFEST (import and required service especially) ?

Regards
JB

On 06/06/2017 01:47 PM, smunro wrote:
> Thanks jbonofre,
> 
> I've updated the blueprint to have the following:
> 
> <jpa:enable/>
>   <tx:enable/>
> 
> With the updated schema refs. The bundle is still not starting, and is now
> stuck in a grace period:
> 
> org.desolateplanet.sgs-ui.auth/0.0.9.SNAPSHOT is waiting for dependencies
> [(&(osgi.unit.name=authentication)(objectClass=javax.persistence.EntityManager))]
> 
> The only thing I changed was the above and injecting the persistence context
> via annotation.
> 
> 
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050576.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Thanks jbonofre,

I've updated the blueprint to have the following:

<jpa:enable/>
 <tx:enable/>

With the updated schema refs. The bundle is still not starting, and is now
stuck in a grace period:

org.desolateplanet.sgs-ui.auth/0.0.9.SNAPSHOT is waiting for dependencies
[(&(osgi.unit.name=authentication)(objectClass=javax.persistence.EntityManager))]

The only thing I changed was the above and injecting the persistence context
via annotation.





--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050576.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Without version, the jpa feature installed is 2.0.0, so you have to update the 
namespace in the blueprint.

Regards
JB

On 06/06/2017 01:15 PM, smunro wrote:
> Hello jbonofre,
> 
> Thanks for the swift reply. Not sure if this answers your question, but I
> have the following feature running:
> 
> hibernate                     | 4.3.6.Final      | x        | Started
> enterprise-4.0.8         | Hibernate 4.3.x JPA persistence engine support
> 
> And my feature file has the following entries:
> 
>              <feature>jndi</feature>
>              <feature>jdbc</feature>
>              <feature>pax-jdbc-h2</feature>
>              <feature>pax-jdbc-pool-dbcp2</feature>
>              <feature>pax-jdbc-config</feature>
>              <feature>jpa</feature>
>              <feature>hibernate</feature>
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050572.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Hibernate, JPA and Karaf 4

Posted by smunro <st...@gmail.com>.
Hello jbonofre,

Thanks for the swift reply. Not sure if this answers your question, but I
have the following feature running:

hibernate                     | 4.3.6.Final      | x        | Started
enterprise-4.0.8         | Hibernate 4.3.x JPA persistence engine support

And my feature file has the following entries:

            <feature>jndi</feature>
            <feature>jdbc</feature>
            <feature>pax-jdbc-h2</feature>
            <feature>pax-jdbc-pool-dbcp2</feature>
            <feature>pax-jdbc-config</feature>
            <feature>jpa</feature>
            <feature>hibernate</feature>



--
View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050572.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Hibernate, JPA and Karaf 4

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

the namespace depends of the jpa version you use. If you use jpa 2.x feature, 
the namespace is http://aries.apache.org/xmlns/jpa/v2.0.0.

Can you check the jpa feature you are using ?

Regards
JB

On 06/06/2017 11:47 AM, smunro wrote:
> Hello,
> 
> I am trying to get JPA & Hibernate working in a OSGI bundle, deployed on
> Karaf 4.0.8.
> Regardless of what tutorials or guides I follow, I am met with the following
> log entry:
> 
> org.desolateplanet.authentication-db-impl/0.0.9.SNAPSHOT is waiting for
> namespace handlers [http://aries.apache.org/xmlns/jpa/v1.0.0]
> 
> The entity manager is never injected via blueprint as the breakpoint I set
> is never hit.
> 
> I'd had more success with direct JDBC, but I don't want to resort to that
> just yet in case I'm missing something silly. I've attached the
> blueprint/pom/persistence.xml below for reference.
> 
> == POM dependencies ==
>   <dependencies>
>          <dependency>
>              <groupId>${project.groupId}</groupId>
>              <artifactId>authentication-api</artifactId>
>          </dependency>
>          <dependency>
>              <groupId>org.osgi</groupId>
>              <artifactId>org.osgi</artifactId>
>          </dependency>
>          
>          <dependency>
>              <groupId>org.osgi</groupId>
>              <artifactId>org.osgi.util.tracker</artifactId>
>          </dependency>
>          
>          <dependency>
>              <groupId>org.osgi</groupId>
>              <artifactId>org.osgi.core</artifactId>
>          </dependency>
>              
>          <dependency>
>              <groupId>org.osgi</groupId>
>              <artifactId>org.osgi.service.cm</artifactId>
>          </dependency>
>                   
>          <dependency>
>              <groupId>javax.transaction</groupId>
>              <artifactId>javax.transaction-api</artifactId>
>              <version>1.2</version>
>          </dependency>
>          <dependency>
>              <groupId>com.h2database</groupId>
>              <artifactId>h2</artifactId>
>              <version>1.3.174</version>
>          </dependency>
>          
>         
>          <dependency>
>              <groupId>org.osgi</groupId>
>              <artifactId>org.osgi.enterprise</artifactId>
>              <version>4.2.0</version>
>          </dependency>
>         
> 
>          <dependency>
>              <groupId>org.hibernate.javax.persistence</groupId>
>              <artifactId>hibernate-jpa-2.1-api</artifactId>
>              <version>1.0.0.Final</version>
>          </dependency>
>          <dependency>
>              <groupId>org.hibernate</groupId>
>              <artifactId>hibernate-core</artifactId>
>              <version>4.3.6.Final</version>
>              <scope>test</scope>
>          </dependency>
>          <dependency>
>              <groupId>org.hibernate</groupId>
>              <artifactId>hibernate-osgi</artifactId>
>              <version>4.3.6.Final</version>
>              <scope>test</scope>
>          </dependency>
>          <dependency>
>              <groupId>org.hibernate</groupId>
>              <artifactId>hibernate-entitymanager</artifactId>
>              <version>4.3.6.Final</version>
>              <scope>test</scope>
>          </dependency>
>          <dependency>
>              <groupId>org.hibernate.common</groupId>
>              <artifactId>hibernate-commons-annotations</artifactId>
>              <version>4.0.4.Final</version>
>          </dependency>
>      </dependencies>
> 
> == Persistence.xml ==
> <persistence version="2.1" 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">
>    <persistence-unit name="authentication" transaction-type="JTA">
>      <provider>org.hibernate.ejb.HibernatePersistence</provider>
>      <jta-data-source>osgi:service/authentication</jta-data-source>
>      <properties>
>        <property name="hibernate.dialect"
> value="org.hibernate.dialect.H2Dialect"/>
>      </properties>
>    </persistence-unit>
> </persistence>
> 
> == blueprint.xml ==
> <blueprint default-activation="eager"
>             xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>             xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
>             xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
>             
>      
> 
>      <bean id="accountStore"
> class="org.desolateplanet.security.impl.AccountStoreImpl">
>          <jpa:context unitname="authentication" property="entityManager"/>
>          <tx:transaction method="*" value="Required"/>
>      </bean>
>    
> 
> </blueprint>
> 
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com