Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Importing the SocialUtils using @Reference annotation causing servlet status is unsatisfied

Avatar

Former Community Member

Hi folks,

When I am importing the SocialUtils using @Reference annotation servlet status is unsatisfied in component list.

@Reference

private SocialUtils socialUtils;

getting this message

Reference socialUtils["Unsatisfied","Service Name: com.adobe.cq.social.ugcbase.SocialUtils","Cardinality: 1..1","Policy: static","Policy Option: reluctant","No Services bound"]

But I can see the SocialUtilsImpl is enabled and in the component list also.


1863

com.adobe.cq.social.ugcbase.impl.SocialUtilsImpl
active

Really appreciate any inputs..

3 Replies

Avatar

Level 3

Hi Kanchan,

Can you share the entire code with me?

You can email it to vmitra@adobe.com. It's a but difficult to debug the same with the information that you have provided.

Thanks

Varun

Avatar

Former Community Member

Hi varunmitra,

Thanks for the reply. I am pasting the code here.

import java.io.IOException;

import javax.servlet.ServletException;

import javax.servlet.http.Cookie;

import org.apache.felix.scr.annotations.Reference;

import org.apache.felix.scr.annotations.ReferenceCardinality;

import org.apache.felix.scr.annotations.ReferencePolicy;

import org.apache.felix.scr.annotations.sling.SlingServlet;

import org.apache.sling.api.SlingHttpServletRequest;

import org.apache.sling.api.SlingHttpServletResponse;

import org.apache.sling.api.servlets.SlingSafeMethodsServlet;

import org.apache.sling.commons.json.JSONException;

import org.apache.sling.commons.json.JSONObject;

import org.apache.sling.jcr.api.SlingRepository;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import com.adobe.cq.social.ugcbase.SocialUtils;

@SlingServlet(paths = "/bin/socialcloud.json", methods = {"GET"}, extensions = {"json" })

public class SocialIntegrationServlet extends SlingSafeMethodsServlet{

  /**

  *

  */

  private static final long serialVersionUID = 6999713032167059980L;

  /**

  *

  */

  private static final Logger log = LoggerFactory.getLogger(SocialIntegrationServlet.class);

  @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY, policy = ReferencePolicy.STATIC)

    private SlingRepository repository;

  @Reference

  private SocialUtils socialUtils;

  @Override

  protected void doGet(SlingHttpServletRequest request,

  SlingHttpServletResponse response) throws ServletException,

  IOException {

  //log.info("socialUtils is::::::::"+socialUtils);

  String sUsername = request.getParameter("user");

  Cookie[] cookies = request.getCookies();

  try {

  response.setCharacterEncoding("utf8");

         response.setContentType("application/json");

        

         JSONObject result = new JSONObject();

         result.put("result", "Got your call");

       

  response.getWriter().write(result.toString(4));

  } catch (JSONException e) {

  e.printStackTrace();

  }

  }

}

If I am removing the @Reference SocialUtils then the servlet is working properly.