create-or-extend-tables with Eclipselink does not work - jpa

I am using Eclipselink 2.5.1 and I have the problem that no table update take place when I run Project->JPA Tools->Create tables form Entites... although I have
<property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
in my peristence.xml (with generation output mode = database).
I have an already existing database table addresses created from a JpaEntity Address.
After table creation I wanted to add a further column named addressType which is of type AddressType which is an enum.
In my JpaEntity Address Eclipse is grumbling that addressType column can not be found in table addresses.
Re-running table creation from entities does not what I want. The column will not be added to the existing table structure. what am I missing to do?
Running Project->JPA Tools->Create tables from Entities... gives the following output:
[EL Config]: metadata: The alias name for the entity class [class com.tsystems.ikt.service.jpaParking.model.Address] is being defaulted to: Address.
[EL Config]: metadata: The column name for element [region] is being defaulted to: REGION.
[EL Config]: metadata: The column name for element [street] is being defaulted to: STREET.
[EL Config]: metadata: The column name for element [zipCode] is being defaulted to: ZIPCODE.
[EL Config]: metadata: The column name for element [streetNumber] is being defaulted to: STREETNUMBER.
[EL Config]: metadata: The column name for element [addressType] is being defaulted to: ADDRESSTYPE.
[EL Config]: metadata: The column name for element [addressId] is being defaulted to: ADDRESSID.
[EL Config]: metadata: The column name for element [city] is being defaulted to: CITY.
[EL Config]: metadata: The column name for element [country] is being defaulted to: COUNTRY.
[EL Info]: EclipseLink, version: Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5
[EL Fine]: connection: Detected database platform: org.eclipse.persistence.platform.database.MySQLPlatform
[EL Fine]: sql: Connection(1483721814)--DROP TABLE addresses
[EL Fine]: sql: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails
Error Code: 1217
Call: DROP TABLE addresses
Query: DataModifyQuery(sql="DROP TABLE addresses")
[EL Fine]: sql: Connection(1483721814)--DROP TABLE entrances
[EL Fine]: sql: Connection(1483721814)--DROP TABLE addresses
[EL Fine]: sql: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails
Error Code: 1217
Call: DROP TABLE addresses
Query: DataModifyQuery(sql="DROP TABLE addresses")
[EL Fine]: sql: Connection(1483721814)--DROP TABLE addresses
[EL Fine]: sql: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails
Error Code: 1217
Call: DROP TABLE addresses
Query: DataModifyQuery(sql="DROP TABLE addresses")
[EL Fine]: sql: Connection(1483721814)--DROP TABLE addresses
[EL Fine]: sql: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails
Error Code: 1217
Call: DROP TABLE addresses
Query: DataModifyQuery(sql="DROP TABLE addresses")
[EL Fine]: sql: Connection(1483721814)--DROP TABLE addresses
[EL Fine]: sql: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails
Error Code: 1217
Call: DROP TABLE addresses
Query: DataModifyQuery(sql="DROP TABLE addresses")
[EL Fine]: sql: Connection(1483721814)--CREATE TABLE addresses (ADDRESSID INTEGER NOT NULL UNIQUE, ADDRESSTYPE VARCHAR(50), CITY VARCHAR(50) NOT NULL, COUNTRY VARCHAR(50) NOT NULL, REGION VARCHAR(50) NOT NULL, STREET VARCHAR(100) NOT NULL, STREETNUMBER VARCHAR(10) NOT NULL, ZIPCODE VARCHAR(15) NOT NULL, PRIMARY KEY (ADDRESSID))
[EL Fine]: sql: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'addresses' already exists
Error Code: 1050
Call: CREATE TABLE addresses (ADDRESSID INTEGER NOT NULL UNIQUE, ADDRESSTYPE VARCHAR(50), CITY VARCHAR(50) NOT NULL, COUNTRY VARCHAR(50) NOT NULL, REGION VARCHAR(50) NOT NULL, STREET VARCHAR(100) NOT NULL, STREETNUMBER VARCHAR(10) NOT NULL, ZIPCODE VARCHAR(15) NOT NULL, PRIMARY KEY (ADDRESSID))
Query: DataModifyQuery(sql="CREATE TABLE addresses (ADDRESSID INTEGER NOT NULL UNIQUE, ADDRESSTYPE VARCHAR(50), CITY VARCHAR(50) NOT NULL, COUNTRY VARCHAR(50) NOT NULL, REGION VARCHAR(50) NOT NULL, STREET VARCHAR(100) NOT NULL, STREETNUMBER VARCHAR(10) NOT NULL, ZIPCODE VARCHAR(15) NOT NULL, PRIMARY KEY (ADDRESSID))")
Why does Eclipselinkt try to drop and re-create the table addresses although I said create-or-extend-tables?

"eclipselink.ddl-generation" is an EclipseLink runtime property that is looked at when you deploy your peristence unit, but you are not running/deploying your persistence unit. Instead you are executing an Eclipse command to create tables from your entities. Eclipse uses EclipseLink under the covers, but will pass in its own properties to be sure your tables get created on the database it is pointed at. This the settings are described here:
https://www.eclipse.org/webtools/dali/docs/3.2/user_guide/tasks007.htm
If you want to have EclipseLink extend your tables, just run your app.

Related

When I am trying to connect to Oracle Database Through Spring Batch using Spring Datasource i am getting Error for metadata table

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? order by JOB_INSTANCE_ID desc]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
I guess you may need to edit you xml config file
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"
p:dataSource-ref="dataSource" p:transactionManager-ref="transactionManager"
p:tablePrefix="MYDB.BATCH_"/>
MYDB been your schema
Source

How do i create a dbo schema in the h2 sqlserver emulator?

I'm getting a
JdbcSQLException: Schema "dbo" not found;
SQL statement: create table "dbo"."TableName"
when running some boilerplate sql against the h2 sqlserver emulator (ie, with config settings:
db.default.slickdriver=com.typesafe.slick.driver.ms.SQLServerDriver
db.default.driver=net.sourceforge.jtds.jdbc.Driver
db.default.url="jdbc:h2:file:~/data/test1;MODE=MSSQLServer"
running the following:
Database.forDataSource(DB.getDataSource())
withSession {
I've tried creating the schema:
Database.forDataSource(DB.getDataSource())
withSession {
implicit session =>
Q.updateNA("CREATE SCHEMA \"dbo\" AUTHORIZATION sa;")
}
but that doesn't seem to do the trick (or report an error message). Am I missing something?
still unable to create the schema programatically. was able to easily create it via the h2 console, using the exact same query as above.
play.api.UnexpectedException: Unexpected exception[JdbcSQLException: Schema "dbo" not found; SQL statement:
create table "dbo"."TestTable" ("TestTableId" CHAR(36))
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:148) ~[play_2.10-2.2.3.jar:2.2.3]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:112) ~[play_2.10-2.2.3.jar:2.2.3]
at scala.Option.map(Option.scala:145) ~[scala-library-2.10.4.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112) ~[play_2.10-2.2.3.jar:2.2.3]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:110) ~[play_2.10-2.2.3.jar:2.2.3]
at scala.util.Success.flatMap(Try.scala:200) ~[scala-library-2.10.4.jar:na]
Caused by: org.h2.jdbc.JdbcSQLException: Schema "dbo" not found; SQL statement:
create table "dbo"."TestTable" ("TestTableId" CHAR(36))
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) ~[h2-1.3.172.jar:1.3.172]
at org.h2.message.DbException.get(DbException.java:169) ~[h2-1.3.172.jar:1.3.172]
at org.h2.message.DbException.get(DbException.java:146) ~[h2-1.3.172.jar:1.3.172]
at org.h2.command.Parser.getSchema(Parser.java:613) ~[h2-1.3.172.jar:1.3.172]
at org.h2.command.Parser.getSchema(Parser.java:620) ~[h2-1.3.172.jar:1.3.172]
at org.h2.command.Parser.parseCreateTable(Parser.java:5254) ~[h2-1.3.172.jar:1.3.172]
Please avoid database URLs of this form (jdbc:h2:file:data/test1) as this is relative to the current working directory (and the working directory can change). Use jdbc:h2:/absolute/path instead, or jdbc:h2:~/data (relative to the current user home directory).
If you use double quotes for create table "dbo"."TableName", then you also need to use double quotes for create schema:
create schema "dbo" authorization sa

Creating table form JPA Entity fails

I have set-up a completely new JPA Project in Eclipse (Kepler)...after I ran into issues in an existing project.
I intend to write a JpaEntity and let Eclipse (or JPA respectively) create the respective table in the database but this fails and I can't figure out the reason.
Eclipse tells me Table "myentrances" cannot be resolved. Of course...it doesn't exist by now. ...it shall be created yet.
Here's my JpaEntity:
#Entity
#Table(name="myentrances")
#NamedQuery(name="MyEntrance.findAll", query="SELECT e FROM MyEntrance e")
#TableGenerator(name = "myentrances")
#Access(PROPERTY)
public class MyEntrance implements Serializable {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private int entranceId;
#OneToOne(cascade = CascadeType.ALL, optional = false, fetch = FetchType.EAGER, orphanRemoval = true)
#PrimaryKeyJoinColumn
private Address address;
#Column(nullable=false)
private double maxHeight;
#Column(nullable=false)
private String maxHeightUom;
private static final long serialVersionUID = 1L;
public MyEntrance() {
super();
}
public int getEntranceId() {
return this.entranceId;
}
public void setEntranceId(int entranceId) {
this.entranceId = entranceId;
}
public Address getAddress() {
return this.address;
}
public void setAddress(Address address) {
this.address = address;
}
public double getMaxHeight() {
return this.maxHeight;
}
public void setMaxHeight(double maxHeight) {
this.maxHeight = maxHeight;
}
public String getMaxHeightUom() {
return this.maxHeightUom;
}
public void setMaxHeightUom(String maxHeightUom) {
this.maxHeightUom = maxHeightUom;
}
}
Here's 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="JpaTest" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.tsystems.ikt.model.Address</class>
<class>com.tsystems.ikt.model.MyEntrance</class>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/myDb"/>
<property name="javax.persistence.jdbc.user" value="root"/>
</properties>
</persistence-unit>
Here's the exception I get:
[EL Config]: metadata: The element [method getAddress] is being defaulted to a one to one mapping.
[EL Config]: metadata: The target entity (reference) class for the one to one mapping element [method getAddress] is being defaulted to: class com.tsystems.ikt.model.Address.
[EL Config]: metadata: The access type for the persistent class [class com.tsystems.ikt.model.Address] is set to [FIELD].
[EL Config]: metadata: The access type for the persistent class [class com.tsystems.ikt.model.MaiEntrance] is set to [FIELD].
[EL Config]: metadata: The alias name for the entity class [class com.tsystems.ikt.model.MyEntrance] is being defaulted to: MyEntrance.
[EL Config]: metadata: The column name for element [getEntranceId] is being defaulted to: ENTRANCEID.
[EL Config]: metadata: The column name for element [getMaxHeightUom] is being defaulted to: MAXHEIGHTUOM.
[EL Config]: metadata: The column name for element [getMaxHeight] is being defaulted to: MAXHEIGHT.
Exception in thread "main" Local Exception Stack:
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: org.eclipse.persistence.dynamic.DynamicClassLoader#580760d7
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 [JpaTest] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class com.tsystems.ikt.model.MyEntrance] has no primary key specified. It should define either an #Id, #EmbeddedId or an #IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
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:79)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.buildEntityManagerFactory(Main.java:94)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:80)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:68)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [JpaTest] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class com.tsystems.ikt.model.MyEntrance] has no primary key specified. It should define either an #Id, #EmbeddedId or an #IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1954)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1945)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:96)
... 5 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [JpaTest] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class com.tsystems.ikt.model.MyEntrance] has no primary key specified. It should define either an #Id, #EmbeddedId or an #IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:230)
... 9 more
Caused by: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class com.tsystems.ikt.model.MyEntrance] has no primary key specified. It should define either an #Id, #EmbeddedId or an #IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
at org.eclipse.persistence.exceptions.ValidationException.noPrimaryKeyAnnotationsFound(ValidationException.java:1422)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.validatePrimaryKey(EntityAccessor.java:1536)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processMappingAccessors(EntityAccessor.java:1243)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:697)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1793)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:576)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:585)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1869)
... 7 more
I am only using field access (in Address as well).
I am using Eclipselink 2.5.1.
By the way:
Isn't it possible to create a table for just a single newly created JpaEntity? Do I ever have to chose MyProject-->JPA Tools-->Generate TableS from EntitieS? This seems to create ALL existing tables as well, does it? What if I have already created a bunch of tables and now just want to add one further table based by a newly created JpaEntity?
The default access mode for entities in JPA is AccessType.FIELD.
You have overwritten it by declaring #Access(PROPERTY) for the entity therefore #Id annotation is unnoticed by the persistence provider while processing metadata. Try to remove #Access(PROPERTY) annotation to solve the problem.
What if I have already created a bunch of tables and now just want to
add one further table based by a newly created JpaEntity?
It depends from a scenario:
if dropping existing tables is forbidden for any reason (i.e. in case of legacy database): leave create-tables in persistence.xml so that the provider creates the table based on a new entity (i.e. MyEnterance); for already existing table you may use DROP TABLE myentrances later on to remove the corresponding table and recreate it automatically during the next start up - the provider will take care of recreating the entity from scratch
if dropping existing tables is allowed: replace create-tables with drop-and-create-tables in persistence.xml - the provider will take care of recreating the whole entity model from scratch

postgresql + jpa + persistence.xml

I have a problem to use PostgreSQL with JPA.
When i try to execute my app on glassfish i got this error:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: no schema has been selected to create in
Error Code: 0
Call: CREATE TABLE CABINET (ID INTEGER NOT NULL, PRIMARY KEY (ID))
Query: DataModifyQuery(sql="CREATE TABLE CABINET (ID INTEGER NOT NULL, PRIMARY KEY (ID))")
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:331)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:895)
So how can i specify the schema for JPA so it can be able to use postgresql
note: i have added the postgresql maven dependancy:
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
Please help me; Thank you
The schema is specified with the "search_path" variable in postgres.
To solve your problem, you have 2 solutions:
Permanently add the search to the user used by your connection:
ALTER user username set search_path=yourschema ;
Add temporarly the search_path in the jdbc connection (which i find ugly)
set search_path=yourschema;

Cannot acquire data source. Can't Use JPA EntityManager (EclipseLink) with JBoss 5.1

I'm facing a lot of difficulties to put the JPA (EclipseLink) working in the JBoss Server. I normally use Tomcat and it's quite simple...
I copied the mysql-ds.xml from /jboss-5.1.0.GA/docs/examples/jca to /jboss-5.1.0.GA/servers/default/deploy/ and then I configured it.
mysql-ds.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>EDeliveryUnit</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/edelivery_db</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>root</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<check-valid-connection-sql>SELECT * FROM systemuser</check-valid-connection-sql>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
Then I configured the persistence.xml in my WebApplication.
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="edeliveryPU"
transaction-type="RESOURCE_LOCAL">
<jta-data-source>jdbc/EDeliveryUnit</jta-data-source>
<non-jta-data-source>jdbc/EDeliveryUnit</non-jta-data-source>
<class>pt.inov.spocs.board.server.model.entity.SystemUser</class>
<class>pt.inov.spocs.board.server.model.entity.UserSession</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/edelivery_db" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="root" />
<property name="eclipselink.jdbc.batch-writing" value="JDBC" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
</properties>
</persistence-unit>
Finale I instantiate the EntityManager:
private EntityManagerFactory emf;
private EntityManager em;
public Controller() {
System.out.println("Begin..");
emf = Persistence.createEntityManagerFactory("edeliveryPU");
em = emf.createEntityManager();
user = em.find(SystemUser.class, new Long(1));
System.out.println("Username: " + user.getUsername() + " | pass: "
+ user.getPassword());
}
When I deploy it I got these error in my jboss:
2012-07-20 13:22:15,762 INFO [STDOUT] (http-127.0.0.1-8080-1) Begin..
2012-07-20 13:22:16,346 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The access type for the persistent class [class pt.inov.spocs.board.server.model.entity.UserSession] is set to [FIELD].
2012-07-20 13:22:16,414 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The target entity (reference) class for the many to one mapping element [field user] is being defaulted to: class pt.inov.spocs.board.server.model.entity.SystemUser.
2012-07-20 13:22:16,417 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The access type for the persistent class [class pt.inov.spocs.board.server.model.entity.SystemUser] is set to [FIELD].
2012-07-20 13:22:16,419 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The alias name for the entity class [class pt.inov.spocs.board.server.model.entity.UserSession] is being defaulted to: UserSession.
2012-07-20 13:22:16,424 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The table name for entity [class pt.inov.spocs.board.server.model.entity.UserSession] is being defaulted to: USERSESSION.
2012-07-20 13:22:16,468 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The column name for element [sessionKey] is being defaulted to: SESSIONKEY.
2012-07-20 13:22:16,470 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The column name for element [endDate] is being defaulted to: ENDDATE.
2012-07-20 13:22:16,472 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The column name for element [beginDate] is being defaulted to: BEGINDATE.
2012-07-20 13:22:16,472 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The column name for element [ip] is being defaulted to: IP.
2012-07-20 13:22:16,474 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The alias name for the entity class [class pt.inov.spocs.board.server.model.entity.SystemUser] is being defaulted to: SystemUser.
2012-07-20 13:22:16,475 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The table name for entity [class pt.inov.spocs.board.server.model.entity.SystemUser] is being defaulted to: SYSTEMUSER.
2012-07-20 13:22:16,476 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The column name for element [id] is being defaulted to: ID.
2012-07-20 13:22:16,477 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The column name for element [username] is being defaulted to: USERNAME.
2012-07-20 13:22:16,477 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The column name for element [password] is being defaulted to: PASSWORD.
2012-07-20 13:22:16,479 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The pk column value for the table generator named [SystemUserGenerator] defined on [class pt.inov.spocs.board.server.model.entity.SystemUser] from [class pt.inov.spocs.board.server.model.entity.SystemUser] is being defaulted to: SystemUserGenerator.
2012-07-20 13:22:16,526 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The primary key column name for the mapping element [field user] is being defaulted to: ID.
2012-07-20 13:22:16,526 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Config]: The foreign key column name for the mapping element [user] is being defaulted to: USER_ID.
2012-07-20 13:22:16,696 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Warning]: PersistenceUnitInfo edeliveryPU has transactionType RESOURCE_LOCAL and therefore jtaDataSource will be ignored
2012-07-20 13:22:16,700 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Info]: EclipseLink, version: Eclipse Persistence Services - 2.3.2.v20111125-r10461
2012-07-20 13:22:16,716 INFO [STDOUT] (http-127.0.0.1-8080-1) [EL Severe]: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [java:/EDeliveryUnit].
Internal Exception: javax.naming.InvalidNameException: Not a compound name: EDeliveryUnit
2012-07-20 13:22:16,717 SEVERE [org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage] (http-127.0.0.1-8080-1) Error Rendering View[/index.xhtml]
javax.el.ELException: /index.xhtml: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [java:/EDeliveryUnit].
Internal Exception: javax.naming.InvalidNameException: Not a compound name: EDeliveryUnit
at org.apache.myfaces.view.facelets.compiler.TextInstruction.write(TextInstruction.java:57)
at org.apache.myfaces.view.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:46)
at org.apache.myfaces.view.facelets.compiler.UILeaf.encodeAll(UILeaf.java:214)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:614)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1159)
at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:263)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:85)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:662)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [java:/EDeliveryUnit].
Internal Exception: javax.naming.InvalidNameException: Not a compound name: EDeliveryUnit
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:517)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:294)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:272)
at pt.inov.spocs.board.server.model.entity.Controller.<init>(Controller.java:19)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.myfaces.config.annotation.TomcatAnnotationLifecycleProvider.newInstance(TomcatAnnotationLifecycleProvider.java:49)
at org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:162)
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.createManagedBean(ManagedBeanResolver.java:303)
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.getValue(ManagedBeanResolver.java:266)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:142)
at org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:65)
at org.apache.myfaces.el.convert.VariableResolverToELResolver.getValue(VariableResolverToELResolver.java:96)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:142)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61)
at org.apache.el.parser.AstValue.getValue(AstValue.java:107)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.myfaces.view.facelets.el.ELText$ELTextVariable.writeText(ELText.java:213)
at org.apache.myfaces.view.facelets.el.ELText$ELTextComposite.writeText(ELText.java:125)
at org.apache.myfaces.view.facelets.compiler.TextInstruction.write(TextInstruction.java:48)
... 28 more
Caused by: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [java:/EDeliveryUnit].
Internal Exception: javax.naming.InvalidNameException: Not a compound name: EDeliveryUnit
at org.eclipse.persistence.exceptions.ValidationException.cannotAcquireDataSource(ValidationException.java:497)
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:584)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:206)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:488)
... 55 more
Caused by: javax.naming.InvalidNameException: Not a compound name: EDeliveryUnit
at javax.naming.CompoundName.addAll(CompoundName.java:445)
at org.jnp.interfaces.NamingContext.composeName(NamingContext.java:1077)
at org.jnp.interfaces.NamingContext.getAbsoluteName(NamingContext.java:1855)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:717)
at javax.naming.InitialContext.lookup(InitialContext.java:396)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:103)
... 59 more
2012-07-20 13:22:16,764 SEVERE [org.apache.myfaces.renderkit.ErrorPageWriter] (http-127.0.0.1-8080-1) An exception occurred
javax.faces.FacesException: javax.persistence.PersistenceException: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [java:/EDeliveryUnit].
Internal Exception: javax.naming.InvalidNameException: Not a compound name: EDeliveryUnit
at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.wrap(ExceptionHandlerImpl.java:241)
at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:156)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:258)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:662)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [java:/EDeliveryUnit].
Internal Exception: javax.naming.InvalidNameException: Not a compound name: EDeliveryUnit
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:517)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:294)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:272)
at pt.inov.spocs.board.server.model.entity.Controller.<init>(Controller.java:19)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.myfaces.config.annotation.TomcatAnnotationLifecycleProvider.newInstance(TomcatAnnotationLifecycleProvider.java:49)
at org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:162)
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.createManagedBean(ManagedBeanResolver.java:303)
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.getValue(ManagedBeanResolver.java:266)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:142)
at org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:65)
at org.apache.myfaces.el.convert.VariableResolverToELResolver.getValue(VariableResolverToELResolver.java:96)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:142)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61)
at org.apache.el.parser.AstValue.getValue(AstValue.java:107)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.myfaces.view.facelets.el.ELText$ELTextVariable.writeText(ELText.java:213)
at org.apache.myfaces.view.facelets.el.ELText$ELTextComposite.writeText(ELText.java:125)
at org.apache.myfaces.view.facelets.compiler.TextInstruction.write(TextInstruction.java:48)
at org.apache.myfaces.view.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:46)
at org.apache.myfaces.view.facelets.compiler.UILeaf.encodeAll(UILeaf.java:214)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:614)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1159)
at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:263)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:85)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)
... 21 more
Caused by: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [java:/EDeliveryUnit].
Internal Exception: javax.naming.InvalidNameException: Not a compound name: EDeliveryUnit
at org.eclipse.persistence.exceptions.ValidationException.cannotAcquireDataSource(ValidationException.java:497)
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:584)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:206)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:488)
... 55 more
Caused by: javax.naming.InvalidNameException: Not a compound name: EDeliveryUnit
at javax.naming.CompoundName.addAll(CompoundName.java:445)
at org.jnp.interfaces.NamingContext.composeName(NamingContext.java:1077)
at org.jnp.interfaces.NamingContext.getAbsoluteName(NamingContext.java:1855)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:717)
at javax.naming.InitialContext.lookup(InitialContext.java:396)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:103)
... 59 more
I tried in many different ways but I can't put these working.
Anyone can help me please?
I found the solution.
JBoss force us to define a non-jta-data-source if we don't want to use transactions or a jta-data-source if you want to use it..
Either way no matter if we want to use transactions, the problem is that most of the information provided advise us to specify these with a jdbc/JNDI-NAME when what we want to use is a java:/JNDI-NAME.
In conclusion, if you want to use a EclipseLink JPA with JBoss instead of Data-Source you need to ensure that you are specifying the:
transaction-type="RESOURCE_LOCAL"
<non-jta-data-source>java:/JNDI-NAME</non-jta-data-source> or <jta-data-source>java:/JNDI-NAME</jta-data-source>
Here is the correction of my persistence.xml:
<persistence-unit name="persistenceSamplePU" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:/EDeliveryUnit</non-jta-data-source>
<!-- Entities must be specified for EclipseLink weaving -->
<class>pt.inov.spocs.board.server.model.entity.SystemUser</class>
<class>pt.inov.spocs.board.server.model.entity.UserSession</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/edelivery_db" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="root" />
</properties>
</persistence-unit>
Thank you for your precious help #Chris.
You are specifying "javax.persistence.jdbc.x" properties which do not mix with datasources. You should specify the datasource to use, or the JDBC connection url etc but not both. Are you trying to use JTA? There is also a warning stating you are using transaction-type="resource-local" with a JTA datasource defined - you need to specify the "JTA" transaction type for the JTA datasource to be used, and the will be needed so it can hook into the JBoss transaction manager. Setting the target server might also be needed for the datasource lookup.
I know this might be old. I faced same issue with jdeveloper 12c and weblogic 12.x
I fixed this by omitting java: from datasource name at persistence.xml file as follows:
from:
java:/app/jdbc/data_source
to:
/app/jdbc/data_source