Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » ClassLoader issue: Loading classes of other bundles
ClassLoader issue: Loading classes of other bundles [message #106123] Tue, 11 March 2008 12:06 Go to next message
Andreas Heinecke is currently offline Andreas HeineckeFriend
Messages: 21
Registered: July 2009
Junior Member
Hi,

I encountered a ClassLoader problem. I try to explain my problem the most
simple way:
- There are 3 bundles (F,S,C)
- Bundle F exports a package com.abc which contains an interface FInterface
- Bundle S imports the package com.abc (from Bundle F) and provides an
implementation of FInterface in package com.sde and exports this package
- Bundle C wants to load the implementation class of FInterface from Bundle
S and therefore imports the package com.sde
- for loading the implementation of FInterface bundle C instruments the
loadClass(String name) method from the BundleContext of Bundle S
--> this is where the error occurs! I get a ClassNotFoundException which
tells me that the FInterface class could not be found

Why does this exception occur (Bundle C imports com.abc as well as com.sde)?
Is there a way to enable Bundle C to load the implementation class of
FInterface from Bundle S?

Any help or pointers are much appreciated.

Regards,

Andreas.
Re: ClassLoader issue: Loading classes of other bundles [message #106208 is a reply to message #106123] Wed, 12 March 2008 06:51 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Andreas Heinecke schrieb:
> Why does this exception occur (Bundle C imports com.abc as well as com.sde)?

What happens if you simply use FInterfaceImpl directly in Bundle C code?
If it imports the packages directly then this shouldn't be a problem at all.

-Gunnar


--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Re: ClassLoader issue: Loading classes of other bundles [message #106412 is a reply to message #106208] Mon, 17 March 2008 08:16 Go to previous messageGo to next message
Andreas Heinecke is currently offline Andreas HeineckeFriend
Messages: 21
Registered: July 2009
Junior Member
Hi Gunnar,

in fact this would be maybe possible, it isn't a solution for my particular
problem. Bundle C must not important any code from Bundle S.

Regards,
Andreas.

"Gunnar Wagenknecht" <gunnar@wagenknecht.org> schrieb im Newsbeitrag
news:fr7uhi$f3f$2@build.eclipse.org...
> Andreas Heinecke schrieb:
>> Why does this exception occur (Bundle C imports com.abc as well as
>> com.sde)?
>
> What happens if you simply use FInterfaceImpl directly in Bundle C code?
> If it imports the packages directly then this shouldn't be a problem at
> all.
>
> -Gunnar
>
>
> --
> Gunnar Wagenknecht
> gunnar@wagenknecht.org
> http://wagenknecht.org/
Re: ClassLoader issue: Loading classes of other bundles [message #106453 is a reply to message #106412] Mon, 17 March 2008 20:44 Go to previous message
Benedikt Arnold is currently offline Benedikt ArnoldFriend
Messages: 5
Registered: July 2009
Junior Member
Hi Andreas,

the cleanest solution for this issue is to use the service registry.
Bundle S registers an FInterfaceImpl object under the name of FInterface
(BundleContext#registerService). Bundle C imports only the package which
hosts FInterface and queries the service registry
(BundleContext#getServiceReference).

For more information take a look at
http://www2.osgi.org/javadoc/r4/org/osgi/framework/BundleCon text.html or
ask this newsgroup :-)

Greetings,
Benedikt

Andreas Heinecke wrote:

> Hi Gunnar,

> in fact this would be maybe possible, it isn't a solution for my particular
> problem. Bundle C must not important any code from Bundle S.

> Regards,
> Andreas.
Previous Topic:RCP, eRCP, and OSGi best practices
Next Topic:Problems running equinox weaved with aspectj
Goto Forum:
  


Current Time: Tue Apr 23 13:32:40 GMT 2024

Powered by FUDForum. Page generated in 0.04367 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top