【发布时间】:2017-08-10 21:02:36
【问题描述】:
我正在尝试在终端上运行我的服务。几乎没问题,只是缺少默认数据源错误,即使在对谷歌进行了大量研究后仍然存在。让我解释一下
我正在使用 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>
这是包含默认绑定的部分 osstandalone.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,它位于 /modules/system/layers/base/org/postgresql/main 文件夹中
<?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 上运行它。如果我运行项目,它会创建表,但不会部署和启动项目。
如果我去 localhost:9090 并测试连接,两个数据源都连接正常。
我在这里错过了什么?
【问题讨论】:
-
您能否检查您的standalone.xml 中
urn:jboss:domain:ee:4.0子系统内的default-binding设置?根据您的配置方式,您可能已经删除了默认绑定的datasource参数。 -
我已经使用默认绑定配置编辑了 mny 帖子。不知道是不是有什么问题
-
尝试将默认绑定改回默认数据源
java:jboss/datasources/ExampleDS。反正你不需要修改它。
标签: xml postgresql netbeans jboss wildfly