我正在尝试部署SPECjEnterprise®2018 Web配置文件以对WildFly进行基准测试。基准测试文档没有指定任何部署指令,称其超出了文档的范围。
我试图部署一个.war
文件,但我得到了以下错误:
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]"
]
}
这是我试图部署的.war
的persistence.xml
:
<?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>
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>
正如您所看到的,我添加了所需的数据源,并在Wildfly控制台中测试了连接。
提前感谢您的回复。
正确的jndi-name
是jndi-name="java:/jdbc/SPECjInsuranceDS"
而不是jndi-name="java:jboss/datasources/jdbc/SPECjInsuranceDS"
更新后的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>