0
votes

getslingscripthelper().getservice() returns null.

I made sure the bundle and the service is active. However, instead of active, it has the number 16.. not sure if this has anything to do with it.

I tried deleting the bundle and reinstalling with the package manager.

Any help would be much appreciated!

1
Welcome to SO. SlingScriptHelper#getService takes an argument. What service are you trying to get? The class you're passing as an argument will determine the result of the call, as will the status of all services. The null implies that the service isn't active. Perhaps you're using the name of an implementation class instead of the interface used to register it? As for the 16, I believe this is the internal representation of a Component being active, not sure why it's displayed this way. - toniedzwiedz
Thanks Olaf, I am using the interface so I dont think it's that. The class itself is an encryption utility so perhaps it has something to do with running it on my local host? Other components in the bundle are working. - Sumwan
Did you check the error.log to see there is more info when this line is executed? - ronnyfm
Do you see your service listed in the bundle on the OSGI console? Wehn you create a service and it's published, you should see it in your bundle in the OSGI console. - Bambara

1 Answers

0
votes

Finally figured this out. It was because I was running the encryption utility service on my local host. I didn't have the keys properly configured in the right directory. After this was fixed it worked fine.

I'm still unsure what the 16 means in the status column of the osgi service but after I configured the keys correctly, the status changed back to 'active'.