title: Error: Could not instantiate bean class - No default constructor found;
body: <p>I am trying to persist an object of Test type in my database through Spring and Java Persistence API</p>
  
  <p>I have a Test table in my database and I have created the corresponding Entity Class:</p>
  
  <pre><code>   @Entity
     @Table(name = "test")
     @XmlRootElement
     @NamedQueries({
     @NamedQuery(name = "Test2.findAll", query = "SELECT t FROM Test t"),
     @NamedQuery(name = "Test2.findByTestId", query = "SELECT t FROM Test t WHERE t.testId = :testId"),
     @NamedQuery(name = "Test2.findByTestint", query = "SELECT t FROM Test t WHERE t.testint = :testint"),
     @NamedQuery(name = "Test2.findByText", query = "SELECT t FROM Test t WHERE t.text = :text")})
  
  public class Test implements Serializable {
  private static final long serialVersionUID = 1L;
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Basic(optional = false)
  @Column(name = "testId")
  private Integer testId;
  @Column(name = "testint")
  private Integer testint;
  @Basic(optional = false)
  
  @Temporal(TemporalType.TIMESTAMP)
  private Date endtime;
  @Column(name = "text")
  private String text;
  
  public Test() {
  }
  
  public Test(Integer testId) {
      this.testId = testId;
  }
  
  public Test(Integer testId, Date starttime, Date endtime) {
      this.testId = testId;
      this.starttime = starttime;
      this.endtime = endtime;
  }
  
  public Integer getTestId() {
      return testId;
  }
  
  public void setTestId(Integer testId) {
      this.testId = testId;
  }
  
  public Integer getTestint() {
      return testint;
  }
  
  public void setTestint(Integer testint) {
      this.testint = testint;
  }
  
  
  
  public String getText() {
      return text;
  }
  
  public void setText(String text) {
      this.text = text;
  }
  }
  </code></pre>
  
  <p>Then I have created a Jpa Class that implements the TestDao interface: </p>
  
  <pre><code> @Repository("testDao")
  public class JpaTestDao  implements TestDao {
  
  
  public JpaTestDao(EntityManagerFactory emf) {
      this.emf = emf;
  }
  @PersistenceUnit
  private EntityManagerFactory emf;// = null;
  EntityManager em;
  
  public EntityManager getEntityManager() {
      return emf.createEntityManager();
  }
  @Transactional
  @Override
  public void create(Test test) {
      em = null;
      try {
          em = getEntityManager();
          em.getTransaction().begin();
          em.persist(test);
          em.getTransaction().commit();
      } finally {
          if (em != null) {
              em.close();
          }
      }
  }
  }
  </code></pre>
  
  <p>TestDao interface:</p>
  
  <pre><code>public interface TestDao {
  
      public void create(Test t);
  }
  </code></pre>
  
  <p>Finally I am receiving the following error:</p>
  
  <pre><code> Could not instantiate bean class [com.mycompany.jpa.JpaTestDao]: No default constructor   found; nested exception is java.lang.NoSuchMethodException: com.mycompany.jpa.JpaTestDao.
  </code></pre>
  
  <p>Could you, please, help me? I cannot figure out what is wrong?</p>