Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
JPA persistence.xml should integrate with @DataSourceDefinition and web.xml data-source definition #30
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:
The following persistence.xml should be valid:
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
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.