无法解析 Jboss 中的数据源依赖关系

Unable to resolve data source dependencies in Jboss

我正在尝试通过 Eclipse 在 JBoss 服务器上部署 JEE Web 应用程序,但我无法解决与数据源相关的依赖性错误。奇怪的是当我开始部署控制台时显示此消息

JBAS014776:    Newly corrected services:
      service jboss.naming.context.java.jboss.datasources.AssetTrackerDS (no longer required)

但是部署失败并出现此错误。

ERROR [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "AssetTracker.war" was rolled back with the following failure message: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"AssetTracker.war#AssetTracker\" is missing [jboss.naming.context.java.jboss.datasources.AssetTrackerDS]"]}

JBoss 服务器已正确配置数据库,连接测试显示正确结果。

standalone.xml

中的数据源配置
              <datasources>
                <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true">
                    <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 jta="true" jndi-name="java:jboss/datasource/AssetTrackerDS" pool-name="AssetTrackerDS" enabled="true" use-java-context="true" use-ccm="true">
                    <connection-url>jdbc:postgresql://localhost:5432/test</connection-url>
                    <driver-class>org.postgresql.Driver</driver-class>
                    <driver>postgresql-9.4.1212.jre6.jar</driver>
                    <security>
                        <user-name>***</user-name>
                        <password>***</password>
                    </security>
                    <validation>
                        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>
                        <background-validation>true</background-validation>
                        <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
                    </validation>
                </datasource>
                <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
    xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit transaction-type="JTA" name="AssetTracker">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>java:jboss/datasources/AssetTrackerDS</jta-data-source>
        <properties>
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
            <property name="transaction.flush_before_completion" value="true" />
            <property name="connection.pool_size" value="5" />
            <property name="hibernate.format_sql" value="false"/>
        </properties>
    </persistence-unit>
</persistence>

我正在使用 JBoss EAP 6.2 和 Eclipse Neon。

您有一个拼写错误:

 <datasource jta="true" jndi-name="java:jboss/datasource/AssetTrackerDS"

对比

<jta-data-source>java:jboss/datasources/AssetTrackerDS</jta-data-source>