Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

OSGI srvice is not getting registered

Avatar

Level 3

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");

  }

}

1 Accepted Solution

Avatar

Correct answer by
Level 3

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

import.PNG

View solution in original post

24 Replies

Avatar

Level 3

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

JSP

jsp.PNG

Exception

null.PNG,

Bundle

bundle.PNG

Avatar

Level 8

Hi,

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

Avatar

Employee

Is your bundle started?

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

Avatar

Level 3

I can only see the below services,services.PNG

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

Avatar

Level 3

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

Avatar

Community Advisor

Hi Shubham

          Please provide below details

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

1223702_pastedImage_4.png

   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

1223712_pastedImage_8.png

1223711_pastedImage_7.png

     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

Avatar

Level 3

hi cquser1,

thanks for your concern but it didn't worked

Avatar

Level 3

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 ?

Avatar

Level 3

Hi Veena,

I got this in error log. Red marked logs says it is registered. error.PNG

in error log i cannot find my service at all

Avatar

Employee

Taking a step back, what exactly is the errormessage?

You posted a screenshot, but I can't see the errormessage there.

Avatar

Employee

thanks for this.

Can you confirm in your code, that indeed the service null. Thus causing the NPE.

Avatar

Employee

Also check in /system/console/components and see for more info there.

Avatar

Employee

Also I don't see "MyServiceImpl" in this list.