I have the next problem:
I am doing a project using JPA and Restfull whit netbeasn and postgres, I have the following persistence
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="PruebaPersitenciaPU" transaction-type="JTA">
<jta-data-source>data_cotratacion</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
And also the following code using the EntityManager:
#GET
public String crearPersona(
#QueryParam("id") String id,
#QueryParam("name") String name,
#QueryParam("gender") String gender,
#QueryParam("date") String date){
Persona p = new Persona();
p.setId(id);
p.setName(name);
p.setGender(gender);
p.setDate(stringToDate(date));
try {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("PruebaPersitenciaPU");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(p);
em.getTransaction().commit();
return "Usuario Creado "+id;
} catch (Exception e) {
return "Usuario no creado error: "+e;
}
}
but try this sends me this error:
Usuario no creado error: javax.persistence.PersistenceException: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException Exception Description: Cannot acquire data source [data_cotratacion]. Internal Exception: javax.naming.NamingException: Lookup failed for 'data_cotratacion' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: data_cotratacion not found]
Sounds like there is no JDBC datasource configured with the name data_cotratacion. You need to configure this JDBC resource on your application server.
Or you need to create your persistence unit by using the wizard in netbeans go in the menu to File > New File Then select Persistence in the left box and Persistence Unit in the right box.
Related
I'm running into a weird issue that hasn't been reported by others from what I could tell, there may be a bug when using createNativeQuery. I have tried so many things to understand why to no avail.
Current Environment:
EclipseLink 2.7.3 JPA provider
PostgreSQL 10.6.1 Database
Eclipse Photon IDE
JRE 1.8.0_121
When executing:
Long total = (Long) em.createNativeQuery("Project.count").getSingleResult();
It's throwing the following:
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.3.v20180807-4be1041): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: syntax error at or near "Project"
Position: 1
Error Code: 0
Call: Project.count
Query: DataReadQuery(sql="Project.count")
at org.eclipse.persistence.internal.jpa.QueryImpl.getDetailedException(QueryImpl.java:391)
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:264)
at org.eclipse.persistence.internal.jpa.QueryImpl.getSingleResult(QueryImpl.java:530)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:404)
at com.bbandt.util.testers.ProjectTester.ProjectVersionMapping(ProjectTester.java:43)
at com.bbandt.util.testers.ProjectTester.main(ProjectTester.java:21)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.3.v20180807-4be1041): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: syntax error at or near "Project"
Position: 1
Error Code: 0
Call: Project.count
Query: DataReadQuery(sql="Project.count")
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:342)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:691)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:567)
at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2096)
at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:603)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:275)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:261)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:332)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelect(DatasourceCallQueryMechanism.java:314)
at org.eclipse.persistence.queries.DataReadQuery.executeNonCursor(DataReadQuery.java:199)
at org.eclipse.persistence.queries.DataReadQuery.executeDatabaseQuery(DataReadQuery.java:154)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:914)
at org.eclipse.persistence.queries.DataReadQuery.execute(DataReadQuery.java:139)
at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:813)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2981)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1895)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1877)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1842)
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:262)
... 4 more
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "Project"
Position: 1
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143)
at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:106)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:1015)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:651)
... 21 more
Persistence.xml (truncated purposely )
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="LocalPostgreSQL" transaction-type="RESOURCE_LOCAL">
<mapping-file>META-INF/orm.xml</mapping-file>
<mapping-file>META-INF/Queries.xml</mapping-file>
<!-- <mapping-file>META-INF/ResultsetMappings.xml</mapping-file>
-->
<class>com.bbandt.jpa.converters.UUIDAttributeConverter</class>
<class>model.Component</class>
<class>model.ComponentVulnerability</class>
<class>model.ComponentVulnerabilityPK</class>
<class>model.Project</class>
<class>model.ProjectVersion</class>
<class>model.ProjectVersionPK</class>
ORM.xml contents:
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd">
<named-native-query name="Project.count">
<query>Select count(*) as total from public.project</query>
</named-native-query>
</entity-mappings>
From what I could tell, the named native query is not getting resolved back to the actual SQL contents.
Executing this works (and it resolves the named-native-query name "Project.count"):
Long total = (Long) em.createNamedQuery("Project.count").getSingleResult();
This also works:
Long total = (Long) em.createNativeQuery("Select count(*) from project").getSingleResult();
I didn't want to resort to JPQL for other reasons unimportant to this thread and I also need to implement SQL Resultset Mappings.
Any insight on this would be greatly appreciated. I truly ran out of ideas.
createNamedQuery: Used to define queries wthe ith name in mapping file or annotation
createNativeQuery: Used to execute native/pure SQL queries
Since you use createNativeQuery method with a named query you are getting above error
My following code is working on my Windows, but does not working on my Linux Mint. A added all libraries that are relevant.
I get this exception for the createEntityManagerFactory row:
javax.persistence.PersistenceException: Explicit persistence provider error(s) occurred for "JPA_probaPU" after trying the following discovered implementations: org.eclipse.persistence.jpa.PersistenceProvider from provider: org.eclipse.persistence.jpa.PersistenceProvider
My java file:
package jpa_proba;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.eclipse.persistence.exceptions.EntityManagerSetupException;
public class JPA_proba {
public static void main(String[] args) {
try{
EntityManagerFactory emf = Persistence.createEntityManagerFactory("JPA_probaPU");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
//Integer id, String isbn, String szerzo, String cim, String mufaj, int ar, int elerheto
Konyv k = new Konyv(null, "654654444444", "Kiss Béla", "Hogyan ne csináljunk semmit?", "dráma", 500, 1);
em.persist(k);
em.getTransaction().commit();
}
catch(Exception ex){
System.out.println(ex);
}
}
}
My persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="JPA_probaPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>jpa_proba.Konyv</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/helix1?zeroDateTimeBehavior=convertToNull"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.password" value="123456"/>
</properties>
</persistence-unit>
</persistence>
Errors:
Exception in thread "main" javax.persistence.PersistenceException: Explicit persistence provider error(s) occurred for "JPA_probaPU" after trying the following discovered implementations: org.eclipse.persistence.jpa.PersistenceProvider from provider: org.eclipse.persistence.jpa.PersistenceProvider
at javax.persistence.Persistence.createPersistenceException(Persistence.java:244)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:186)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:72)
at jpa_proba.JPA_proba.main(JPA_proba.java:13)
Caused by: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoad er#5caf905d
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [JPA_probaPU] failed.
Internal Exception: java.lang.IncompatibleClassChangeError: Implementing class
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:152)
You are getting Internal Exception: java.lang.IncompatibleClassChangeError: Implementing class.
This might occur when you have more than one version of same class/jar.
I am creating an app for school that generates business rules.
The front end consists of Apex and the backend is a java application that uses hibernate to access the database.
To communicate between Apex and Java I am using a rest service (using struts2).
This works fine when I deploy the application in my IDE (netbeans). But then it runs on my localhost. This way the Apex application can not connect to it. (The Apex application is hosted by my school)
So I tried deploying my application using various websites. The rest service part still works and I can connect the java app with my Apex application.
The problem is that the java application cant seem to connect to the database as soon as i deploy it online.
The glassfish console shows this when I try to get data from the database:
(Tosad is the name of the project/course)
[2016-01-08T15:23:07.004+0000] [glassfish 4.1] [INFO] [] []
[tid: _ThreadID=43 _ThreadName=Thread-8] [timeMillis: 1452266587004] [levelValue: 800] [[
[EL Severe]: ejb: 2016-01-08 15:23:07.004--ServerSession(1585495182)--
Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd):
org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [TOSAD].
Internal Exception: javax.naming.NamingException: Lookup failed for 'TOSAD' in SerialContext[
myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,
java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl,
java.naming.factory.url.pkgs=com.sun.enterprise.naming}
[Root exception is javax.naming.NameNotFoundException: TOSAD not found]]]
Hibernate.cfg.xml (I replaced some info for safety purposes)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:#ondora02.hu.nl:PORT:COURSE</property>
<property name="hibernate.connection.username">USERNAME</property>
<property name="hibernate.connection.password">PASSWORD</property>
</session-factory>
</hibernate-configuration>
HibernateUtil.java
package Service;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
public class HibernateUtil {
private static String orclcfg = "nl.hu.ict.jpa.oracle";
private static String mysqlcfg = "nl.hu.ict.jpa.mysql";
private static boolean mysql = false;
private static String dbcfg = orclcfg;
private static final EntityManagerFactory entityManagerFactory;
//entityManagerFactory = Persistence.createEntityManagerFactory("nl.hu.ict.jpa.oracle" );
static {
try {
if (!mysql) {
dbcfg = orclcfg;
}
entityManagerFactory = Persistence.createEntityManagerFactory(dbcfg);
} catch (Throwable th) {
System.err.println("Initial EntityManagerFactory creation failed" + th);
throw new ExceptionInInitializerError(th);
}
}
public static EntityManagerFactory getEntityManagerFactory() {
return entityManagerFactory;
}
}
The error message is somewhat clear. The JNDI resource named TOSAD cannot be located on your remote deployed server. Make sure it is configured on the remote server like you likely have done on your local machine.
I am setting up a new project using Tomcat, Weld (for CDI) and DeltaSpike (Data, JPA and JSF modules)
I have reached the point now where I am trying to create a JPA repository (backed by Hibernate) by following the directions in the DeltaSpike documentation (http://deltaspike.apache.org/documentation/data.html).
I am struggling to hook up the persistence unit in the way the documentation describes as my EntityManagerFactory object is always null
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
public class EntityManagerProducer {
#PersistenceUnit(unitName = "srdPersistenceUnit")
private EntityManagerFactory emf;
#Produces // you can also make this #RequestScoped
public EntityManager create() {
return emf.createEntityManager();
}
public void close(#Disposes EntityManager em) {
if (em.isOpen()) {
em.close();
}
}
}
I have created a persistence.xml file which is in the /META-INF/ directory of the jar file that contains my service/data layer
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="srdPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<non-jta-data-source>java:comp/env/jdbc/srdDCP</non-jta-data-source>
<properties>
</properties>
</persistence-unit>
</persistence>
I was previously using Spring to handle dependency injection and the JPA stuff which worked fine so I know my data source is set up correctly as a Tomcat JNDI resource.
Now however I see this exception (suggesting that the EntityManagerFactory is not being injected)
Caused by: java.lang.NullPointerException
at testproj.data.entity.EntityManagerProducer.create(EntityManagerProducer.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:88)
at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:78)
at org.jboss.weld.injection.producer.ProducerMethodProducer.produce(ProducerMethodProducer.java:95)
at org.jboss.weld.injection.producer.AbstractMemberProducer.produce(AbstractMemberProducer.java:167)
at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:183)
at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:69)
at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:101)
at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:761)
at org.jboss.weld.bean.builtin.InstanceImpl.getBeanInstance(InstanceImpl.java:179)
at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:99)
at org.apache.deltaspike.data.impl.handler.EntityManagerLookup.lookupFor(EntityManagerLookup.java:58)
at org.apache.deltaspike.data.impl.handler.QueryHandler.createContext(QueryHandler.java:104)
at org.apache.deltaspike.data.impl.handler.QueryHandler.invoke(QueryHandler.java:77)
I suspect I have missed something in the setting up of the persistence unit.
What more do I need to do to create a valid persistence unit backed by hibernate jpa linked to my datasource?
i ve a huge problem with intellij 13.0.1. I set up a JPA Project for the first time in intellij 13 and need some help to get some rid of an strange error.
Caused by: Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error. Class [] not found.
I added a persistence Unit and add the datasource, if i test the connection it is successfull. I also added eclipselink in version 2.5.1 and postgres.jdbc.driver in 9.3-1100. I also installed Postgres # latest build. I get the error if i want to create an Entitymanager. Any idea what i could do to get rid of this error?
src:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("RoomDB");
EntityManager em = emf.createEntityManager(); //<- Configuration Error
em.getTransaction().begin();
User user1 = new User();
user1.setUsername("testuser");
user1.setPassword("testuser");
em.persist(user1);
Room room1 = new Room();
room1.setRoom_nr(12);
em.persist(room1);
em.getTransaction().commit();
em.close();
Stack-Trace:
[EL Info]: transaction: 2013-12-30 23:16:13.05--ServerSession(20030435)--property eclipselink.jdbc.user is deprecated, property javax.persistence.jdbc.user should be used instead.
[EL Info]: transaction: 2013-12-30 23:16:13.062--ServerSession(20030435)--property eclipselink.jdbc.driver is deprecated, property javax.persistence.jdbc.driver should be used instead.
[EL Info]: transaction: 2013-12-30 23:16:13.062--ServerSession(20030435)--property eclipselink.jdbc.url is deprecated, property javax.persistence.jdbc.url should be used instead.
[EL Info]: transaction: 2013-12-30 23:16:13.062--ServerSession(20030435)--property eclipselink.jdbc.password is deprecated, property javax.persistence.jdbc.password should be used instead.
[EL Info]: transaction: 2013-12-30 23:16:13.949--ServerSession(20030435)--property eclipselink.jdbc.user is deprecated, property javax.persistence.jdbc.user should be used instead.
[EL Info]: transaction: 2013-12-30 23:16:13.949--ServerSession(20030435)--property eclipselink.jdbc.driver is deprecated, property javax.persistence.jdbc.driver should be used instead.
[EL Info]: transaction: 2013-12-30 23:16:13.95--ServerSession(20030435)--property eclipselink.jdbc.url is deprecated, property javax.persistence.jdbc.url should be used instead.
[EL Info]: transaction: 2013-12-30 23:16:13.95--ServerSession(20030435)--property eclipselink.jdbc.password is deprecated, property javax.persistence.jdbc.password should be used instead.
[EL Info]: 2013-12-30 23:16:15.632--ServerSession(20030435)--EclipseLink, version: Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5
[EL Severe]: ejb: 2013-12-30 23:16:15.639--ServerSession(20030435)--Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error. Class [] not found.
Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error. Class [] not found.
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:766)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:182)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:527)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:140)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at de.Enviroment.main(Enviroment.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error. Class [] not found.
at org.eclipse.persistence.exceptions.DatabaseException.configurationErrorClassNotFound(DatabaseException.java:89)
at org.eclipse.persistence.sessions.DefaultConnector.loadDriverClass(DefaultConnector.java:267)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:85)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.setOrDetectDatasource(DatabaseSessionImpl.java:204)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:741)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:239)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:685)
... 13 more
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="RoomDB">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>de.Entity.Room</class>
<class>de.Entity.User</class>
<properties>
<property name="eclipselink.jdbc.url" value=""/>
<property name="eclipselink.jdbc.driver" value=""/>
<property name="eclipselink.jdbc.user" value=""/>
<property name="eclipselink.jdbc.password" value=""/>
</properties>
</persistence-unit>
</persistence>
<property name="eclipselink.jdbc.driver" value=""/>
I'd say that's your problem. You're explicitly specifying no driver. Omit it or use org.postgresql.Driver.