title: Unsatisfied dependency expressed through constructor argument with index 0
body: <p>I am getting the following error. I have also mentioned the java code related to the error.</p>
  
  <p><strong>Error</strong></p>
  
  <p>Following is the error I am getting</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.List com.hp.ccue.serviceExchange.rest.OrderUtilsResource.orderUtils; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sawOrderUtils' defined in URL [jar:file:/opt/hp/propel/sx/WEB-INF/lib/sx-adapter-saw-2.20-SNAPSHOT.jar!/com/hp/ccue/serviceExchange/adapter/saw/util/SawOrderUtils.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [com.hp.ccue.serviceExchange.adapter.saw.SawOperationExecutor]: : No qualifying bean of type [com.hp.ccue.serviceExchange.adapter.saw.SawOperationExecutor] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.hp.ccue.serviceExchange.adapter.saw.SawOperationExecutor] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
          at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
          ... 58 more
  </code></pre>
  
  <p><strong>SawOrderUtils.java</strong>
  The file for which the error is related</p>
  
  <pre><code>package com.hp.ccue.serviceExchange.adapter.saw.util;
  
  import com.google.common.base.Predicate;
  import com.google.common.collect.ImmutableMap;
  import com.google.common.collect.Maps;
  import com.hp.ccue.serviceExchange.SXConstants;
  import com.hp.ccue.serviceExchange.adapter.saw.SawConstants;
  import com.hp.ccue.serviceExchange.adapter.saw.SawOperationExecutor;
  import com.hp.ccue.serviceExchange.aggregation.AggregationConstants;
  import com.hp.ccue.serviceExchange.config.Configuration;
  import com.hp.ccue.serviceExchange.message.MessageTransformer;
  import com.hp.ccue.serviceExchange.message.builder.MessageConstants;
  import com.hp.ccue.serviceExchange.utils.JsonUtils;
  import com.hp.ccue.serviceExchange.utils.MessageUtils;
  import com.hp.ccue.serviceExchange.utils.OrderUtilsBase;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  
  import java.util.List;
  import java.util.Map;
  import java.util.Objects;
  
  import static com.google.common.base.Objects.firstNonNull;
  import static com.hp.ccue.serviceExchange.SXConstants.SawInstancesCfg;
  import static com.hp.ccue.serviceExchange.utils.JsonUtils.getField;
  
  @Component
  public class SawOrderUtils extends OrderUtilsBase {
      @Autowired
      private Configuration configuration;
  
      @Autowired
      private MessageTransformer messageTransformer;
  
      @Autowired
      public SawOrderUtils(SawOperationExecutor operationExecutor) {
          super(SawConstants.SAW_TYPE, operationExecutor, SawInstancesCfg.CFG_NAME);
      }
  
      @Override
      public Map&lt;String, String&gt; getInstances() {
          Map&lt;String, Object&gt; allInstanceConfigs = configuration.getConfiguration(getInstancesConfigPath());
          Map&lt;String, Object&gt; instanceConfigs = Maps.filterValues(allInstanceConfigs, new Predicate&lt;Object&gt;() {
              @Override
              public boolean apply(Object input) {
                  @SuppressWarnings("unchecked")
                  Map&lt;String, Object&gt; instanceConfig = (Map&lt;String, Object&gt;) input;
                  return firstNonNull(JsonUtils.getBooleanField(instanceConfig, SawInstancesCfg.R2F_ENABLED), false);
              }
          });
          return MessageUtils.instanceNames(instanceConfigs);
      }
  
      @Override
      protected Map&lt;String, String&gt; fetchCatalogItems(String targetInstance) {
          Map&lt;String, Object&gt; operationOutput = executeOperationForInstance(OPERATION_GET_CATALOG_ITEMS, targetInstance);
          return getField(operationOutput, MessageConstants.RESULT);
      }
  
      @Override
      protected List&lt;String&gt; fetchContacts(String targetInstance) {
          Map&lt;String, Object&gt; operationOutput = executeOperationForInstance(OPERATION_GET_CONTACTS, targetInstance);
          return getField(operationOutput, MessageConstants.RESULT);
      }
  
      @Override
      public String getCatalogItemForm(String targetInstance, String itemId, String authToken) throws Exception {
          Map&lt;String, Object&gt; offeringOperationOutput = executeOperationForInstance(AggregationConstants.OPERATION_GET_OFFERING, targetInstance,
                  ImmutableMap.&lt;String, Object&gt;of("itemID", itemId));
  
          Map&lt;String, Object&gt; offering = getField(offeringOperationOutput, MessageConstants.RESULT);
  
          if (offering == null) {
              return "";
          }
  
          Map&lt;String, Object&gt; infrastructure = configuration.getConfiguration(SXConstants.INFRASTRUCTURE_CONFIG);
  
          if (Objects.equals(JsonUtils.getStrField(offering, "summary", "type"), "SUPPORT")) {
              List&lt;Map&lt;String, Object&gt;&gt; fields = JsonUtils.getField(offering, "form", "fields");
              fields.removeIf(field -&gt; {
                  final String id = JsonUtils.getStrField(field, "id");
                  return Objects.equals(id, "name") || Objects.equals(id, "description");
              });
          }
  
          return messageTransformer.transformMessage(ImmutableMap.of(
                  "offering", offering,
                  "userAuthToken", authToken,
                  "infrastructure", infrastructure
          ), "ui/optionsHtmlTransform.ftl");
      }
  }
  </code></pre>
  
  <p><strong>SawOperationExecutor.java</strong></p>
  
  <pre><code>package com.hp.ccue.serviceExchange.adapter.saw;
  
  import com.google.common.net.HttpHeaders;
  import com.hp.ccue.serviceExchange.SXConstants.SawInstancesCfg;
  import com.hp.ccue.serviceExchange.adapter.caseex.CxAwareOperationExecutor;
  import com.hp.ccue.serviceExchange.adapter.saw.sawBeans.BulkOperationResult;
  import com.hp.ccue.serviceExchange.adapter.saw.sawBeans.BulkOperationResult.CompletionStatuses;
  import com.hp.ccue.serviceExchange.adapter.saw.sawBeans.BulkOperationResult.EntityResult;
  import com.hp.ccue.serviceExchange.adapter.saw.sawBeans.BulkOperationResult.ErrorDetails;
  import com.hp.ccue.serviceExchange.adapter.saw.util.SXSAWImplProperties;
  import com.hp.ccue.serviceExchange.config.Configuration;
  import com.hp.ccue.serviceExchange.http.HttpRequest;
  import com.hp.ccue.serviceExchange.http.HttpResponse;
  import com.hp.ccue.serviceExchange.http.HttpResponseWrapper;
  import com.hp.ccue.serviceExchange.operation.OperationConstants;
  import com.hp.ccue.serviceExchange.utils.JsonUtils;
  import com.hp.ccue.serviceExchange.utils.ValidationUtils;
  import org.apache.http.StatusLine;
  import org.apache.http.message.BasicStatusLine;
  import org.springframework.beans.factory.annotation.Autowired;
  
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.core.Response.Status;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Locale;
  import java.util.Map;
  import java.util.Objects;
  import java.util.Optional;
  import java.util.Set;
  import java.util.function.Function;
  import java.util.stream.Collectors;
  
  import static com.google.common.base.Objects.firstNonNull;
  import static com.hp.ccue.serviceExchange.SXConstants.SUPPORTED_LANGUAGE_TAGS;
  
  public class SawOperationExecutor extends CxAwareOperationExecutor {
  
      private static final String LOGIN_REQUEST_URL = "/auth/authentication-endpoint/authenticate/login";
      private static final String DOWNLOAD_ATTACHMENT_URL = "/frs/file-list/";
      private static final String DOWNLOAD_IMAGES_URL = "/frs/image-list/";
      private static final String IMAGES_URL = "/js/modules/saw/resources/images/";
  
      @Autowired
      private SawNotificationSetupExecutor notificationSetupExecutor;
  
      private Set&lt;String&gt; operationsWithoutLogging;
  
      @Autowired
      private Configuration configuration;
  
      public void setOperationsWithoutLogging(Set&lt;String&gt; operationsWithoutLogging) {
          this.operationsWithoutLogging = operationsWithoutLogging;
      }
  
      public SawOperationExecutor() {
          super(SawConstants.SAW_TYPE, SawInstancesCfg.CFG_NAME, true);
          setDefaultHttpRequestContentType(MediaType.APPLICATION_JSON);
      }
  
      private Collection&lt;String&gt; getInstanceEndpoints(){
          Collection&lt;String&gt; instanceEndpoints = new ArrayList&lt;&gt;();
          Map&lt;String, Object&gt; allInstanceConfigs = configuration.getConfiguration(SawInstancesCfg.CFG_NAME);
          for (Object value : allInstanceConfigs.values()) {
              @SuppressWarnings("unchecked")
              Map&lt;String,Object&gt; instance = (Map&lt;String, Object&gt;) value;
              instanceEndpoints.add((String)instance.get("endpoint"));
          }
          return instanceEndpoints;
      }
  
      @Override
      public void afterPropertiesSet() throws Exception {
          super.afterPropertiesSet();
          Set&lt;String&gt; skippedOperations = firstNonNull(operationsWithoutLogging, Collections.&lt;String&gt;emptySet());
          for (String operation : skippedOperations) {
              skipLoggingForOperation(operation);
          }
      }
  
      @Override
      protected void beforeExecuteOperation(String operationName, Map&lt;String, Object&gt; message, Map&lt;String, Object&gt; context, boolean doLogging) {
          context.put(KEY_BUNDLE, SXSAWImplProperties.getMessagesBundle());
          context.put(KEY_BUNDLES, SUPPORTED_LANGUAGE_TAGS.stream()
                  .collect(Collectors.toMap(Function.identity(), tag -&gt; SXSAWImplProperties.getMessagesBundle(Locale.forLanguageTag(tag)))));
      }
  
      @Override
      protected HttpResponse afterHttpResponseReceived(final HttpResponse httpResponse, final HttpRequest request) {
          // SAW HTTP responses are buggy!
          // we need to wrap them to determine proper Content-Type - the server does not send them
          // we must wrap all methods which have something to do with Content-Type handling
          HashMap&lt;String, Object&gt; context = new HashMap&lt;&gt;(); // unfortunately we don't have the context here; fixing this would required changing method signature
          SawHttpResponseWrapper result = new SawHttpResponseWrapper(httpResponse, request);
          getEffectiveStatusCode(httpResponse, context).ifPresent(result::setStatus);
          return result;
      }
  
      private Optional&lt;Integer&gt; getEffectiveStatusCode(HttpResponse httpResponse, Map&lt;String, Object&gt; context) {
          try {
              Optional&lt;BulkOperationResult&gt; bulkOperationResult = parseBulkOperationResult(httpResponse, context);
              if (bulkOperationResult.isPresent() &amp;&amp; !Objects.equals(bulkOperationResult.get().getMeta().getCompletionStatus(), CompletionStatuses.FAILED)) {
                  return Optional.empty();
              }
              return bulkOperationResult.flatMap(SawOperationExecutor::getErrorDetails).map(ErrorDetails::getHttpStatus);
          } catch (Exception e) {
              return Optional.empty();
          }
      }
  
      private class SawHttpResponseWrapper extends HttpResponseWrapper {
  
          private final HttpRequest request;
          private int statusCode;
          private StatusLine statusLine;
  
          public SawHttpResponseWrapper(HttpResponse httpResponse, HttpRequest request) {
              super(httpResponse);
              this.request = request;
              this.statusCode = httpResponse.getStatusCode();
              this.statusLine = httpResponse.getStatusLine();
          }
  
          @Override
          public String getHeader(String headerName) {
              if (headerName.equals(HttpHeaders.CONTENT_TYPE) &amp;&amp; !isUrlKnownToHaveCorrectContentType(request.getUrl())) {
                  if (request.getUrl().contains(LOGIN_REQUEST_URL)) {
                      // authentication response is plaintext
                      return MediaType.TEXT_PLAIN;
                  } else {
                      // other responses are JSON
                      return MediaType.APPLICATION_JSON;
                  }
              }
              // else:
              return super.getHeader(headerName);
          }
  
          @Override
          public boolean hasStringContent() {
              //noinspection SimplifiableIfStatement
              if (!isUrlKnownToHaveCorrectContentType(request.getUrl())) {
                  return true;
              }
              return super.hasStringContent();
          }
  
          @Override
          public boolean isJson() {
              return getHeader(HttpHeaders.CONTENT_TYPE).equals(MediaType.APPLICATION_JSON);
          }
  
          private boolean isUrlKnownToHaveCorrectContentType(String url) {
              for (String endpoint : getInstanceEndpoints()) {
                  if (url.startsWith(endpoint)) {
                      return url.contains(DOWNLOAD_ATTACHMENT_URL) || url.contains(IMAGES_URL) || url.contains(DOWNLOAD_IMAGES_URL);
                  }
              }
              return true;
          }
  
          @Override
          public int getStatusCode() {
              return statusCode;
          }
  
          @Override
          public StatusLine getStatusLine() {
              return statusLine;
          }
  
          void setStatus(int statusCode) {
              this.statusCode = statusCode;
              Status status = Status.fromStatusCode(statusCode);
              String reasonPhrase = status != null ? status.getReasonPhrase() : String.format("HTTP %s", statusCode);
              this.statusLine = new BasicStatusLine(getDelegate().getStatusLine().getProtocolVersion(), statusCode, reasonPhrase);
          }
      }
  
      @Override
      protected void executeNotificationSetup(
              String entityId, Map&lt;String,Object&gt; entity, String checkOperation, Map&lt;String, Object&gt; checkOperationInputMessage, String catalogCallbackTemplate,
              EntityRegistrationMode mode, Map&lt;String, Object&gt; context, Map&lt;String, Object&gt; stepConfig) throws Exception {
          notificationSetupExecutor.executeNotificationSetup(
                  entityId, entity, checkOperation, checkOperationInputMessage, catalogCallbackTemplate, mode, context, stepConfig);
      }
  
      @Override
      protected boolean isResponseSuccess(String operationName, Map&lt;String, Object&gt; stepConfig, HttpResponse httpResponse, Map&lt;String, Object&gt; message, Map&lt;String, Object&gt; context) {
          final int statusCode = httpResponse.getStatusCode();
          List&lt;Integer&gt; whiteListedStatuses = firstNonNull(JsonUtils.&lt;List&lt;Integer&gt;&gt;getField(stepConfig, OperationConstants.REPORT_SUCCESS_FOR_HTTP_STATUSES),
                  Collections.&lt;Integer&gt;emptyList());
          //noinspection SimplifiableIfStatement
          if (whiteListedStatuses.contains(statusCode)) {
              return true;
          }
          return statusCode &lt; 400;
      }
  
      private Optional&lt;BulkOperationResult&gt; parseBulkOperationResult(HttpResponse httpResponse, Map&lt;String, Object&gt; context) {
          if (!httpResponse.isJson()) {
              return Optional.empty();
          }
          Object jsonPayload;
          try {
              jsonPayload = parseJsonPayload(httpResponse, context);
          } catch (IOException e) {
              throw new RuntimeException(e);
          }
          if (!(jsonPayload instanceof Map)) {
              return Optional.empty();
          }
          BulkOperationResult bulkOperationResult;
          try {
              //noinspection unchecked
              bulkOperationResult = JsonUtils.readBean((Map&lt;String, Object&gt;) jsonPayload, BulkOperationResult.class);
              ValidationUtils.validateBean(bulkOperationResult);
          } catch (Exception e) {
              return Optional.empty();
          }
          return Optional.of(bulkOperationResult);
      }
  
      @Override
      protected String getDetailErrorMessage(String operationName, Map&lt;String, Object&gt; stepConfig, HttpResponse httpResponse, Map&lt;String, Object&gt; message, Map&lt;String, Object&gt; context) {
          if (!httpResponse.isJson()) {
              return null;
          }
          try {
              ErrorDetails errorDetails = parseBulkOperationResult(httpResponse, context).flatMap(SawOperationExecutor::getErrorDetails).orElse(null);
              if (errorDetails == null) {
                  return null;
              }
              final Integer httpStatus = errorDetails.getHttpStatus();
              final String detailMessage = errorDetails.getMessage();
              if (httpStatus == null || detailMessage == null) {
                  return null;
              }
              return String.format("%s (effective HTTP status: %s)", detailMessage, httpStatus);
          } catch (RuntimeException e) {
              log.debug("Failed to extract the detail message.", e);
              return null;
          }
      }
  
      private static Optional&lt;ErrorDetails&gt; getErrorDetails(BulkOperationResult bulkOperationResult) {
          ErrorDetails errorDetails;
          final List&lt;EntityResult&gt; entityResultList = bulkOperationResult.getEntityResultList();
          if (entityResultList.size() != 1) { // let's cover only the case of single entity
              errorDetails = bulkOperationResult.getMeta().getErrorDetails();
          } else {
              errorDetails = entityResultList.get(0).getErrorDetails();
          }
          return Optional.ofNullable(errorDetails);
      }
  }
  </code></pre>
  
  <p><strong>SAWAdapterContext.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
         http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"&gt;
  
      &lt;context:component-scan base-package="com.hp.ccue.serviceExchange.adapter.saw"/&gt;
      &lt;context:component-scan base-package="com.hp.ccue.serviceExchange.adapter.saw.util"/&gt;
      &lt;context:component-scan base-package="com.hp.ccue.serviceExchange.adapter.saw.sawBeans"/&gt;
      &lt;context:component-scan base-package="com.hp.ccue.serviceExchange.adapter.saw.caseex"/&gt;
      &lt;context:component-scan base-package="com.hp.ccue.serviceExchange.adapter.saw.freemarker"/&gt;
      &lt;context:component-scan base-package="com.hp.ccue.serviceExchange.adapter.saw.healthcheck"/&gt;
  
     &lt;!--  &lt;bean class="com.hp.ccue.serviceExchange.adapter.saw.SawOperationExecutor"&gt;
          &lt;property name="operationsWithoutLogging"&gt;
              &lt;set&gt;
                  &lt;value&gt;getChangedIncidents&lt;/value&gt;
                  &lt;value&gt;getChangedRequests&lt;/value&gt;
                  &lt;value&gt;getChangedOfferings&lt;/value&gt;
                  &lt;value&gt;getAggregationFeatures&lt;/value&gt;
              &lt;/set&gt;
          &lt;/property&gt;
      &lt;/bean&gt; --&gt;
  
      &lt;!--
          To avoid IllegalArgumentException when autowiring lastUpdatedEntityDao in SawChangeListener:
          http://stackoverflow.com/questions/18369258/spring-aop-at-service-layer
      --&gt;
      &lt;aop:aspectj-autoproxy proxy-target-class="true"/&gt;
  
  &lt;/beans&gt;
  </code></pre>