You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by GFO <gu...@soprasteria.com> on 2018/03/20 14:35:03 UTC

Karaf + Hibernate + Oracle: missing dependency

Hello,

I am trying to connect my bundles to a Oracle Database (10g) through
ServiceMix.

I have a bundle which contains my entities and my persistence.xml file in
META-INF.

Alongside, I have a DAO bundle in which I inject my entity manager.

When I start my entities+persistence bundle, it has the state "Active". But
when I look at the logs (I turned them into DEBUG), I have the following
line : " org.apache.aries.jpa.container - 1.0.4 | The persistence unit
my-unit in bundle my-bundle/0.0.1.SNAPSHOT cannot be registered because no
DataSourceFactory service for JDBC driver oracle.jdbc.driver.OracleDriver
exists.".

You'll find the result of service:list DataSource and DataSourceFactory
here: https://pastebin.com/H1UB4D4h. Does the log line is "normal" as it is
in DEBUG ?

Plus, when I launch my DAO bundle, I stays in "GRACE_PERIOD" and then
"FAILED" states.
In the logs, my DAO bundle seems to find the persistence infos from the
other bundle : "Registering bundle bundle-dao_0.0.1.SNAPSHOT as a client of
persistence unit my-unit with properties
{org.apache.aries.jpa.context.type=TRANSACTION}.".

But my DAO bundle seems to wait for a dependency : "Bundle
bundle-dao/0.0.1.SNAPSHOT is waiting for dependencies
[(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=my-unit))(objectClass=javax.persistence.EntityManagerFactory))]".

I don't know why.

Here you'll find the logs of the launch of the DAO bundle :
https://pastebin.com/YnVirQqm.

Here is my persistence.xml (from entity+persistence bundle):
https://pastebin.com/FY2s5AAT

Here is my blueprint context (from DAO bundle):
https://pastebin.com/WxpeBAte

Here is the result of bundle:list -t 0 command:
https://pastebin.com/2L80Ud6L

Here is the MANIFEST of my DAO bundle: https://pastebin.com/fpYmALgg


Please can you help me on this problem? I'm completely stuck. :(

Thanks a lot!



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by GFO <gu...@soprasteria.com>.
Hello Christian,

Thanks for the reply.

I didnt know for the debug message, thanks. But when I execute the
bundle:diag command l do not see any warning about the DSF... 

I already have the pax-jdbc-oracle installed as you can see in the result of
bundle list command above. :/

Thanks



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by Christian Schneider <ch...@die-schneider.net>.
The debug log message is an early warning that something might be wrong. It
says that Aries JPA needs a DataSourceFactory to initialize your
persistence unit.

As in OSGi services can start in any order this can be a temporary state
(if the DSF is just not yet up). In your case this is a permanent state as
you seem to the missing this service.
Blueprint reports this after a while but the timeout is quite high. This is
why there is the debug log message.

Another way to get an early warning is to se the karaf diag command.

Now back to your original problem. You need to install a DataSourceFactory
OSGi service. Many databases already provide this in their driver jar.
Unsurprisingly Oracle does not.
You can solve this by installing the feature pax-jdbc-oracle.

Cheers
Christian

2018-03-20 15:35 GMT+01:00 GFO <gu...@soprasteria.com>:

> Hello,
>
> I am trying to connect my bundles to a Oracle Database (10g) through
> ServiceMix.
>
> I have a bundle which contains my entities and my persistence.xml file in
> META-INF.
>
> Alongside, I have a DAO bundle in which I inject my entity manager.
>
> When I start my entities+persistence bundle, it has the state "Active". But
> when I look at the logs (I turned them into DEBUG), I have the following
> line : " org.apache.aries.jpa.container - 1.0.4 | The persistence unit
> my-unit in bundle my-bundle/0.0.1.SNAPSHOT cannot be registered because no
> DataSourceFactory service for JDBC driver oracle.jdbc.driver.OracleDriver
> exists.".
>
> You'll find the result of service:list DataSource and DataSourceFactory
> here: https://pastebin.com/H1UB4D4h. Does the log line is "normal" as it
> is
> in DEBUG ?
>
> Plus, when I launch my DAO bundle, I stays in "GRACE_PERIOD" and then
> "FAILED" states.
> In the logs, my DAO bundle seems to find the persistence infos from the
> other bundle : "Registering bundle bundle-dao_0.0.1.SNAPSHOT as a client of
> persistence unit my-unit with properties
> {org.apache.aries.jpa.context.type=TRANSACTION}.".
>
> But my DAO bundle seems to wait for a dependency : "Bundle
> bundle-dao/0.0.1.SNAPSHOT is waiting for dependencies
> [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name
> =my-unit))(objectClass=javax.persistence.EntityManagerFactory))]".
>
> I don't know why.
>
> Here you'll find the logs of the launch of the DAO bundle :
> https://pastebin.com/YnVirQqm.
>
> Here is my persistence.xml (from entity+persistence bundle):
> https://pastebin.com/FY2s5AAT
>
> Here is my blueprint context (from DAO bundle):
> https://pastebin.com/WxpeBAte
>
> Here is the result of bundle:list -t 0 command:
> https://pastebin.com/2L80Ud6L
>
> Here is the MANIFEST of my DAO bundle: https://pastebin.com/fpYmALgg
>
>
> Please can you help me on this problem? I'm completely stuck. :(
>
> Thanks a lot!
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>



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

Computer Scientist
http://www.adobe.com

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by GFO <gu...@soprasteria.com>.
Hello JB,


Here is a zip of my project which reproduces the error: Can you have a look?

Thanks for the example, but my bundles are not structured the same way. I
read it is a good practice to separate entites from persistence.xml. It is
in the same bundle in your example. Which way is the better?

Thanks,
GFO



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by GFO <gu...@soprasteria.com>.
Hello JB,


Here is a zip of my project which reproduces the error:
https://ufile.io/fb27x. Can you have a look?

Thanks for the example, but my bundles are not structured the same way. I
read it is a good practice to separate entites from persistence.xml. It is
in the same bundle in your example. Which way is the better?

Thanks,
GFO



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by GFO <gu...@soprasteria.com>.
Hi, 

Your example is using JPA 2, while mine is using JPA 1. It is the only
difference I guess.

I could try to update my JPA version to 2.

GFO



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
OK, interesting. Did you compare with the example I shared with you ?

I didn't check your zip yet. I will try to take a look asap.

Regards
JB

On 03/27/2018 09:18 AM, GFO wrote:
> JB,
> 
> OK, in the ZIP file I gave you I have my entities + persistence.xml in the
> same bundle.
> 
> I just tested something: everything in the same bundle. It doesn't change
> anything, I still have "Not an entity" error... I really don't know why I
> have this error. When I look at my configuration it seems OK.
> 
> GFO
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

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

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by GFO <gu...@soprasteria.com>.
JB,

OK, in the ZIP file I gave you I have my entities + persistence.xml in the
same bundle.

I just tested something: everything in the same bundle. It doesn't change
anything, I still have "Not an entity" error... I really don't know why I
have this error. When I look at my configuration it seems OK.

GFO



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

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

as the persistence.xml defines the entity, it has to be in the same classloader.
So, it has to be in the bundle, or the bundle containing the persistence.xml
should import the package containing the entities (from the other bundle).

Regards
JB

On 03/26/2018 04:27 PM, GFO wrote:
> Hello JB,
> 
> 
> Here is a zip of my project which reproduces the error:
> https://ufile.io/fb27x. Can you have a look?
> 
> Thanks for the example, but my bundles are not structured the same way. I
> read it is a good practice to separate entites from persistence.xml. It is
> in the same bundle in your example. Which way is the better?
> 
> Thanks,
> GFO
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

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

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by GFO <gu...@soprasteria.com>.
Hello JB,


Here is a zip of my project which reproduces the error:
https://ufile.io/fb27x. Can you have a look?

Thanks for the example, but my bundles are not structured the same way. I
read it is a good practice to separate entites from persistence.xml. It is
in the same bundle in your example. Which way is the better?

Thanks,
GFO



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

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

any chance to share your project (or at least a sample) ?

You can take a look on the examples we are preparing:

https://github.com/jbonofre/karaf/tree/DEV_GUIDE/examples/karaf-jpa-example

Maybe, you have some module structure issue: where did you put your entity ?
Does it extend a class from a package provided by another bundle ?

Regards
JB

On 03/26/2018 11:05 AM, GFO wrote:
> Hello,
> 
> I still have the error described above.
> 
> For information, I have the following dependencies: 
> 
> DAO bundle requires entities+persitence bundle
> service bundle requires DAO bundle
> service bundle requires entites+persistence bundle
> 
> The error occurs when I launch the service bundle because it uses some
> methods defined in the DAO bundle. 
> 
> Do you think it could be an error caused by dependencies conflicts?
> 
> GFO
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

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

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by GFO <gu...@soprasteria.com>.
Hello,

I still have the error described above.

For information, I have the following dependencies: 

DAO bundle requires entities+persitence bundle
service bundle requires DAO bundle
service bundle requires entites+persistence bundle

The error occurs when I launch the service bundle because it uses some
methods defined in the DAO bundle. 

Do you think it could be an error caused by dependencies conflicts?

GFO



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by GFO <gu...@soprasteria.com>.
Hello François,

Yes, my entities have @Entity annotation + they are in my persistence.xml.

I noticed something weird. 

When I do this:


> final Query q = entityManager.createQuery("from " + className + " c");		
> q.getResultList().iterator();

it returns results.

But when I do this:

> // pType is Class
> <T>
> final TypedQuery
> <T>
>  queryAll = entityManager.createQuery(query.select(query.from(pType)));
> return queryAll.getResultList();

I have the error 


> Caused by: java.lang.IllegalArgumentException: Not an entity: class
> com.example.FirstBean

Thanks,
GFO




--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by fpapon <fr...@openobject.fr>.
Have add @Entity in your FirstBean classes ?

François



-----
Francois Papon
Openrun : https://www.openrun.re
--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by GFO <gu...@soprasteria.com>.
Hello,

I found the problem.

It was because I had "javax.persistence.jdbc.driver =
oracle.jdbc.driver.OracleDriver" in my persistence.xml.
I have removed this line and it works now, I do not longer have the debug
saying there is no DataSourceFactory with Oracle driver.

Now I have the following error:

Caused by: java.lang.IllegalArgumentException: Not an entity:
com.example.FirstBean

when I launch my client bundle. Do you know where it can comes from? This
bean is in my peristence.xml and seems to be loaded when I launch my
entity+persistence bundle (I can see it in the logs).

Thanka,
GFO




--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by GFO <gu...@soprasteria.com>.
Hi,

Can anyone help? It is a really blocking issue for me :/

Thanks,
GFO



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by GFO <gu...@soprasteria.com>.
Hi,

Yes I have edited my post with a link to the result of jdbc:ds-list.

Right, I just forgot to replace referentiel-unit by my-unit before posting
my persistence.xml here. ;) So all is good in my persistence.xml and in my
blueprint conf... 

GFO



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by Francois Papon <fr...@openobject.fr>.
Hi,

Sorry I can't see the output of the jdbc:ds-list.

By the way, if jdbc:tables print your tables, you're right about your
datasource, it's probably ok ;)

But I see that your persistence unit declared in persistence.xml is
referentiel-unit but in your blueprint you want to use a persistence
unit named "my-unit".

I think your problem is here ;)

<jpa:context unitname="my-unit" property="entityManager" />

François

On 21/03/2018 15:01, GFO wrote:
> Hi,
>
> To add information to my post, I think my DataSource is really fine.
>
> Indeed, when I do: 
>
> jdbc:ds-list, I have the following result:
>
>
>
> And when I do, for example, jdbc:tables, I see tables from my Oracle DB. So
> the DataSource is OK, right?
>
> So, do you agree my problem doesn't come from DataSource? 
> But it doesn't explain the debug message I still see "The persistence unit
> referentiel-unit in bundle nsis-common-referentiel-entity/0.0.1.SNAPSHOT
> cannot be registered because no DataSourceFactory service for JDBC driver
> oracle.jdbc.driver.OracleDriver exists." and the fail of the other bundle
> which uses my entity+persistence bundle.
>
> Does the main error,
>
> Missing dependencies:
> (&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=person))(objectClass=javax.persistence.EntityManagerFactory
>
> can come from JPA problem? I saw several threads about bugs in
> AriesJPA/Hibernate/etc. in OSGi envs.
>
>
> Thanks a lot.
> GFO
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: Karaf + Hibernate + Oracle: missing dependency

Posted by GFO <gu...@soprasteria.com>.
Hi,

To add information to my post, I think my DataSource is really fine.

Indeed, when I do: 

jdbc:ds-list, I have the following result:



And when I do, for example, jdbc:tables, I see tables from my Oracle DB. So
the DataSource is OK, right?

So, do you agree my problem doesn't come from DataSource? 
But it doesn't explain the debug message I still see "The persistence unit
referentiel-unit in bundle nsis-common-referentiel-entity/0.0.1.SNAPSHOT
cannot be registered because no DataSourceFactory service for JDBC driver
oracle.jdbc.driver.OracleDriver exists." and the fail of the other bundle
which uses my entity+persistence bundle.

Does the main error,

Missing dependencies:
(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=person))(objectClass=javax.persistence.EntityManagerFactory

can come from JPA problem? I saw several threads about bugs in
AriesJPA/Hibernate/etc. in OSGi envs.


Thanks a lot.
GFO



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by GFO <gu...@soprasteria.com>.
Hi François,

The result of "bundle:list -t 0" command is the following:
https://pastebin.com/2L80Ud6L.

As you can see I have the following bundles. On is pax-jdbc-oracle and the
second is Oracle JDBC drivers from
http://www.oracle.com/technetwork/apps-tech/jdbc-10201-088211.html. 

477 | Active   |  80 | 0                                  |
wrap_mvn_com.oracle_ojdbc14_10.2.0.5
478 | Active   |  80 | 1.0.1                              | OPS4J Pax JDBC
Oracle Driver Adapter

As I mentioned in my first message, I have a DataSource and a
DataSourceFactory in Karaf: https://pastebin.com/H1UB4D4h. The
DataSourceFactory seems to bee Oracle compliant...

Do I need something more?


Thanks,
GFO



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf + Hibernate + Oracle: missing dependency

Posted by Francois Papon <fr...@openobject.fr>.
Hi,

I'm not sure that the oracle jdbc drivers jar is include with the
pax-jdbc-oracle bundle.

Can you check in yours lib or system repositories if exist ?

François

Le 20/03/2018 à 18:35, GFO a écrit :
> Hello,
>
> I am trying to connect my bundles to a Oracle Database (10g) through
> ServiceMix.
>
> I have a bundle which contains my entities and my persistence.xml file in
> META-INF.
>
> Alongside, I have a DAO bundle in which I inject my entity manager.
>
> When I start my entities+persistence bundle, it has the state "Active". But
> when I look at the logs (I turned them into DEBUG), I have the following
> line : " org.apache.aries.jpa.container - 1.0.4 | The persistence unit
> my-unit in bundle my-bundle/0.0.1.SNAPSHOT cannot be registered because no
> DataSourceFactory service for JDBC driver oracle.jdbc.driver.OracleDriver
> exists.".
>
> You'll find the result of service:list DataSource and DataSourceFactory
> here: https://pastebin.com/H1UB4D4h. Does the log line is "normal" as it is
> in DEBUG ?
>
> Plus, when I launch my DAO bundle, I stays in "GRACE_PERIOD" and then
> "FAILED" states.
> In the logs, my DAO bundle seems to find the persistence infos from the
> other bundle : "Registering bundle bundle-dao_0.0.1.SNAPSHOT as a client of
> persistence unit my-unit with properties
> {org.apache.aries.jpa.context.type=TRANSACTION}.".
>
> But my DAO bundle seems to wait for a dependency : "Bundle
> bundle-dao/0.0.1.SNAPSHOT is waiting for dependencies
> [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=my-unit))(objectClass=javax.persistence.EntityManagerFactory))]".
>
> I don't know why.
>
> Here you'll find the logs of the launch of the DAO bundle :
> https://pastebin.com/YnVirQqm.
>
> Here is my persistence.xml (from entity+persistence bundle):
> https://pastebin.com/FY2s5AAT
>
> Here is my blueprint context (from DAO bundle):
> https://pastebin.com/WxpeBAte
>
> Here is the result of bundle:list -t 0 command:
> https://pastebin.com/2L80Ud6L
>
> Here is the MANIFEST of my DAO bundle: https://pastebin.com/fpYmALgg
>
>
> Please can you help me on this problem? I'm completely stuck. :(
>
> Thanks a lot!
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html