Hi,
The line

var service = sling.getService(Packages.com.me.helloservice.HelloService);

Is trying to get an OSGi service from the Service Registry named
com.me.helloservice.HelloService. Is such a service actually registered?
Generally (although not exclusively), those services are registered using
Declarative Services and your bundle doesn't have any DS components.

Regards,
Justin



On Wed, Apr 27, 2016 at 7:16 AM Ivan Gimenez <[email protected]> wrote:

> Hi
>
> I am evaluating Apache Sling for a project. I am running Sling8 via
> launchpad, downloaded org.apache.sling.launchpad-8.jar from Apache Site.
>
> I am trying to learn the basics before developing anything, so I created an
> OSGi bundle I try to invoke from an ESP script (GET.esp) using
>
> <html>
> <head>
>     <title><%= currentNode["jcr:title"] %></title>
> </head>
> <body>
>
>
> <%
>     var service =
> sling.getService(Packages.com.me.helloservice.HelloService);
>     var msg = "null service";
>     if(service)
>         msg = service.sayHello();
> %>
> <p><%= msg %></p>
>
> </body>
> </html>
>
>
> The page shows "null service" isntead of "Hello World!". (simplest OSGi
> bundle BTW)
>
> but ESP script is unable to resolve the OSGi bundle, althouth it has been
> properly loaded as shown in the Apache Felix system console.
>
> 123
>
> HelloServicePluginHelloServicePlugin
> Symbolic NameHelloServicePluginVersion0.0.1.SNAPSHOTBundle
> Locationinputstream:HelloServicePlugin-0.0.1-SNAPSHOT.jarLast
> ModificationTue Apr 26 17:40:50 CEST 2016DescriptionHello Service
> PluginStart Level20Exported
> Packagescom.me.helloservice,version=0.0.1Imported
> Packagesorg.osgi.framework,version=1.8.0 from org.apache.felix.framework
> (0)
> <http://localhost:8080/system/console/bundles/0>Manifest
> HeadersArchiver-Version: Plexus Archiver
> Bnd-LastModified: 1461685217794
> Build-Jdk: 1.8.0_77
> Built-By: igimenez
> Bundle-Description: Hello Service Plugin
> Bundle-ManifestVersion: 2
> Bundle-Name: HelloServicePlugin
> Bundle-SymbolicName: HelloServicePlugin
> Bundle-Version: 0.0.1.SNAPSHOT
> Created-By: Apache Maven Bundle Plugin
> Export-Package: com.me.helloservice; uses:="org.osgi.framework";
> version="0.0.1"
> Import-Package: org.osgi.framework; version="[1.5, 2)"
> Manifest-Version: 1.0
> Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.8))"
> Tool: Bnd-3.0.0.201509101326
> do I need to add any annotation on the OSGI plugin to allow to be invoked
> from Sling ?
>

Reply via email to