Bundle registers as a component but no longer as a service | Community
Skip to main content
Level 6
October 16, 2015
Solved

Bundle registers as a component but no longer as a service

  • October 16, 2015
  • 4 replies
  • 901 views

I developed a basic project as an OSGI bundle. 

I tested it by installing it using http://localhost:4502/system/console/bundles. The bundle shows as active.

Then I switch to http://localhost:4502/system/console/services and the services of the bundle show.

Later after doing some development, my bundle installs and shows as active. But its methods no longer appears in the services interface. And they cannot be accessed using  sling.getService.

What can cause this and how does one go about testing to see what caused it to stop being a service.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by JustinEd3

Your component is abstract - which means it doesn't actually get registered as a service. See http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/scr-annotations.html#abstract-service-descriptions

4 replies

Sham_HC
Level 10
October 16, 2015

AFAIK there is no method names displayed in tab http://localhost:4502/system/console/services

Level 6
October 16, 2015

Please forgive my terminology.

 

For example 

 

I have 

In the console/bundles

         
397
 
1.0.0 Active
  •  

 

In the console/services

 

      
2878[getspecials.nigeria.shoprite.HelloService]getspecials.nigeria.shoprite.getwigroupspecials (397)

Then I upload 

         
398
 
1.0.0.SNAPSHOT Active

 

 

 

in the console/services

      
2882[com.shoprite.specialsandcoupons.HelloService]com.shoprite.specialsandcoupons.specialsandcoupons-bundle (398)

But I do not see the method inside my bundle

I left the default Interface HelloService and its implementation. 

I also created a new interface

public interface SpecialsAndCoupons {}

and its implementation class 

package com.shoprite.specialsandcoupons.impl;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.TreeSet;

import org.xml.sax.InputSource;

import java.net.HttpURLConnection;

import javax.net.ssl.HttpsURLConnection;

import java.net.URL;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import com.shoprite.specialsandcoupons.SpecialsAndCoupons;

import Objects.Items;

@Component(componentAbstract=true)

@Service

public class SpecialsAndCouponsImpl implements SpecialsAndCoupons {

 

But I do not see com.shoprite.specialsandcoupons.SpecialsAndCoupons on http://localhost:4502/system/console/services

Sham_HC
Level 10
October 16, 2015

If i understood you question correctly,  There are two services in same bundle and only one is listed but not both. Is that correct? 

If everything defined correctly it should not be the case.  Sort by bundles column in [1] and verify.  Also when you redeploy bundle by adding new service please make sure to higher up the version number.

[1] http://localhost:4502/system/console/services

JustinEd3Adobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

Your component is abstract - which means it doesn't actually get registered as a service. See http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/scr-annotations.html#abstract-service-descriptions