Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-4096

Datasource Defined in web.xml Does Not Work with JPA Entity Manager

XMLWordPrintable

      The datasource defined in web.xml:

      <data-source>
      <name>java:/datasources/test</name>
      <class-name>org.apache.derby.jdbc.ClientDataSource</class-name>
      <database-name>test</database-name>
      <url>jdbc:derby://localhost:1527/test</url>
      <user>test</user>
      <password>test</password>
      </data-source>

      The persistence unit:

      <persistence-unit name="wtpu" transaction-type="JTA">
      <jta-data-source>java:/datasources/test</jta-data-source>
      </persistence-unit>

      The deployment error:

      17:57:10,813 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015876: Starting deployment of "WebTest.war" (runtime-name: "WebTest.war")
      17:57:11,078 INFO [org.jboss.as.jpa] (MSC service thread 1-2) JBAS011401: Read persistence.xml for wtpu
      17:57:11,172 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "WebTest.war")]) - failure description: ("JBAS014771: Services with missing/unavailable dependencies" => "jboss.persistenceunit.\"WebTest.war#wtpu\".__FIRST_PHASE__ is missing [jboss.naming.context.java.datasources.test]")
      17:57:11,187 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018559: Deployed "WebTest.war" (runtime-name : "WebTest.war")
      17:57:11,187 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 1) JBAS014774: Service status report
      JBAS014775: New missing/unsatisfied dependencies:
      service jboss.naming.context.java.datasources.test (missing) dependents: service jboss.persistenceunit."WebTest.war#wtpu".__FIRST_PHASE__

      If I remove the persistence unit, the datasource can be successfully bound:

      17:55:47,851 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:/datasources/test]

      The same code works as expected in GlassFish 4.1, and the @DataSourceDefinition annotation has the same issue.

              smarlow1@redhat.com Scott Marlow
              shinzey shinzey shinzey (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: