2017-08-10 57 views
0

我试图在终端上运行我的服务。这几乎可以,只是缺少的默认数据源错误,即使经过大量的谷歌研究之后仍然存在。让我来解释Wildfly&Postgre:缺少默认数据源问题

我使用wildfly 10.1.0

这是我在standalone.xml数据源

<datasources> 
    <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="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/datasources/PostgreSQLDS" pool-name="PostgreSQLDS" enabled="true" use-java-context="true"> 
     <connection-url>jdbc:postgresql://localhost:5432/lucasmucida</connection-url> 
     <driver>postgresql</driver> 
     <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> 
     <pool> 
      <min-pool-size>10</min-pool-size> 
      <max-pool-size>100</max-pool-size> 
      <prefill>true</prefill> 
     </pool> 
     <security> 
      <user-name>xxx</user-name> 
      <password>xxx</password> 
     </security> 
     <statement> 
      <prepared-statement-cache-size>32</prepared-statement-cache-size> 
      <share-prepared-statements>true</share-prepared-statements> 
     </statement> 
    </datasource> 
    <drivers> 
     <driver name="h2" module="com.h2database.h2"> 
      <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class> 
     </driver> 
     <driver name="postgresql" module="org.postgresql"> 
      <xa-datasource-class>org.postgresql.xa.PGXADataSourc</xa-datasource-class> 
     </driver> 
    </drivers> 
</datasources> 

这是包含defaul结合

部分OS standalone.xml
<subsystem xmlns="urn:jboss:domain:ee:4.0"> 
       <spec-descriptor-property-replacement>false</spec-descriptor-property-replacement> 
       <concurrent> 
        <context-services> 
         <context-service name="default" jndi-name="java:jboss/ee/concurrency/context/default" use-transaction-setup-provider="true"/> 
        </context-services> 
        <managed-thread-factories> 
         <managed-thread-factory name="default" jndi-name="java:jboss/ee/concurrency/factory/default" context-service="default"/> 
        </managed-thread-factories> 
        <managed-executor-services> 
         <managed-executor-service name="default" jndi-name="java:jboss/ee/concurrency/executor/default" context-service="default" hung-task-threshold="60000" keepalive-time="5000"/> 
        </managed-executor-services> 
        <managed-scheduled-executor-services> 
         <managed-scheduled-executor-service name="default" jndi-name="java:jboss/ee/concurrency/scheduler/default" context-service="default" hung-task-threshold="60000" keepalive-time="3000"/> 
        </managed-scheduled-executor-services> 
       </concurrent> 
       <default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/lucasmucida" jms-connection-factory="java:jboss/DefaultJMSConnectionFactory" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/> 
      </subsystem> 

这是我的module.xml那就是/模块/系统/层/基层/组织/ PostgreSQL的/主文件夹内

<?xml version="1.0" encoding="UTF-8"?> 
<module xmlns="urn:jboss:module:1.0" name="org.postgresql"> 
    <resources> 
    <resource-root path="postgresql-42.1.4.jar"/> 
    </resources> 
    <dependencies> 
    <module name="javax.api"/> 
    <module name="javax.transaction.api"/> 
    </dependencies> 
</module> 

如果我运行SH standalone.sh它在lucasmucida数据库中创建甚至表,但这个错误:

17:38:49,984 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "jpa2-1.0-SNAPSHOT.war")]) - failure description: { 
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.jboss.datasources.lucasmucida"], 
    "WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.\"jpa2-1.0-SNAPSHOT\".\"jpa2-1.0-SNAPSHOT\".DefaultDataSource is missing [jboss.naming.context.java.jboss.datasources.lucasmucida]"] 
} 
17:38:49,988 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "testeJava-1.0-SNAPSHOT.war")]) - failure description: { 
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.jboss.datasources.lucasmucida"], 
    "WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.\"testeJava-1.0-SNAPSHOT\".\"testeJava-1.0-SNAPSHOT\".DefaultDataSource is missing [jboss.naming.context.java.jboss.datasources.lucasmucida]"] 
} 

不要让我的NetBeans运行它。如果我运行该项目,它将创建该表,但不会部署和启动该项目。

如果我去本地主机:9090和测试连接,两个数据源连接正常。

我在这里错过了什么?

+0

可以检查'瓮内你'默认binding'设置:JBoss的:域名:EE:4.0'子系统的独立。 XML?根据你的配置,你可能已经删除了默认绑定的'datasource'参数。 – stdunbar

+0

我编辑了默认绑定配置的mny文章。我不知道它是否有什么问题 – Mucida

+0

尝试将默认绑定改回到java:jboss/datasources/ExampleDS'的默认数据源。无论如何你都不需要修改。 – stdunbar

回答

0

只需将driver.jar你module.xml位置

+0

这个jar“postgresql-42.1.4.jar”已经存在了= / – Mucida