1 Reply Latest reply on Dec 30, 2005 8:20 PM by epbernard

    No default constructor for entity

    mmarcom

      hello all,
      i am trying to get acquainted with EJB3.. i developed a simple SLSB which acts as a facade to my entity ejb
      my entity ejb is as follows:


      @Entity
      @Table (name="jobApplication")

      public class JobApplication
      implements java.io.Serializable {

      private String jobName;
      private String jobStatus;
      private String jobAgency;
      private String jobApplicationDate;
      private String jobSalary =;
      private String jobLocation =;
      private int id;


      public JobApplication() {}

      public JobApplication(String jobName, String jobStatus,
      String jobAgency, String jobApplicationDate,
      String jobSalary, String jobLocation) {
      this.jobName = jobName;
      this.jobStatus = jobStatus;
      this.jobAgency = jobAgency;
      this.jobApplicationDate = jobApplicationDate;
      this.jobSalary = jobSalary;
      this.jobLocation = jobLocation;
      }


      @Id(generate = GeneratorType.AUTO)
      public int getId() {
      return id;
      }

      public void setId(int id) {
      this.id = id;
      }


      /**
      * @return the job name
      */
      public String getJobName() {
      return jobName;
      }


      /**
      * @return the status of the job
      */
      public String getJobStatus() {
      return jobStatus;
      }


      /**
      * @return the job agency
      */
      public String getJobAgency() {
      return jobAgency;
      }

      /**
      * @return the job name
      */
      public String getJobApplicationDate() {
      return jobApplicationDate;
      }

      /**
      * @return the job salary
      */
      public String getJobSalary() {
      return jobSalary;
      }

      /**
      * @return the job location
      */
      public String getJobLocation() {
      return jobLocation;
      }

      /**
      * set the job name
      */
      public void setJobName(String name) {
      this.jobName = name;
      }

      /**
      * set the job agency
      */
      public void setJobAgency(String agency){
      this.jobAgency = agency;
      }

      /**
      * set the job applicationDate
      */
      public void setJobApplicationDate(String date) {
      this.jobApplicationDate = date;
      }

      /**
      * set the job salary
      */
      public void setJobSalary(String salary) {
      this.jobSalary = salary;
      }

      /**
      * set the job location
      */
      public void setJobLocation(String location) {
      this.jobLocation = location;
      }

      /**
      * Set the job status
      */
      public void setJobStatus(String status) {
      this.jobStatus = status;
      }

      }



      my session is as follows:

      @Stateless
      @Remote ( {Calculator.class})

      public class CalculatorBean implements Calculator,java.io.Serializable{

      @PersistenceContext EntityManager em;

      public double calculate(int start, int end, double growthrate, double saving) {
      double tmp = Math.pow(1. + growthrate / 12.,
      12. * (end - start) + 1);




      return saving * 12. * (tmp - 1) / growthrate;
      }

      // @PostConstruct



      @TransactionAttribute(TransactionAttributeType.REQUIRED)
      public void addJobApplication(String name,String status,
      String agency, String appDate,
      String salary, String location) {

      System.err.println("..CalculatorBean.persisting JobApplication..");

      JobApplication job = new JobApplication(name, status, agency,
      appDate, salary, location);
      em.persist(job);
      }


      public Collection getJobApplications() {
      return em.createQuery("from JobApplication ja").getResultList();
      }

      }


      it looks like em is not persisting anything...
      actually, when i try to use a query to find what i have just inserted, i got back following excepiton

      Exception in looking up calculator..
      2005-12-13 19:58:33,093 INFO [STDOUT] javax.ejb.EJBException: null; CausedByException is:
      No default constructor for entity: com.myapp.ejb3.agencies.JobApplication
      2005-12-13 19:58:33,109 INFO [STDOUT] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:46)
      2005-12-13 19:58:33,109 INFO [STDOUT] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:70)
      2005-12-13 19:58:33,109 INFO [STDOUT] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
      2005-12-13 19:58:33,109 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      2005-12-13 19:58:33,109 INFO [STDOUT] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
      2005-12-13 19:58:33,109 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      2005-12-13 19:58:33,109 INFO [STDOUT] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
      2005-12-13 19:58:33,109 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      2005-12-13 19:58:33,109 INFO [STDOUT]


      anyone can help me out?
      thanks and regards
      marco