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/01/26 08:19:28 UTC

Unable to get module classpath

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

Re: Unable to get module classpath

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
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é
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Unable to get module classpath

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
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é
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Unable to get module classpath

Posted by GFO <gu...@soprasteria.com>.
Hi, here is the pastebin link : https://pastebin.com/USXC3cqC

Thanks



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