title: "Could not resolve matching constructor" error when passing in constructor-arg for child class
body: <p>I have the following classes:</p>
  
  <pre><code>public abstract class ParentClass
  {
      public ParentClass()
      {
          throw new RuntimeException("An ID must be specified.");
      }
  
      public ParentClass(String id)
      {
          this(id, DEFUALT_ARG_VALUE);
      }
  
      public ParentClass(String id, int anotherArg)
      {
          this.id = id;
          //stuff with anotherArg
      }
  
      public abstract void doInstanceStuff();
  }
  
  public class ChildClass extends ParentClass
  {
      @Override
      public void doInstanceStuff()
      {
          //....
      }
  }
  </code></pre>
  
  <p>In my application context I have this:</p>
  
  <pre><code>&lt;bean id="myChildInstance" class="com.foo.bar.ChildClass " scope="singleton"&gt;
      &lt;constructor-arg value="myId" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>The problem is that when the server starts up I get the following error:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ivpluginHealthCheckTest' defined in ServletContext resource [/WEB-INF/spring/root-context.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
  </code></pre>
  
  <p>Seeing the error, I tried adding the different attributes, but with no luck. I ended up with something like this:</p>
  
  <pre><code>&lt;bean id="myChildInstance" class="com.foo.bar.ChildClass " scope="singleton"&gt;
      &lt;constructor-arg value="myId" index="0" type="java.lang.String" name="id" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>And I still get the same error.</p>
  
  <p>I tried adding the same constructors to my child class, and just call <code>super()</code> with the appropriate arguments for each one, and that seems to fix it. However, I don't want to have to add the same constructors in all my child instances and have to maintain those with the parent class.</p>
  
  <p>Is there some reason Spring has trouble calling an inherited constructor to instantiate the class? Is there something I can do to make this work?</p>