title: Inject class from bean with property HashMaps of <String, Class>
body: <p>I'm looking to populate a class with two HashMaps of types HashMap via spring injection.  Unfortunately I'm getting the following error when I attempt to build my platform.</p>
  
  <pre><code>    SEVERE: Exception sending context initialized event to listener instance of class de.hybris.platform.spring.HybrisContextLoaderListener
  org.springframework.beans.FatalBeanException: Context hybris Global Context Factory  couldn't  be created correctly due to, Error creating bean with name 'EnumUtil' defined in class path resource [payment3dsi-spring.xml]: Cannot create inner bean 'util:map#4b13c655' of type [org.springframework.beans.factory.config.MapFactoryBean] while setting bean property 'stateCodes'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'util:map#4b13c655': Error converting typed String value for bean property 'sourceMap' with key [TypedStringValue: value [US-IL], target type [class java.lang.String]]; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'com.gsk.platform.payment3dsi.cardmanagement.CreditCardManagementServiceStub$StateProvinceCode'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.gsk.platform.payment3dsi.cardmanagement.CreditCardManagementServiceStub$StateProvinceCode]: no matching editors or conversion strategy found
  </code></pre>
  
  <p>I'm not sure why there are conversion errors? I should just be setting a key/value pair, no conversion needed.  My bean looks like this:</p>
  
  <pre><code>    &lt;bean name="EnumUtil" class="com.gsk.platform.payment3dsi.util.EnumUtil" scope="tenant"&gt;
      &lt;property name="stateCodes"&gt;
          &lt;util:map map-class="java.util.HashMap" key-type="java.lang.String" value-type="com.gsk.platform.payment3dsi.cardmanagement.CreditCardManagementServiceStub.StateProvinceCode"&gt;
              &lt;entry key="US-IL" value="StateProvinceCode.Illinois" /&gt;
              .
              .
              .....etc
          &lt;/util:map&gt;
      &lt;/property&gt;
      &lt;property name="countryCodes"&gt;
          &lt;util:map map-class="java.util.HashMap" key-type="java.lang.String" value-type="com.gsk.platform.payment3dsi.cardmanagement.CreditCardManagementServiceStub.CountryCode"&gt;
              &lt;entry key="US" value="CountryCode.UnitedStates" /&gt;
              &lt;entry key="CA" value="CountryCode.Canada" /&gt;
          &lt;/util:map&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>My Enum class looks like the following:</p>
  
  <pre><code>package com.gsk.platform.payment3dsi.util;
  
  import java.util.HashMap;
  import java.util.Map.Entry;
  
  import com.gsk.platform.payment3dsi.cardmanagement.CreditCardManagementServiceStub.CountryCode;
  import com.gsk.platform.payment3dsi.cardmanagement.CreditCardManagementServiceStub.StateProvinceCode;
  
  public class EnumUtil {
      private HashMap&lt;String, StateProvinceCode&gt; stateCodes;
      private HashMap&lt;String, CountryCode&gt; countryCodes;
  
      private HashMap&lt;String, StateProvinceCode&gt; getStateCodes() {
          return stateCodes;
      }
  
      private HashMap&lt;String, CountryCode&gt; getCountryCodes() {
          return countryCodes;
      }
  
      public void setStateCodes(HashMap&lt;String, StateProvinceCode&gt; stateCodes) {
          this.stateCodes = stateCodes;
      }
  
      public void setCountryCodes(HashMap&lt;String, CountryCode&gt; countryCodes) {
          this.countryCodes = countryCodes;
      }
  
      public String getRegionCodeForStateCode(StateProvinceCode stateProvinceCode){
          for(Entry&lt;String, StateProvinceCode&gt; entry : stateCodes.entrySet()){
              if(entry.getValue().equals(stateProvinceCode)){
                  return entry.getKey();
              }
          }
          return null;
      }
  
      public StateProvinceCode getStateCodeFromRegionCode(String regionCode){
          return getStateCodes().get(regionCode);
      }
  
      public String getCountryIsoForCountryCode(CountryCode countryCode){
          for(Entry&lt;String, CountryCode&gt; entry : countryCodes.entrySet()){
              if(entry.getValue().equals(countryCode)){
                  return entry.getKey();
              }
          }
          return null;
      }
  
      public CountryCode getCountryCodeFromCountryIso(String countryCode){
          return getCountryCodes().get(countryCode);
      }
  }
  </code></pre>
  
  <p>And I'm attempting to use this class in my code in the following manner:</p>
  
  <pre><code>    @Resource(name = "EnumUtil")
      private EnumUtil enumUtil;
  
      .
      .
      .
  
  
      billingAddress.setStateProvinceCode(enumUtil.getStateCodeFromRegionCode(billingAddressData.getRegion().getIsocode()));
  billingAddress.setCountryCode(enumUtil.getCountryCodeFromCountryIso(billingAddressData.getCountry().getIsocode()));
  </code></pre>
  
  <p>Any ideas on what the issue is here? I'm just looking to inject these two pre-populated maps into the class and not sure what the conversion error is from.  Thanks!</p>