Discussion:
Karaf + Hibernate + Oracle: missing dependency
GFO
2018-03-20 14:35:03 UTC
Permalink
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
2018-03-20 17:16:09 UTC
Permalink
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
Post by GFO
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.
https://pastebin.com/YnVirQqm.
https://pastebin.com/FY2s5AAT
https://pastebin.com/WxpeBAte
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
GFO
2018-03-20 22:31:40 UTC
Permalink
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
Francois Papon
2018-03-21 04:42:56 UTC
Permalink
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
Post by GFO
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.
https://pastebin.com/YnVirQqm.
https://pastebin.com/FY2s5AAT
https://pastebin.com/WxpeBAte
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
GFO
2018-03-21 08:11:43 UTC
Permalink
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
GFO
2018-03-21 11:01:14 UTC
Permalink
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
Francois Papon
2018-03-21 11:13:48 UTC
Permalink
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
Post by GFO
Hi,
To add information to my post, I think my DataSource is really fine.
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,
(&(&(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
GFO
2018-03-21 11:17:53 UTC
Permalink
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
GFO
2018-03-22 07:05:26 UTC
Permalink
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
GFO
2018-03-22 13:55:13 UTC
Permalink
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
fpapon
2018-03-23 04:52:29 UTC
Permalink
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
GFO
2018-03-23 08:09:53 UTC
Permalink
Hello François,

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

I noticed something weird.
final Query q = entityManager.createQuery("from " + className + " c");
q.getResultList().iterator();
it returns results.
// 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
GFO
2018-03-26 09:05:36 UTC
Permalink
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é
2018-03-26 09:09:55 UTC
Permalink
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
Post by GFO
Hello,
I still have the error described above.
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é
***@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
GFO
2018-03-26 14:27:36 UTC
Permalink
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é
2018-03-26 15:44:41 UTC
Permalink
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
Post by GFO
Hello JB,
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é
***@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
GFO
2018-03-27 07:18:08 UTC
Permalink
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é
2018-03-27 09:04:37 UTC
Permalink
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
Post by GFO
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é
***@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
GFO
2018-03-28 14:36:09 UTC
Permalink
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
GFO
2018-03-26 14:42:30 UTC
Permalink
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
GFO
2018-03-26 15:25:20 UTC
Permalink
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
Loading...