New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPA persistence.xml should integrate with @DataSourceDefinition and web.xml data-source definition #30

Open
glassfishrobot opened this Issue Sep 9, 2013 · 10 comments

Comments

Projects
None yet
3 participants
@glassfishrobot

glassfishrobot commented Sep 9, 2013

Datasources defined via @DataSourceDefinition allow @resource injection of DataSource objects into application code. However, these data-sources are not integrated with the persistence.xml JPA configuration file. And attempted use of the custom defined DataSource in persistence.xml will result in deployment failure. The EE spec allow for interop between these features:

For a datasource definition:

@DataSourceDefinition(
         url = "jdbc:h2:mem:",
         className = "org.h2.jdbcx.JdbcDataSource",
         name = "java:global/jdbc/h2db",
         user = "sa",
         password = "")

The following persistence.xml should be valid:

<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://www.oracle.com/webfolder/technetwork/jsc/xml/ns/persistence/persistence_2_1.xsd"> 
   <persistence-unit name="default" transaction-type="JTA">
      <jta-data-source>java:global/jdbc/h2db</jta-data-source>
      <exclude-unlisted-classes>false</exclude-unlisted-classes>
   </persistence-unit>

</persistence>

Environment

EE 6/7+

@glassfishrobot

This comment has been minimized.

Show comment
Hide comment
@glassfishrobot

glassfishrobot Sep 9, 2013

Reported by lincolnbaxter

glassfishrobot commented Sep 9, 2013

Reported by lincolnbaxter

@glassfishrobot

This comment has been minimized.

Show comment
Hide comment
@glassfishrobot

glassfishrobot Sep 9, 2013

reza_rahman said:
I think this is a bug unrelated to the spec. I have this use case working fine: https://java.net/projects/cargotracker/pages/Home.

glassfishrobot commented Sep 9, 2013

reza_rahman said:
I think this is a bug unrelated to the spec. I have this use case working fine: https://java.net/projects/cargotracker/pages/Home.

@glassfishrobot

This comment has been minimized.

Show comment
Hide comment
@glassfishrobot

glassfishrobot Sep 12, 2013

kithouna said:
This is definitely a bug with whatever server OP is using.

See http://henk53.wordpress.com/2012/06/30/the-state-of-datasourcedefinition-in-java-ee + http://henk53.wordpress.com/2012/04/15/jsf2-primefaces3-ejb3-jpa2-integration-project/#step10 and http://jdevelopment.nl/open-source/java-ee-kickoff-app for two other working cases.

If the server happens to be Glassfish, remember that due to a big bug in that you have to copy the JDBC driver to some installation directory of Glassfish itself. See GLASSFISH-19451

glassfishrobot commented Sep 12, 2013

kithouna said:
This is definitely a bug with whatever server OP is using.

See http://henk53.wordpress.com/2012/06/30/the-state-of-datasourcedefinition-in-java-ee + http://henk53.wordpress.com/2012/04/15/jsf2-primefaces3-ejb3-jpa2-integration-project/#step10 and http://jdevelopment.nl/open-source/java-ee-kickoff-app for two other working cases.

If the server happens to be Glassfish, remember that due to a big bug in that you have to copy the JDBC driver to some installation directory of Glassfish itself. See GLASSFISH-19451

@glassfishrobot

This comment has been minimized.

Show comment
Hide comment
@glassfishrobot

glassfishrobot Jan 8, 2014

arjan_t said:
There's is definitely something fishy here. Historically this has failed more often and if I'm not misinterpreting things some vendors at least gave (me) the impression that they thought this didn't needed to be supported.

For the current crop of Java EE 7 servers it again fails. See WildFly issue https://issues.jboss.org/browse/WFLY-2727 and GlassFish issue GLASSFISH-20944

I think the spec should explicitly say that @DataSourceDefinition and web.xml's data-source definition can be used in persistence.xml and add a TCK test that checks that this is indeed possible for a given implementation.

glassfishrobot commented Jan 8, 2014

arjan_t said:
There's is definitely something fishy here. Historically this has failed more often and if I'm not misinterpreting things some vendors at least gave (me) the impression that they thought this didn't needed to be supported.

For the current crop of Java EE 7 servers it again fails. See WildFly issue https://issues.jboss.org/browse/WFLY-2727 and GlassFish issue GLASSFISH-20944

I think the spec should explicitly say that @DataSourceDefinition and web.xml's data-source definition can be used in persistence.xml and add a TCK test that checks that this is indeed possible for a given implementation.

@glassfishrobot

This comment has been minimized.

Show comment
Hide comment
@glassfishrobot

glassfishrobot Jan 9, 2014

arjan_t said:
For the JPA side of this issue see JPA_SPEC-70

glassfishrobot commented Jan 9, 2014

arjan_t said:
For the JPA side of this issue see JPA_SPEC-70

@glassfishrobot

This comment has been minimized.

Show comment
Hide comment
@glassfishrobot

glassfishrobot Apr 10, 2014

lincolnbaxter said:
When speaking to the various people in charge of JPA integration in these servers, I got the overall impression that they did not believe the spec required this, which is why it does not work on most servers. Thus I moved to file a spec issue that would cause people to do the right thing

glassfishrobot commented Apr 10, 2014

lincolnbaxter said:
When speaking to the various people in charge of JPA integration in these servers, I got the overall impression that they did not believe the spec required this, which is why it does not work on most servers. Thus I moved to file a spec issue that would cause people to do the right thing

@glassfishrobot

This comment has been minimized.

Show comment
Hide comment
@glassfishrobot

glassfishrobot Apr 15, 2014

ldemichiel said:
The spec does require this. We'll make sure that this is clearer in the future, and add a TCK test for it.

glassfishrobot commented Apr 15, 2014

ldemichiel said:
The spec does require this. We'll make sure that this is clearer in the future, and add a TCK test for it.

@glassfishrobot

This comment has been minimized.

Show comment
Hide comment
@glassfishrobot

glassfishrobot Mar 13, 2016

arjan_t said:
@ldemichiel

We're now almost 2 years later and just wondering, has this TCK test already been added?

glassfishrobot commented Mar 13, 2016

arjan_t said:
@ldemichiel

We're now almost 2 years later and just wondering, has this TCK test already been added?

@glassfishrobot

This comment has been minimized.

Show comment
Hide comment
@glassfishrobot

glassfishrobot Apr 25, 2017

This issue was imported from java.net JIRA JAVAEE_SPEC-30

glassfishrobot commented Apr 25, 2017

This issue was imported from java.net JIRA JAVAEE_SPEC-30

@arjantijms

This comment has been minimized.

Show comment
Hide comment
@arjantijms

arjantijms Aug 13, 2018

Member

This time it's more than 2 years later. Maybe if/when the TCK gets transferred we'll finally be able to see if that TCK test was ever added or not.

Member

arjantijms commented Aug 13, 2018

This time it's more than 2 years later. Maybe if/when the TCK gets transferred we'll finally be able to see if that TCK test was ever added or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment