Injected Entity Manager not using correct persistence unit - java

I have a JAX-RS restful service which needs to access a MySQL database. I am trying to do this using CDI and a entity manager. However, when I publish the app, it appears that the incorrect persistence unit is being used (it's trying to connect on port 1527 instead of 3306).
The exception that is caught by the try/catch is:
javax.servlet.ServletException:
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504):
org.eclipse.persistence.exceptions.DatabaseException
Internal Exception:
java.sql.SQLException:
Error in allocating a connection. Cause: Connection could not be allocated because:
java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.
Error Code: 0
Here is the restful service:
#Path("/databases")
#Stateless
public class DatabaseResource {
#PersistenceUnit(unitName = "beta.example.services")
EntityManagerFactory entityManagerFactory;
#GET
#Produces(MediaType.APPLICATION_JSON)
public Response list() {
try {
EntityManager entityManager = entityManagerFactory.createEntityManager();
Connection connection = entityManager.unwrap(java.sql.Connection.class);
...
return Response.ok().build();
} catch (SchemaCrawlerException e) {
return Response.status(500).entity(e.getMessage()).build();
}
}
}
The persistence unit (located in src/META-INF):
<?xml version="1.0" encoding="UTF-8"?>
<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="beta.example.services">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/" />
<property name="javax.persistence.jdbc.user" value="test" />
<property name="javax.persistence.jdbc.password" value="test" />
</properties>
</persistence-unit>
</persistence>
Any help would be appreciated

Ok, a persistence unit can be configured in two modes : RESOURCE_LOCAL and JTA.
Ex:
<persistence-unit name="beta.example.services" transaction-type="JTA">
VS
<persistence-unit name="beta.example.services" transaction-type="RESOURCE_LOCAL">
JTA is the default value. Properties like "javax.persistence.jdbc.*" will only be read when using "RESOURCE_LOCAL". When using JTA, the transaction manager of glassfish will be used. That means in this case you must specify JNDI name like this :
<jta-data-source>youJNDIName</jta-data-source>
What I think might be happening is that you use the default "JTA" transaction-type, but since you dont specify any jta-datasource, it might try to use the glassfish default one (wich point to derby).
Persistence unit as RESOURCE_LOCAL or JTA?
http://openejb.apache.org/jpa-concepts.html
Looking at how you use the entity manager, setting transaction-type to RESOURCE_LOCAL seems to be the solution for you.

Related

Injecting EntityManager returns null after Jboss/Wildfly migration

My application is running perfectly fine in JBoss AS 5.1.0. My goal is to migrate it to Wildfly 10.
Below is my persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="ApplicationPersistenceUnit">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/MySQL_DS</jta-data-source>
<jar-file>application_db_interface.jar</jar-file>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="jboss.entity.manager.jndi.name" value="java:/ApplicationPersistenceUnit"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/ApplicationPersistenceUnitFactory"/>
</properties>
</persistence-unit>
</persistence>
Below is my transaction manager class;
public class TransactionManager implements TransactionManagerI {
#PersistenceContext(unitName="ApplicationPersistenceUnit")
private EntityManager em;
...
}
I also try to use lookup but it still returns null;
public Session getSession() throws DAOException {
..
em = (EntityManager) new InitialContext().lookup("java:/ApplicationPersistenceUnit");
..
}
Below is the project schema;
->application.ear
->application.ear/application.war
->application.ear/db.jar
->application.ear/db.jar/META-INF/persistence.xml
I looked into other solutions and try one by one but couldn't figure out mine yet. I can provide more info if you need.
UPDATE: I check JNDI view from wildfly admin console. I don't see ApplicationPersistenceUnit there. It looks like server doesn't bind my persistence.xml file. I am now trying to figure out this problem.

JavaEE + eclipseLink + TomEE gives java.sql.SQLSyntaxErrorException: user lacks privilege or object not found

I try to make a simple app using a rest service, eclipseLink and mysql.
I want to make this run on a TomEE server (apache-tomee-plume-1.7.4).
I deploy the app with eclipse.
The deployment seems to be ok
When I go to http://localhost:8080/eleve/ I'm getting :
javax.servlet.ServletException: Error processing webservice request
org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXRSFilter.java:98)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
java.io.IOException: Failed to invoke AbstractHTTPDestination
org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(CxfRsHttpListener.java:229)
org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXRSFilter.java:94)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
java.lang.RuntimeException: org.apache.cxf.interceptor.Fault:
Internal Exception: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: ELEVE
Error Code: -5501
Call: SELECT ID, ADRESSE, classe, date_naissance, NOM, PRENOM, SEXE FROM ELEVE
Query: ReadAllQuery(referenceClass=Eleve sql="SELECT ID, ADRESSE, classe, date_naissance, NOM, PRENOM, SEXE FROM ELEVE")
org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:116)
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:324)
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:240)
org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(CxfRsHttpListener.java:227)
org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXRSFilter.java:94)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Here is my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="notePU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.test.eleve.model.Eleve</class>
<properties>
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/notes_eleves" />
<!-- <property name="eclipselink.ddl-generation" value="drop-and-create-tables" /> -->
<property name="eclipselink.logging.level" value="INFO" />
</properties>
</persistence-unit>
</persistence>
I must be missing something but I can not find what.
I pushed my code here: gitlab
Thanks for your help
I finally managed to make it works on TomEE 1.7 and 7.
This is the changes I had to do:
Remove the database related properties from the persistence.xml
Replace non-jta-data-source tag by jta-data-source in persistence.xml
Put the mysql connector jar in my server /lib
In my server /conf/tomee.xml I have added myDatasource configuration as a resource.
Put #XmlRootElement(name = "eleve") over my Eleve entity (this seems to be only mandatory on TomEE <7)
At the end I think that my issue was that the datasource needs to be configure in the server conf in a EE context (datasource properties in persistence was just ignore I think, so it was like no one was declared) and the exception
user lacks privilege or object not found
was comming from the fact that:
If a DataSource is needed by the application and one is not declared,
TomEE will create one dynamically using default settings.
TomEE documentation
I'm not 100% sure of that explanation but at least the problem is solved, don't hesitate to put comments if I misunderstood something.
I have updated the gitlab project
Edit: Be aware that you can also configure the resource in a /WEB-INF/resources.xml file
Edit 2: If you are using Eclipse you can also face this issue if you wrongly configured your server location, it should be set to "use Tomcat installation (take control...)" and not "use workspace metadata"

Generating tables from entities

I am trying to generate tables from my entities in Eclipse Juno using Project right-click -> JPA Tools -> Generate Tables from Entities
I am using EclipseLink as JPA Provider
My app container is Glassfish 4
My database is the one embedded within glassfish, derby.
My application starts without errors and I am able to commit data to the database using a simple test bean (so I assume my connection pool and datasource are working as intended)
I am getting the following stack trace error when I try to generate the tables from entities:
[EL Info]: EclipseLink, version: Eclipsenter code heree Persistence Services - 2.4.0.v20120608-r11652
[EL Severe]: ejb: Local Exception Stack:
Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [jdbc/__planificateur].
Internal Exception: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at org.eclipse.persistence.exceptions.ValidationException.cannotAcquireDataSource(ValidationException.java:502)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:109)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:685)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:213)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:542)
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: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:103)
... 11 more
Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [jdbc/__planificateur].
Internal Exception: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:602)
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-7060] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [jdbc/__planificateur].
Internal Exception: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at org.eclipse.persistence.exceptions.ValidationException.cannotAcquireDataSource(ValidationException.java:502)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:109)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:685)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:213)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:542)
... 7 more
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:103)
... 11 more
Here is my persistence.xml
<?xml version="1.0" encoding="UTF-8" ?>
<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"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="planificateurepicerie" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/__planificateur</jta-data-source>
<class>com.whybe.pe.jpa.Ingredient</class>
<class>com.whybe.pe.jpa.Recette</class>
<class>com.whybe.pe.jpa.ComposantRecette</class>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.logging.level" value="FINE"/>
</properties>
</persistence-unit>
</persistence>
I also have the database setup in the Database Development perspective and that works fine too.
Inside the glassfish console I can ping the connection pool successfully.
I am running out of ideas as of why the ddl won't generate...
If you need more details let me know!
Thanks in advance!
You are using transaction-type="JTA" in a run mode as standalone application. JPA looking for the JNDI resource name in the default context (Wait, currently there is no context in your application, since is a run mode standalone application). Change to transaction-type="LOCAL" for that run mode. e.g.:
<?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="SamplePU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/sample"/>
<property name="javax.persistence.jdbc.password" value="123"/>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="eclipselink.logging.level" value="ALL"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
</properties>
</persistence-unit>
</persistence>
But you are using Glassfish 4. Run the application on the server. If you don't have the JDNI resource name, you need to add it in the JDBC resources. The more easy way is using the console administration of Glassfish. By default, you can find it in http://localhost:4848. See more about this in Chapter 3 JDBC Resources.

handle EntityManager dynamically with multiples persistences units

I have a database with multiples schemas so I have a persistence.xml file with multiples <persistence-unit /> (named 01, 02, ...).
Problematic :
I want to create an EntityManager dynamically function of some user criteria.
I have tested 2 cases.
First case : basically, I tested this code (inside stateless EJB) :
String criteria = "01";
EntityManagerFactory emf = Persistence.createEntityManagerFactory(criteria);
EntityManager em = emf.createEntityManager();
Joueur joueur = new Joueur(); // Joueur is an Entity
joueur.setPseudo("olivier");
em.persist(joueur);
but I received exception :
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERREUR: la transaction est annulée, les commandes sont ignorées jusqu'à la fin du bloc
de la transaction
I thought, (with help of some Stackoverflow posts), that my EntityManager wasn't "linked" to my transaction context due to the fact it wasn't injected by container.
Second case : thus, I used injection :
#PersistenceContext(unitName="00")
private EntityManager em00;
#PersistenceContext(unitName="01")
private EntityManager em01;
Code in my function :
String criteria = "01";
EntityManager em = getEm(criteria);
...
and getEm() method :
private EntityManager getEm(String criteria){
if (criteria == "00")
return em00;
else if (criteria == "01")
return em01;
return null;
}
No problem, it's work but I have to inject as many EntityManagers that I have persistence-unit.
What will be the cost if I have 50 schemas...?
Is there a way to really manage entities managers dynamically ? (1 EntityManger only)
If I have to create 1 EntityManager per schema even if I don't use it, how can I improve my code to consume the least amount of resources possible ?
Thank you for advices and feedbacks
EDIT :
My configurations files :
Persistence.xml :
<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="00" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/sim/00</jta-data-source>
<mapping-file>orm_00_beta.xml</mapping-file>
<class>com.sim.entities.Joueur</class>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables" />
</properties>
</persistence-unit>
<persistence-unit name="01" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/sim/01</jta-data-source>
<mapping-file>orm_01_beta2.xml</mapping-file>
<class>com.sim.entities.Joueur</class>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables" />
</properties>
</persistence-unit>
</persistence>
orm_00_beta.xml :
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<persistence-unit-defaults>
<schema>beta</schema>
</persistence-unit-defaults>
</persistence-unit-metadata>
orm_01_beta2.xml :
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<persistence-unit-defaults>
<schema>beta2</schema>
</persistence-unit-defaults>
</persistence-unit-metadata>
You need to set the "eclipselink.target-server" to the application server you are using when using application managed persistence units (some servers set this automatically then using container managed persistence units). Then the EntityManager will bind with the JTA transaction that is active when it is created. If you create the EntityManager before the start of the JTA transaction then you can use joinTransaction().
If you still have issues, include the server you are using, and the full exception stack trace.
If you have a lot of schemas, you could consider using EclipseLink multi-tenant support, which allows each tenant to have their own schema.
http://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/a_multitenant.htm#BABEGBIJ
Usually you don't have 50 schemas. I would not worry about the cost of injections, as usually EJB container has a pool of already opened connections which are ready to be injected. So the overhead is really small.
AFAIK, JPA does not allow dynamic entity managers.
If you care about resources, I would suggest to avoid using EclipseLink (I had really bad experience with EclipseLink + EJBs)
To optimize things a bit I would try to use factory pattern here. Create a Bean which will serve you EntityManagers. Instead of injecting several PersistenceContext you will have one injection with a method like:
EntityManager getEntityManager(String schemaId) {...}
Another option is to move all injections to an AbstractBean. All other beans inherit from the AbstractBean.

Entity manager error on the server?

Hi I have developed my java application on glassfish server with EJB 3.0 persistance. On my local machine the application was running fine and was persisting the data perfectly. However, When I deployed it on the linux server, whenever I persist any data it gives me this EJB exception error:
Caused by: Java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManagerFactory.
And here is my persistence.xml file:
<?xml version="1.0" encoding="UTF-8" ?>
<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="MyPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/security</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables" />
</properties>
</persistence-unit>
</persistence>
what could possbily cause this?
PS: Im using Glassfish 3.1.43, EJB 3.0
What database are you using? I would verify that the user you have configured in the connection pool has the privilege to create tables.
I have managed to solve it finally!! The problem was in the database connection that was not set properly!! Now I have connected to the database and the data are persisted!!

Categories