Unsatisfied (reference) Error for a utility class | Community
Skip to main content
New Participant
February 7, 2023
Solved

Unsatisfied (reference) Error for a utility class

  • February 7, 2023
  • 4 replies
  • 2226 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by DEBAL_DAS

We use @3214626 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/wcm/core/components/internal/Utils.java

 

Then call the relevant static method using

Utils.methodname("") in your servlet.

4 replies

BrianKasingli
New Participant
February 8, 2023

You typically wouldn’t use @3214626 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. 

BrianKasingli
New Participant
February 8, 2023

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?

Peter_Puzanovs
New Participant
February 7, 2023

Hi Goyal,

 

This normally means that service you referenced from your service is not available in OSGi Service Registry.

 

Regards,

Peter

DEBAL_DAS
New Participant
February 7, 2023

Is GetUserProfileUtils an OSGi service? How did you call GetUserProfileUtils in your servlet?

New Participant
February 8, 2023

It is not an OSGi service. A plain Util class that I'm calling using @3214626 annotation.

DEBAL_DAS
DEBAL_DASAccepted solution
New Participant
February 8, 2023

We use @3214626 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/wcm/core/components/internal/Utils.java

 

Then call the relevant static method using

Utils.methodname("") in your servlet.