Search code examples
compiler-errorsadobeaemosgi-bundle

Getting Service cannot be resolved to a type error while consuming OSGi service


I have created a component which consumes the sling service from OSGI bundle in Cq5. But while consuming it throws error stating that com.aem.HelloService cannot be resolved to a type , When looked under http://localhost:4502/system/console/services.

Service is running properly.


Solution

  • In your webconsole look for your OSGI bundle, this can be found for example under:

    http://localhost:4502/system/console/bundles
    

    Then under your bundle's properties look for the property called Symbolic Name. See below for an example:
    enter image description here

    This is the path you must use in your JSP import, for example, at the top of your JSP page:

    <%@page import="org.apache.sling.tooling.support.install%> //you might have to add .* at the end to import everything
    

    Then also make sure your OSGI service Java file is properly annotated and constrcuted as per the Adobe and other documentation