Search code examples
postgresqljbosswildflydatasourcebenchmarking

Wildfly deploy fail for missing datasource


I'm trying to deploy the SPECjEnterprise®2018 Web Profile to benchmark WildFly. The benchmark documentation doesn't specify any deploy instruction, saying it's beyond the scope of the documentation.

I tried to deploy a .war file but i get the following error:

00:39:12,410 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "insurance.war")]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.jdbc.SPECjInsuranceDS"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "jboss.persistenceunit.\"insurance.war#InsuranceAudit\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jdbc.SPECjInsuranceDS]",
        "jboss.persistenceunit.\"insurance.war#InsuranceAudit\" is missing [jboss.naming.context.java.jdbc.SPECjInsuranceDS]",
        "jboss.persistenceunit.\"insurance.war#Insurance\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jdbc.SPECjInsuranceDS]",
        "jboss.persistenceunit.\"insurance.war#Insurance\" is missing [jboss.naming.context.java.jdbc.SPECjInsuranceDS]"
    ]
}

This is the persistence.xml of the .war i'm trying to deploy:

<?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="Insurance">
       <jta-data-source>jdbc/SPECjInsuranceDS</jta-data-source>
       <class>org.spec.jent.common.Address</class>
       <class>org.spec.jent.common.insurance.entity.PolicyCoverage</class>
       <class>org.spec.jent.common.insurance.entity.PolicyHolder</class>
       <class>org.spec.jent.common.SPECjWebTarget</class>
       <class>org.spec.jent.common.insurance.entity.Vehicle</class>
       <class>org.spec.jent.common.insurance.entity.VehicleInsurance</class>
       <!--  class>org.spec.jent.vehicle.entity.VehicleDescription</class -->
       <shared-cache-mode>NONE</shared-cache-mode>
   </persistence-unit>
</persistence>

And there are the datasources defined in standalone.xml:

            <datasources>
                <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">
                    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
                    <driver>h2</driver>
                    <security>
                        <user-name>sa</user-name>
                        <password>sa</password>
                    </security>
                </datasource>
                <datasource jndi-name="java:jboss/datasources/jdbc/SPECjInsuranceDS" pool-name="SPECjInsuranceDS">
                    <connection-url>jdbc:postgresql://localhost:5432/specdb</connection-url>
                    <driver>postgres</driver>
                    <security>
                        <user-name>specdb</user-name>
                        <password>root</password>
                    </security>
                </datasource>
                <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                    <driver name="postgres" module="org.postgres">
                        <driver-class>org.postgresql.Driver</driver-class>
                    </driver>
                </drivers>
            </datasources>

As you can see, i added the required datasource, and tested the connection inside the Wildfly console.

Thanks in advance for any reply.


Solution

  • The correct jndi-name was jndi-name="java:/jdbc/SPECjInsuranceDS" instead of jndi-name="java:jboss/datasources/jdbc/SPECjInsuranceDS"

    The updated standalone.xml is then:

    <datasources>
       <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">
          <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
          <driver>h2</driver>
          <security>
             <user-name>sa</user-name>
             <password>sa</password>
          </security>
       </datasource>
       <datasource jndi-name="java:jboss/datasources/jdbc/SPECjInsuranceDS" pool-name="SPECjInsuranceDS">
          <connection-url>jdbc:postgresql://localhost:5432/specdb</connection-url>
          <driver>postgres</driver>
          <security>
             <user-name>specdb</user-name>
             <password>root</password>
          </security>
       </datasource>
       <drivers>
          <driver name="h2" module="com.h2database.h2">
             <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
          </driver>
          <driver name="postgres" module="org.postgres">
             <driver-class>org.postgresql.Driver</driver-class>
          </driver>
       </drivers>
    </datasources>