Skip to main content
Level 2
Jun 6, 2017 7:02 AM UTC
Solved

OSGI srvice is not getting registered

Hi,

I am facing an issue i created a project of maven archType10 in eclipse and when i upload the bundle on felix console it does not show the service registered over there below is the code what i wrote and screenshot of the bundle on felix,

MyService.java (Interface)

package com.aem.community.core.services;

public interface MyService {

  public String helloWorld();

}

MyServiceImpl.java (class implementing Interface)

package com.aem.community.core.servicesImpl;

import org.apache.felix.scr.annotations.Service;

import com.aem.community.core.services.MyService;

import aQute.bnd.annotation.component.Component;

@Component(immediate=true)

@Service(value=MyService.class)

public class MyServiceImpl implements MyService {

  @Override

  public String helloWorld() {

  return ("Hello");

  }

}

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
shubham250894Accepted solution
Level 2
Jun 7, 2017 10:57 AM UTC

I made the blunder there is issue with the highlighted import i changed it to

import org.apache.felix.scr.annotations.Component;

and it works fine. Thanks for the help everyone

24 replies

Level 2
Jun 6, 2017 7:07 AM UTC

sorry , here is the bundle screenshot, JSP screenshot and null pointer exception

JSP

Exception

,

Bundle

Translate
cquser1
Level 7
Jun 6, 2017 10:31 AM UTC

Hi,

Not pretty sure, but can you just try with "@Service({MyService.class})" instead of @Service(value=MyService.class) and see if it helps.

Translate
Feike_Visser1
Adobe Employee
Adobe Employee
Jun 6, 2017 11:06 AM UTC

Is your bundle started?

Can you go to services in the OSGi console, and see if you have more info there?

Translate
Level 2
Jun 6, 2017 11:24 AM UTC

I can only see the below services,

the service i created is not there, hence it is giving null pointer exception

Translate
Level 2
Jun 6, 2017 11:26 AM UTC

yes bundle is started, Also, i can find my package name in MANIFEST info.

Translate
smacdonald2008
Level 10
Jun 6, 2017 2:44 PM UTC

Try this article - its only the bundle and the JSP that invokes it.

Scott's Digital Community: Creating your first AEM Service using an Adobe Maven Archetype project

Translate
VeenaVikraman
Community Advisor
Community Advisor
Jun 6, 2017 3:21 PM UTC

Hi Shubham

          Please provide below details

  1. Please check if the bundle is active. Please check the below screenshot for reference.

   If it is installed or in registered state , then check the cause of unresolved bundle

2. If your bundle is active, just check your logs and see if any information is available which says a conflict for the service.

3. Could you please provide the error log you see in your screen , because the screenshot you provided didn't give much insight on your issue.

          I did try your code snippet and I could see the service is registered. Providing the screenshots below for your reference

     My bundle is active and the service is showing up . I doubt there could be some other issue with your code, which can be figured out through the error logs

Thanks

Veena

Translate
Level 2
Jun 7, 2017 6:08 AM UTC

hi smacdonald,

Thanks for the help

Translate
Level 2
Jun 7, 2017 6:11 AM UTC

hi cquser1,

thanks for your concern but it didn't worked

Translate
Level 2
Jun 7, 2017 6:13 AM UTC

Hi Veena,

I cannot see anything like conflicting service in error log, should i give you the screenshot of the logs created after reloading the page ?

Translate