Unable to get module classpath

classic Classic list List threaded Threaded
5 messages Options
GFO
Reply | Threaded
Open this post in threaded view
|

Unable to get module classpath

GFO
I am facing a problem with one of my OSGi bundles.
When I start it, I have the following error :

   

It is not blocking for starting my bundle, it is "Active". But when I try to
execute a SQL command through my Java code, it only works with native
queries. When I try to execute HQL queries/named queries, I always have
errors such as

    ClassCastException: com.example.MyBean cannot be cast to
com.example.MyBean

I guess it is linked to the first error. What do you think about that? Do
you know how to prevent the first error?

Additional information:

- I have a bundle bundleA which contains persistence configuration, beans
(like MyBean), managers, etc. I also have bundleB which uses a service
exposed by bundleA. So the error appears when I call bundleA service through
bundleB. Alongside bundleA and bundleB, I have hibernate-osgi,
hibernate-entitymanager, hibernate-core and hibernate-commons-annotations
bundles in version 4.3.6.Final.

- Only bundleA contains MyBean class. BundleB has "Import-Package:
com.example" and "Import-Service: com.example.service" which is a service to
interact with managers contained in bundleA. When I show classes in bundleA
and bundleB with "bundle:classes" Karaf command, I find MyBean in both
bundles

- when I look at classes in my jars, I only find MyBean in bundleA. Not in
bundleB. Maybe "bundle:classes" shows classes in the bundle's jar and
classes imported by the bundle?

Do not hesitate if you need more information.

Thanks a lot



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Unable to get module classpath

fpapon
Hi,

We can't see your first error, can you repaste it ?

François

Le 26 janv. 2018 12:19 PM, GFO <[hidden email]> a écrit :

>
> I am facing a problem with one of my OSGi bundles.
> When I start it, I have the following error :
>
>    
>
> It is not blocking for starting my bundle, it is "Active". But when I try to
> execute a SQL command through my Java code, it only works with native
> queries. When I try to execute HQL queries/named queries, I always have
> errors such as
>
>     ClassCastException: com.example.MyBean cannot be cast to
> com.example.MyBean
>
> I guess it is linked to the first error. What do you think about that? Do
> you know how to prevent the first error?
>
> Additional information:
>
> - I have a bundle bundleA which contains persistence configuration, beans
> (like MyBean), managers, etc. I also have bundleB which uses a service
> exposed by bundleA. So the error appears when I call bundleA service through
> bundleB. Alongside bundleA and bundleB, I have hibernate-osgi,
> hibernate-entitymanager, hibernate-core and hibernate-commons-annotations
> bundles in version 4.3.6.Final.
>
> - Only bundleA contains MyBean class. BundleB has "Import-Package:
> com.example" and "Import-Service: com.example.service" which is a service to
> interact with managers contained in bundleA. When I show classes in bundleA
> and bundleB with "bundle:classes" Karaf command, I find MyBean in both
> bundles
>
> - when I look at classes in my jars, I only find MyBean in bundleA. Not in
> bundleB. Maybe "bundle:classes" shows classes in the bundle's jar and
> classes imported by the bundle?
>
> Do not hesitate if you need more information.
>
> Thanks a lot
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html 
Francois Papon
Openrun : https://www.openrun.re
GFO
Reply | Threaded
Open this post in threaded view
|

Re: Unable to get module classpath

GFO
Reply | Threaded
Open this post in threaded view
|

Re: Unable to get module classpath

jbonofre
Hi,

I would start by defining the TCCL (Thread Context ClassLoader).

Second, I would check if you don't embed any Hibernate package, because it looks
for SPI.

So, your bundle should use the EntityManager. This entity manager can be
injected by Aries JPA for instance.

You can take a look on:

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

It's pretty old but almost valid.

By the way, you will have samples soon in the Karaf distribution.

Regards
JB

On 01/26/2018 09:33 AM, GFO wrote:
> Hi, here is the pastebin link : https://pastebin.com/USXC3cqC
>
> Thanks
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Unable to get module classpath

jbonofre
In reply to this post by GFO
By the way, you can find the examples that will be included in Karaf soon (with
corresponding dev guide section):

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

Regards
JB

On 01/26/2018 09:33 AM, GFO wrote:
> Hi, here is the pastebin link : https://pastebin.com/USXC3cqC
>
> Thanks
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com