2014-09-19 2 views
0

Я продолжаю получать эту ошибку при вызове hentMeldinger();Не удалось выполнить установку PersistenceUnit [...]. Закройте все заводы для этого PersistenceUnit

public class Kontroll { 
    private EntityManagerFactory emf; 

    Kontroll() { 
     emf = Persistence.createEntityManagerFactory("meldingsTing"); 
    } 

    public List<Melding> hentMeldinger() { 
     EntityManager em = emf.createEntityManager(); 

     TypedQuery<Melding> query = em.createQuery("SELECT o FROM Melding o", 
     Melding.class);// FIKS 
     List<Melding> meldinger = query.getResultList(); 

     em.close(); 

     return meldinger; 
    } 
} 

за исключением отчета:

message Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException 

description The server encountered an internal error that prevented it from fulfilling this request. 

exception 

javax.persistence.PersistenceException: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException 
Exception Description: Deployment of PersistenceUnit [meldingsTing] failed. Close all factories for this PersistenceUnit. 
Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.IntegrityException 
Descriptor Exceptions: 
--------------------------------------------------------- 

Exception [EclipseLink-63] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DescriptorException 
Exception Description: The instance creation method [no.hib.dat104.oblig1.Melding.<Default Constructor>], with no parameters, does not exist, or is not accessible. 
Internal Exception: java.lang.NoSuchMethodException: no.hib.dat104.oblig1.Melding.<init>() 
Descriptor: RelationalDescriptor(no.hib.dat104.oblig1.Melding --> [DatabaseTable(MELDING)]) 

Runtime Exceptions: 
--------------------------------------------------------- 

    org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createDeployFailedPersistenceException(EntityManagerSetupImpl.java:820) 
    org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:760) 
    org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204) 
    org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:304) 
    org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:336) 
    org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:302) 
    no.hib.dat104.oblig1.Kontroll.lagreMelding(Kontroll.java:32) 
    no.hib.dat104.oblig1.MeldingServlet.doPost(MeldingServlet.java:83) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:646) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 

Первопричины:

Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException 
Exception Description: Deployment of PersistenceUnit [meldingsTing] failed. Close all factories for this PersistenceUnit. 
Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.IntegrityException 
Descriptor Exceptions: 
--------------------------------------------------------- 

Exception [EclipseLink-63] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DescriptorException 
Exception Description: The instance creation method [no.hib.dat104.oblig1.Melding.<Default Constructor>], with no parameters, does not exist, or is not accessible. 
Internal Exception: java.lang.NoSuchMethodException: no.hib.dat104.oblig1.Melding.<init>() 
Descriptor: RelationalDescriptor(no.hib.dat104.oblig1.Melding --> [DatabaseTable(MELDING)]) 

Runtime Exceptions: 
--------------------------------------------------------- 

    org.eclipse.persistence.exceptions.EntityManagerSetupException.deployFailed(EntityManagerSetupException.java:238) 
    org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createDeployFailedPersistenceException(EntityManagerSetupImpl.java:820) 
    org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:760) 
    org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204) 
    org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:304) 
    org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:336) 
    org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:302) 
    no.hib.dat104.oblig1.Kontroll.lagreMelding(Kontroll.java:32) 
    no.hib.dat104.oblig1.MeldingServlet.doPost(MeldingServlet.java:83) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:646) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
root cause 

Exception [EclipseLink-0] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.IntegrityException 
Descriptor Exceptions: 
--------------------------------------------------------- 

Exception [EclipseLink-63] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DescriptorException 
Exception Description: The instance creation method [no.hib.dat104.oblig1.Melding.<Default Constructor>], with no parameters, does not exist, or is not accessible. 
Internal Exception: java.lang.NoSuchMethodException: no.hib.dat104.oblig1.Melding.<init>() 
Descriptor: RelationalDescriptor(no.hib.dat104.oblig1.Melding --> [DatabaseTable(MELDING)]) 

Runtime Exceptions: 
--------------------------------------------------------- 

    org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:696) 
    org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:632) 
    org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:568) 
    org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:799) 
    org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:743) 
    org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:239) 
    org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:685) 
    org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204) 
    org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:304) 
    org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:336) 
    org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:302) 
    no.hib.dat104.oblig1.Kontroll.lagreMelding(Kontroll.java:32) 
    no.hib.dat104.oblig1.MeldingServlet.doPost(MeldingServlet.java:83) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:646) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 

Моя проблема заключается в том, что я понятия не имею, где начать, глядя на этого отчета об ошибке. Я пробовал пару часов, но мне это не имеет смысла. Было бы здорово, если бы кто-нибудь мог понять и объяснить, но решить проблему было бы лучше.

ответ

3
Exception Description: The instance creation method [no.hib.dat104.oblig1.Melding.<Default Constructor>], with no parameters, does not exist, or is not accessible. 

Для JPA лица, по крайней мере, должен включать в себя default constructor (no-arg constructor),

public Melding() { 
} 
Смежные вопросы