Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » ClassNotFoundException if injecting an own service
ClassNotFoundException if injecting an own service [message #1722302] Wed, 03 February 2016 23:50 Go to next message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 235
Registered: July 2009
Senior Member
Hi all,
I've an OSGi service component which exposes a certain service (let's
say, MyService). The implementation class is done in com.acme.bundle1.
This bundle also contains the service definition as a xml file (in the
OSGI-INF folder).
The interface IMyService resides in com.acme.bundle2. I use the
IMyService in an RCP application (com.acme.rcp) via @Inject. Now, if I
start the application, all bundles turn into "ACTIVE" state with no
errors. But if I try to access the RCP class which contains the (field)
injected service I get the following error:

java.lang.ClassNotFoundException: com.acme.bundle1.IMyService cannot be
found by com.acme.rcp

The MANIFEST.MF of com.acme.bundle1 requires the com.acme.bundle2 and
has the "Service-Component" entry pointing to the OSGI-INF folder.

The com.acme.rcp MANIFEST.MF contains a dependency to com.acme.bundle2.

Now I don't know what's wrong with this. Could anybody out there help
me? Thanks in advance.

Ralf.
Re: ClassNotFoundException if injecting an own service [message #1722388 is a reply to message #1722302] Thu, 04 February 2016 14:16 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
Quote:
The com.acme.rcp MANIFEST.MF contains a dependency to com.acme.bundle2.


I assume com.acme.bundle2 exports the package with the IMyService class?
Re: ClassNotFoundException if injecting an own service [message #1722447 is a reply to message #1722388] Thu, 04 February 2016 21:08 Go to previous message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 235
Registered: July 2009
Senior Member
Am 04.02.2016 um 15:16 schrieb Thomas Watson:
> Quote:
>> The com.acme.rcp MANIFEST.MF contains a dependency to com.acme.bundle2.
>
>
> I assume com.acme.bundle2 exports the package with the IMyService class?


Hi all,
after fiddling half of a day I found the mistake(s):

- the service interface and the service implementation were in the same
package, but in different bundles. This lead to unexpected results. They
not even have to reside in hierarchical packages. So I renamed my
packages to completely different ones.

- the exported packages had no version number (I assume they have to
have one)

- the service component had no startup flag (but there I'm not sure if
it was throughout my experiments)

Now it seems to work. Although... there's one more thing... but this is
another thread :-)

Ralf.
Previous Topic:Prevent installation of product 1 'on top of' product 2
Next Topic:servletbridge and org.osgi.framework.system.packages.extra
Goto Forum:
  


Current Time: Thu Oct 10 21:28:22 GMT 2024

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

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

Back to the top