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

  • Home
  • SEARCH
  • 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 5962913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:10:21+00:00 2026-05-22T19:10:21+00:00

I have a problem with my Declarative Services. I have 2 bundles, one is

  • 0

I have a problem with my Declarative Services. I have 2 bundles, one is a server provider and another the user interface that consumes the service.

On server side, the implementation is:

public boolean checkUser(){
    return true;
}

And the XML file inside OSGi-INF folder:

<component name="ZBService">
<implementation class="service.ZBService" />
   <service>
     <provide interface="service.IZBService" />
   </service>
</component>

On client side, the implementation is:

public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService{
   IZBService zb;

   public void setZBService(IZBService eventAdmin) {
      this.zb = eventAdmin;
   }

   public void unsetZBService(IZBService eventAdmin){
      if(this.zb == eventAdmin){
          this.zb = null;}
   }
   public boolean greetServer(String input, String input2) throws Exception {
      return zb.checkUser();
   }
}

And XML file:

<component name="ZBService">
  <implementation class="main.java.com.gwt.app.server.GreetingServiceImpl" />
   <service>
        <provide interface="main.java.com.gwt.app.client.GreetingService"/>
   </service>
   <reference name="zb" interface="service.IZBService" bind="setZBService" unbind="unsetZBService" cardinality="0..n" policy="dynamic" />
</component>

Also, I have included the tag Service-Component on manifest file and I have deployed the equinox ds bundle that is ACTIVE.

The client is a GWT user interface, then I inject the service reference into server side of GWT. Well, when I deploy the application on Equinox it runs, but when I push the button, I launch an event to call ZBService. I have debugged the application and the error is zb attribute is null. It is to say, the dependence is nos injected. However the services are exposed on Equinox. If I write services on Equinox console, the services are deployed. Then, my conclusion is the error is due to the injection does not perform.

I would like to know if someone knows what is the reason??

Thanks a lot in advance!!

Nice day

EDIT:

I did your suggestions but it doesn’t run. I change the component names and condinality/policy. The result is the same –> NullPointerException due to the injection isn’t done.

Also I have debug the application to see if the methods bind and/or unbind are called, but they aren’t.

The complete class is:

public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService{
static protected IZBService zb;

public GreetingServiceImpl(){
    System.out.println("Constructor GreetingServiceImpl");
}

public IZBService getZb() {
    return zb;
}

public void setZb(IZBService zb) {
    GreetingServiceImpl.zb = zb;
}

public void unsetZb(IZBService zb) {
    GreetingServiceImpl.zb = zb;
}

@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    // Cache the current thread
    Thread currentThread = Thread.currentThread();
    // We are going to swap the class loader
    ClassLoader oldContextClassLoader = currentThread.getContextClassLoader();
    currentThread.setContextClassLoader(this.getClass().getClassLoader());
    super.service(req, resp);
    currentThread.setContextClassLoader(oldContextClassLoader);
}

public void activate(ComponentContext context) {
    System.out.println("Creating new greeter for " + context.getProperties().get("name")
            + ": " + context.getComponentInstance().toString());
}

public void activate() {
    System.out.println("Activando la referencia al servicio");
}

public void deactivate(ComponentContext context) {
    System.out.println("Deactivating greeter for " + context.getProperties().get("name")
            + ": " + context.getComponentInstance().toString());
}

public boolean greetServer(String input, String input2) throws Exception {
    return zb.checkUser();
}
}

And the XML client is:

<?xml version="1.0" encoding="UTF-8" ?>
<scr:component name="serviceZB" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
<implementation class="main.java.com.gwt.app.server.GreetingServiceImpl" />
<!-- <service>
    <provide interface="main.java.com.gwt.app.client.GreetingService"/>
</service> -->
<reference name="zb" interface="service.IZBService"
    bind="setZb" unbind="unsetZb" cardinality="1..1"
    policy="static" />
</scr:component>

Why isn’t the service injected if the service is deployed???

  • 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-05-22T19:10:22+00:00Added an answer on May 22, 2026 at 7:10 pm

    Here is a list of things you can try:

    • First, remove the “static” of zb, that could be the problem.
    • If you are using Equinox, add the -Dequinox.ds.print=true flag to the VM arguments and see more information about parsing XMLs and so
    • Of course, add sysouts to setZB and unsetZB 🙂
    • Remember that IZBService implementation needs a constructor without arguments
    • If you are using Equinox use the “list -c” command to obtain information of each component (it’s cool because says exactly why a component is not registered).
    • Set the “inmediate=true” in XMLs to force to inmediatly activation.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following situation: Three concrete service classes implement a service interface: one
Considering a server that expose a service through WCF. One of the OperationContract return
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with fancybox. I want to write a function that will run
I have a small problem that I think should be easily handled by SQL
I have to interact with a set of web-services that each come with their
I have a big problem. I created a WCF service.My POST declaration looks like
I have a problem with the Elixir declarative layer; I want to retrieve, for
I have the following simple problem that I'd like to use to experiment with
my web application is based on dojo 1.6.0. The problem that I have is

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.