I have written a resource type servlet and used a utility class in it.
My core bundle state is active. But, the servlet is showing 'Unsatisfied (reference)' error.
When I checked for the particular servlet, it is showing me the attached issue.
Please explain what is the exact issue and how to get it resolved.
Solved! Go to Solution.
Views
Replies
Total Likes
We use @reference annotation to inject OSGi service.
You can define your Util class as similar to https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/w...
Then call the relevant static method using
Utils.methodname("") in your servlet.
Is GetUserProfileUtils an OSGi service? How did you call GetUserProfileUtils in your servlet?
It is not an OSGi service. A plain Util class that I'm calling using @reference annotation.
We use @reference annotation to inject OSGi service.
You can define your Util class as similar to https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/w...
Then call the relevant static method using
Utils.methodname("") in your servlet.
Hi Goyal,
This normally means that service you referenced from your service is not available in OSGi Service Registry.
Regards,
Peter
It might be because the UtilityService that you are trying to use does not exist in the OSGI Apache Felix environment. What's your implementation of the servlet?
You typically wouldn’t use @reference for the Utils class, because it’s reserved for dependency injection, injecting AEM services, as such.
If your utils class is created with static methods (as you should), all you would need to do is import the utils class into your project, and call:
Utils.getString(“”)
if you’d like to be a better backend developer, I would recommend you to download some linting libraries for your IDE like sonarLint. This will dramatically improved your code quality, and also enables learning opportunities as well.