title: Dozer unable to map Collection<Interface> member
body: <p>I have an object which contains a Collection:</p>
  
  <pre><code>public class Wrapper {
      private Collection&lt;Base&gt; bases = new LinkedList&lt;Base&gt;();
      public Collection&lt;Base&gt; getBases() {return bases;}
      public void setBases(final Collection&lt;Base&gt; bases) {this.bases = bases;}
  }
  </code></pre>
  
  <p>The implementations of the interface are quite simple:</p>
  
  <pre><code>public class BaseOne implements Base {
  }
  
  public class BaseTwo implements Base {
  }
  </code></pre>
  
  <p>When I run a simple test:</p>
  
  <pre><code>@Test
  public void testCopyOther() {
      final Wrapper wrapper =  new Wrapper();
      wrapper.getBases().add(new BaseOne());
  
      final Wrapper copy = dozer.map(wrapper, Wrapper.class);
  }
  </code></pre>
  
  <p>I get this exception:</p>
  
  <pre><code>org.dozer.MappingException: java.lang.NoSuchMethodException: com.usamp.biddingtool.model.service.impl.Base.&lt;init&gt;()
      at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:82)
      at org.dozer.factory.ConstructionStrategies$ByConstructor.newInstance(ConstructionStrategies.java:261)
      at org.dozer.factory.ConstructionStrategies$ByConstructor.create(ConstructionStrategies.java:245)
      at org.dozer.factory.DestBeanCreator.create(DestBeanCreator.java:65)
      at org.dozer.MappingProcessor.mapCustomObject(MappingProcessor.java:489)
      at org.dozer.MappingProcessor.mapOrRecurseObject(MappingProcessor.java:446)
      at org.dozer.MappingProcessor.addOrUpdateToList(MappingProcessor.java:776)
      at org.dozer.MappingProcessor.addOrUpdateToList(MappingProcessor.java:850)
      at org.dozer.MappingProcessor.mapListToList(MappingProcessor.java:686)
      at org.dozer.MappingProcessor.mapCollection(MappingProcessor.java:541)
      at org.dozer.MappingProcessor.mapOrRecurseObject(MappingProcessor.java:434)
      at org.dozer.MappingProcessor.mapFromFieldMap(MappingProcessor.java:342)
      at org.dozer.MappingProcessor.mapField(MappingProcessor.java:288)
      at org.dozer.MappingProcessor.map(MappingProcessor.java:248)
      at org.dozer.MappingProcessor.map(MappingProcessor.java:197)
      at org.dozer.MappingProcessor.map(MappingProcessor.java:187)
      at org.dozer.MappingProcessor.map(MappingProcessor.java:124)
      at org.dozer.MappingProcessor.map(MappingProcessor.java:119)
      at org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:120)
      at com.usamp.biddingtool.model.service.impl.DozerTest.testCopyOther(DozerTest.java:52)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
  </code></pre>
  
  <p>So, it seems that Dozer is trying to create an instance of the actual type being used in the collection while the type is just an interface.  Since interfaces cannot be instantiated an error is produced.</p>
  
  <p>I have seen others ask this question, but not really get any specific answer.  Are there any solutions for this issue?</p>
  
  <p>Thanks.
  -AP_ </p>