Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Bundle registers as a component but no longer as a service

Avatar

Level 6

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.

1 Accepted Solution

Avatar

Correct answer by
Employee

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...

View solution in original post

4 Replies

Avatar

Level 6

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

Avatar

Level 10

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

Avatar

Correct answer by
Employee

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...