title: java.lang.NoSuchMethodException: JAXB Unmarshalling Interfaces
body: <p>I am following the threads related to JAXB Marshalling / Unmarshalling for a while now.</p>
  
  <p>I had run into problems while i was trying to convert a Java Object into XML, which had some interfaces in it. Later i found out this can be solved using EclipseLink's MOxy. @Bdoughan's articles here <a href="http://blog.bdoughan.com/2012/07/jaxb-no-annotations-required.html" rel="nofollow">http://blog.bdoughan.com/2012/07/jaxb-no-annotations-required.html</a> and answers were very helpful. But now, i have problems when i am trying to unmarshal the same XML file generated back into Java Objects.</p>
  
  <p>This is the interface.</p>
  
  <pre><code>public interface TimePeriod extends Serializable{
  
  /**
   * Return the end Time of the Time Period
   */
  public Date getEndDate();
  
  /**
   * Return the startTime of the Time Period
   */
  public Date getStartDate();
  
  /**
   * Sets the startTime of the Time period
   */
  public void setStartDate(Date newStartDate);
  
  /**
   * Sets the endTime of the Time period
   */
  public void setEndDate(Date newEndDate);
  
  }
  </code></pre>
  
  <p>One of the Implementations</p>
  
  <p>TaskStepTimePeriod</p>
  
  <pre><code>public class TaskStepTimePeriod implements TimePeriod {
  
  private Date taskStartDate;
  private Date taskEndDate;
  
  @Override
  public Date getEndDate() {
      return taskEndDate;
  }
  
  @Override
  public Date getStartDate() {
      return taskStartDate;
  }
  
  
  public void setTaskStartDate(Date newVal) {
      this.taskStartDate = newVal;
  }
  
  
  public void setTaskEndDate(Date newVal) {
      this.taskEndDate = newVal;
  }
  
  @Override
  public void setStartDate(Date newStartDate) {
      this.taskStartDate = newStartDate;
  }
  
  @Override
  public void setEndDate(Date newEndDate) {
      this.taskEndDate = newEndDate;
  }
  
  }
  </code></pre>
  
  <p>Marshalled XML</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;plannedProgram&gt;
    &lt;taskStep&gt;
       &lt;endDate&gt;2014-07-31T12:00:00.262+05:30&lt;/endDate&gt;
       &lt;startDate&gt;2014-06-01T12:00:00.262+05:30&lt;/startDate&gt;
    &lt;/taskStep&gt;
  &lt;/plannedProgram&gt;
  </code></pre>
  
  <p>So when i try to Unmarshall, i get this error stacktrace..</p>
  
  <pre><code> Exception in thread "main" Local Exception Stack: 
    Exception [EclipseLink-63] (Eclipse Persistence Services -      2.6.1.v20150916-55dc7c3):       org.eclipse.persistence.exceptions.DescriptorException
    Exception Description: The instance creation method      [com.cts.axb.model.TimePeriod.&lt;Default Constructor&gt;], with no parameters,    does not exist, or is not accessible.
    Internal Exception: java.lang.NoSuchMethodException:    com.cts.axb.model.TimePeriod.&lt;init&gt;()
    Descriptor: XMLDescriptor(com.cts.axb.model.TimePeriod --&gt; [])
  </code></pre>
  
  <p>It says no default constructor, but in an interface? Would really appreciate some pointers on what have i done wrong?</p>
  
  <p>Have i missed annotating any elements in the classes?</p>
  
  <p>My Unmarshalling code.!</p>
  
  <pre><code> try {
           context = JAXBContext.newInstance(PlannedProgram.class);    
           Unmarshaller jaxbUnmarshaller = context.createUnmarshaller();
           newMaintProg = (PlannedProgram) jaxbUnmarshaller.unmarshal(file);
           System.err.println("XML file succesffuly read");
       } catch (JAXBException e) {
           System.err.println("Error Reading /  Unmarshalling the XML file "+ e);          
       }  
  </code></pre>