Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8889029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:09:40+00:00 2026-06-14T22:09:40+00:00

I have written an OSGi bundle to use it in my eclipse 4 rcp

  • 0

I have written an OSGi bundle to use it in my eclipse 4 rcp application. The usage of the service works fine if I add the dependencies, register these service in my activator and inject it in my class.

In activator

IUserService service = new TestUserService();
context.registerService(IUserService.class.getName(), service, null);

In my class

@Inject
IUserService service;

service.getSth();

I read that using bundles via declarative services should be the better way. So changed my implementation.
I created a component definition in my bundle to provide my service:

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="usermanagement.test">
   <implementation class="usermanagement.test.TestUserService"/>
   <service>
      <provide interface="usermanagement.IUserService"/>
   </service>
</scr:component>

Then I removed the service registration from my activator and created an service consumer class:

public class UserServiceConsumer {

    private IUserService service;

    public synchronized void setQuote(IUserService service) {
        this.service = service;
    }

    public synchronized void unsetQuote(IUserService service) {
        if (this.service == service) {
            this.service = null;
        }
    }

}

and another component definition:

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="UserServiceConsumer">
   <implementation class="services.UserServiceConsumer"/>
   <reference bind="setService" cardinality="1..1" interface="usermanagement.IUserService" name="IUserService" policy="static" unbind="unsetService"/>
</scr:component>

After these modifications the injection of my serivce does not work anymore. The problem is that the injected service reference is NULL everytime.

Does anyone know why? Did I forgot something?

Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:09:42+00:00Added an answer on June 14, 2026 at 10:09 pm

    I can suggest a few things you can do to debug.

    1. Have you actually got an scr implementation in your runtime? SCR (another name for declarative services) isn’t included in Equinox core, so you’ll need to include it. Most people use the Felix SCR bundle – it will sit very happily on top of Equinox.

    2. Since Declarative Services just use services, you can change one half of your app at a time, to identify whether it’s the service consumption or registration which isn’t working.

    3. You can also use the Equinox console to inspect your service registration. Use ‘ss’ to identify your bundle, then ‘bundle [no]’ to see what services are registered and consumed. If you’re using Felix SCR, there are also Equinox console extensions, so you can use ‘scr list’ to see all services which a bundle attempts to register (and their state), and ‘scr info’ for more details on a particular service.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written this code in JavaScript and works perfectly fine when I include
I have written this OSGI bundle: /* * To change this template, choose Tools
I try to learn how osgi works. I've written my first hello-world bundle which
I have written some Python scripts in Eclipse where at some point I have
I have written a web-service (in Java) which produces as a result a (rather
I have written a simple WCF web service in C# which returns records from
I have written a WCF service with the REST template that has the defaultOutgoingResponseFormat
I have written an Android app (target 3.2) using Eclipse 3.7, I tried to
I have written a generic CSV file reader that I'm trying to use to
I have written a function for browser compatibility. When I pass objTR.cells[0] it works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.