1

Hi everyone I have problems with my JPA project. Fichier.java end Application.java implements an interface "FileSystemElement.java" Those are my classes Application.java

package com.bfi.webtop.model;



import java.io.Serializable;
import java.util.*;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;

/** @pdOid d477195f-149e-4336-8586-19d6a09ee2d4 */
@Entity
@Table(name="application_")
public abstract class Application implements FileSystemElement, Serializable {
//  public Application() {
//      super();
//  }



  public Application(int id_app, String url) {
super();
this.id_app = id_app;
this.url = url;
  }



      public Application() {
  super();
  // TODO Auto-generated constructor stub
   }



  private int id_app;

  private java.lang.String url;

  /**
  * @return the url
  */
  public java.lang.String getUrl() {
return url;
   }

         /**
  * @param url the url to set
     */
      public void setUrl(java.lang.String url) {
          this.url = url;
    }

    /**
      * @return the id_app
   */
 @Id
 @GeneratedValue(strategy=GenerationType.AUTO)
public int getId_app() {
return id_app;
}

/**
 * @param id_app the id_app to set
 */
public void setId_app(int id_app) {
this.id_app = id_app;
}

}

Fichier.java

package com.bfi.webtop.model;

/***********************************************************************
 * Module:  Fichier.java
 * Author:  Marwa
 * Purpose: Defines the Class Fichier
 ***********************************************************************/

import java.util.*;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;


@Entity
public abstract class Fichier implements FileSystemElement {
 private int id_fichier;

   private java.lang.String extension;
   private java.lang.Boolean supprim;
/**
 * @return the extension
 */
public java.lang.String getExtension() {
return extension;
}
/**
 * @param extension the extension to set
 */
 public void setExtension(java.lang.String extension) {
this.extension = extension;
}
/**
 * @return the supprim
 */
public java.lang.Boolean getSupprim() {
return supprim;
}
/**
 * @param supprim the supprim to set
 */
public void setSupprim(java.lang.Boolean supprim) {
this.supprim = supprim;
}
/**
* @return the id_fichier
*/
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public int getId_fichier() {
return id_fichier;
}
/**
 * @param id_fichier the id_fichier to set
*/
 public void setId_fichier(int id_fichier) {
this.id_fichier = id_fichier;
}

public Fichier() {
super();
}

}

FileSystemElement.java

package com.bfi.webtop.model;

import javax.annotation.Generated;
import javax.persistence.metamodel.StaticMetamodel;

@Generated(value="Dali", date="2013-01-28T10:33:26.416+0100")
@StaticMetamodel(FileSystemElement.class)
public class FileSystemElement_ {
}

The other classes have the same structures When I try to do: jpa tooles> generate tables from entities I have the following mistakes

Exception in thread "main" javax.persistence.PersistenceException: Exception >[EclipseLink-28019] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Deployment of PersistenceUnit [webtop] failed. Close all factories for this PersistenceUnit. Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.IntegrityException

Descriptor Exceptions:

Exception [EclipseLink-34] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.DescriptorException Exception Description: This class does not define a public default constructor, or the constructor raised an exception. Internal Exception: java.lang.InstantiationException Descriptor: RelationalDescriptor(com.bfi.webtop.model.Application --> [DatabaseTable(application_)])

Exception [EclipseLink-34] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.DescriptorException Exception Description: This class does not define a public default constructor, or the constructor raised an exception. Internal Exception: java.lang.InstantiationException Descriptor: RelationalDescriptor(com.bfi.webtop.model.Fichier --> [DatabaseTable(FICHIER)])

Exception [EclipseLink-34] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.DescriptorException Exception Description: This class does not define a public default constructor, or the constructor raised an exception. Internal Exception: java.lang.InstantiationException Descriptor: RelationalDescriptor(com.bfi.webtop.model.Raccourci --> [DatabaseTable(RACCOURCI)])

Runtime Exceptions:

at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createDeployFailedPersistenceException(EntityManagerSetupImpl.java:616)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:596)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:186)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:278)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:304)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:282)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.perform(Main.java:85)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:76)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:63)
Caused by: Exception [EclipseLink-28019] (Eclipse Persistence Services -       2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.EntityManagerSetupException

Exception Description: Deployment of PersistenceUnit [webtop] failed. Close all factories for this PersistenceUnit. Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.IntegrityException

I am using Eclipse Juno Any help please?

}

3
  • Why do you have the default no arg Application constructor commented out? The errors state EclipseLink cannot initiate new instances of your classes so it is likely related.
    – Chris
    Jan 28, 2013 at 13:20
  • Where is the FileSystemElement interface? I see only a FileSystemElement_ class. Jan 28, 2013 at 13:44
  • And why are Application and Fichier classes abstract? Jan 28, 2013 at 13:51

3 Answers 3

8

You've defined your class Fichier as abstract:

public abstract class Fichier

Remove abstract and it'll work. The error message in this case is somewhat confusing.

0

As the error states, you need to provide a default (no argument) constructor for you Application class.

The constructor can be private if you do not want to expose it to your app.

2
  • 2
    That didn't change anything James Jan 28, 2013 at 18:47
  • 1
    The constructor should NOT be private, as it breaks with the JPA2 specification, which states: The entity class must have a no-arg constructor. The entity class may have other constructors as well. The no-arg constructor must be public or protected
    – Tobb
    Nov 6, 2013 at 8:02
0

Consider create no-arg constructor in your class, then clean you project and try. I had the same problem and using lombok I fixed it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.