Deploy failure due to jta-data-source in persistence.xml

Hey All,

This is driving me insane. Every example, including the Sun tutorials (which don't work on my instance of Glassfish), list persistence.xml files like:

"<?xml version="1.0" encoding="UTF-8"?>

<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">

<persistence-unit name="persistence_sample">

<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider </provider>

<jta-data-source>jdbc/SamplesDB</jta-data-source>

<non-jta-data-source>jdbc/SamplesDB__nontx</non-jta-data-source>

</persistence-unit>

</persistence>"

I've tried every combination of <persistence...> tags, with namespace definitions, posted in examples on the internet, but my problem is, any time I deploy my ear with a "<jta-data-source>" tag specified, I receive the following failure from the App Server:

"Error loading deployment descriptors for module [pi-0] Line 26 Column 24 -- Deployment descriptor file META-INF/persistence.xml in archive [pi-ejb.jar]. cvc-complex-type.2.4.a: Invalid content was found starting with element 'jta-data-source'. One of '{"http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected.

at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:35 2)

at com.sun.enterprise.deployment.backend.AppDeployerBase.loadDescriptors(AppDeploy erBase.java:327)

at com.sun.enterprise.deployment.backend.AppDeployer.explodeArchive(AppDeployer.ja va:332)

at com.sun.enterprise.deployment.backend.AppDeployer.deploy(AppDeployer.java:182)

at com.sun.enterprise.deployment.backend.AppDeployer.doRequestFinish(AppDeployer.j ava:129)

at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:169)

at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPh ase.java:95)

at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeplo ymentService.java:871)

at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentSe rvice.java:266)

at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentSe rvice.java:739)

at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:174)

at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:210)

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'jta-data-source'. One of '{"http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected.

at com.sun.enterprise.deployment.io.DeploymentDescriptorFile.read(DeploymentDescri ptorFile.java:285)

at com.sun.enterprise.deployment.archivist.Archivist.readPersistenceDeploymentDesc riptor(Archivist.java:1718)

at com.sun.enterprise.deployment.archivist.EjbArchivist.readPersistenceDeploymentD escriptors(EjbArchivist.java:239)

at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Arc hivist.java:301)

at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:200)

at com.sun.enterprise.deployment.archivist.ApplicationArchivist.readModulesDescrip tors(ApplicationArchivist.java:308)

at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:31 6)

... 11 more"

Note that this only happens when I have a <jta-data-source> element in the persistence.xml file. When I comment out the jta-data-source, it deploys without problems (though it doesn't _do_ much). Here's my persistence-unit code:

...

<persistence-unit name="prodcontext" transaction-type="JTA">

<provider>org.hibernate.ejb.HibernatePersistence</provider>

<class>OneOfMyClasses</class>

<jta-data-source>jdbc/SamplesDB</jta-data-source>

</persistence-unit>

...

Please help.

Thank you,

Todd

[4351 byte] By [loopyzrta] at [2007-11-26 15:33:30]
# 1
Okay okay, my mistake (staring at this thing too long).The solution is, I confess I overlooked it, the jta-data-source node in the xml has to follow the exact order specified in the xsd. I was putting it below the class nodes, which is a no-no.
loopyzrta at 2007-7-8 21:50:39 > top of Java-index,Application & Integration Servers,Application Servers...