Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Class Cast Exception when casting to common interface
icon5.gif  Class Cast Exception when casting to common interface [message #629192] Mon, 27 September 2010 13:03 Go to next message
Iulius is currently offline IuliusFriend
Messages: 4
Registered: March 2010
Junior Member
Hi everybody,

I am currently playing around with OSGi and especially with Equinox. however I'm running into a little problem and am stuck there right now. My sample app is designed as follows:

Java Main program, that starts the Framework via EclipseStarter.
Bundle "interfaces" that only contains common interfaces.
Bundle "operatorA" and Bundle "operatorB" which depend on the interfaces bundle.
When I try to run a service from operatorA Bundle and cast it to the common interface I get the following exception:

Exception in thread "main" java.lang.ClassCastException: ...

I am sure this is a class loader issue, but I have no idea how to circumvent it. Any suggestions?

Thank you!

cya,
Iulius
Re: Class Cast Exception when casting to common interface [message #629197 is a reply to message #629192] Mon, 27 September 2010 13:14 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
In order for bundles to share the same package in OSGi the bundles need to import the common package (using Import-Package header). Do you have a bundle which exports the common package (using the Export-Package manifest header)? And does your other bundles import this package (using the Import-Package manifest header)?

It sounds like you package the common interface into each bundle and they are loading the interface with their own bundle class loader at runtime, this would cause the cast exception.

HTH

Tom.
Re: Class Cast Exception when casting to common interface [message #629204 is a reply to message #629192] Mon, 27 September 2010 13:33 Go to previous message
Iulius is currently offline IuliusFriend
Messages: 4
Registered: March 2010
Junior Member
the interface bundle exports the package
org.osgi.interfaces.export
whereas the other bundles import exactly this package.

the classes are solely exported in the interface bundle. so I am using the Import/Export package header and do not package the common interface with each bundle.


Previous Topic:Hibernate integration with Equinox.
Next Topic:Loading files from a JAR at runtime
Goto Forum:
  


Current Time: Fri Apr 19 23:11:05 GMT 2024

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

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

Back to the top