我正在使用 Wildfly 8.2 和 postgresql 9.4 和 java ee 7。我正在做一些关于休息服务的教程。我完全不知道出了什么问题,我没有更改 .xml 中的任何内容,但出现了旧错误,因为我记得我在开始使用我的应用程序时解决了类似的问题(在第一次尝试连接 2 个数据源之后)。当我尝试在服务器上部署我的应用程序时,我得到了这个:
11:24:29,700 INFO [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011401: Read persistence.xml for test
11:24:30,013 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "postgres.war")]) - failure description: {"JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
"Services that were unable to start:" => [
"jboss.deployment.unit.\"postgres.war\".POST_MODULE",
"jboss.persistenceunit.\"postgres.war#test\""
],
"Services that may be the cause:" => ["jboss.jdbc-driver.postgresql-9_3-1102_jdbc41_jar"]
}}
11:24:30,013 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "PostgresDS")
]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/PostgresDS is missing [jboss.jdbc-driver.postgresql-9_3-1102_jdbc41_jar]",
"jboss.data-source.java:jboss/PostgresDS is missing [jboss.jdbc-driver.postgresql-9_3-1102_jdbc41_jar]"
]}
11:24:30,013 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "Test")
]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.data-source.java:jboss/datasources/TestDs is missing [jboss.jdbc-driver.postgresql-9_3-1102_jdbc41_jar]",
"jboss.driver-demander.java:jboss/datasources/TestDs is missing [jboss.jdbc-driver.postgresql-9_3-1102_jdbc41_jar]"
]}
11:24:30,013 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "PostgresDS")
]) - failure description: {
"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/PostgresDS is missing [jboss.jdbc-driver.postgresql-9_3-1102_jdbc41_jar]",
"jboss.data-source.java:jboss/PostgresDS is missing [jboss.jdbc-driver.postgresql-9_3-1102_jdbc41_jar]"
],
"JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
"Services that were unable to start:" => [
"jboss.data-source.reference-factory.PostgresDS",
"jboss.naming.context.java.jboss.PostgresDS"
],
"Services that may be the cause:" => ["jboss.jdbc-driver.postgresql-9_3-1102_jdbc41_jar"]
}
}
11:24:30,013 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "Test")
]) - failure description: {
"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.data-source.java:jboss/datasources/TestDs is missing [jboss.jdbc-driver.postgresql-9_3-1102_jdbc41_jar]",
"jboss.driver-demander.java:jboss/datasources/TestDs is missing [jboss.jdbc-driver.postgresql-9_3-1102_jdbc41_jar]"
],
"JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
"Services that were unable to start:" => [
"jboss.data-source.reference-factory.Test",
"jboss.naming.context.java.jboss.datasources.TestDs"
],
"Services that may be the cause:" => ["jboss.jdbc-driver.postgresql-9_3-1102_jdbc41_jar"]
}
}
我的persistance.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="test" ><!-- transaction-type="RESOURCE_LOCAL"> -->
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:jboss/PostgresDS</jta-data-source>
<class>rest.Book</class>
<properties>
<property name="javax.persistence.schema-generation-action"
value="drop-and-create" />
<property name="javax.persistence.schema-generation-target"
value="database-and-scripts" />
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql:postgres2" />
<property name="javax.persistence.jdbc.user" value="postgres" />
<property name="javax.persistence.jdbc.password" value="POSTGRES" />
<property name="eclipselink.ddl-generation" value="create-tables" />
</properties>
</persistence-unit>
</persistence>
和standalone.xml中的数据源,我通过:9990添加它们。
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<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/PostgresDS" pool-name="PostgresDS" enabled="true" use-ccm="true">
<connection-url>jdbc:postgresql:postgres</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgresql-9.3-1102.jdbc41.jar</driver>
<security>
<user-name>postgres</user-name>
<password>POSTGRES</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<set-tx-query-timeout>false</set-tx-query-timeout>
<blocking-timeout-millis>0</blocking-timeout-millis>
<idle-timeout-minutes>0</idle-timeout-minutes>
<query-timeout>0</query-timeout>
<use-try-lock>0</use-try-lock>
<allocation-retry>0</allocation-retry>
<allocation-retry-wait-millis>0</allocation-retry-wait-millis>
</timeout>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<datasource jta="true" jndi-name="java:jboss/datasources/TestDs" pool-name="Test" enabled="true" use-ccm="true">
<connection-url>jdbc:postgresql:test</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgresql-9.3-1102.jdbc41.jar</driver>
<security>
<user-name>postgres</user-name>
<password>POSTGRES</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<set-tx-query-timeout>false</set-tx-query-timeout>
<blocking-timeout-millis>0</blocking-timeout-millis>
<idle-timeout-minutes>0</idle-timeout-minutes>
<query-timeout>0</query-timeout>
<use-try-lock>0</use-try-lock>
<allocation-retry>0</allocation-retry>
<allocation-retry-wait-millis>0</allocation-retry-wait-millis>
</timeout>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
我尝试 2 安装 jdbc 驱动程序作为我创建的模块 '..\wildfly-8.2.0.Final\modules\system\layers\base\org\postgresql\jdbc\main' 并放入 postgresql-9.4-1201.jdbc41.jar和这个 module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
<resources>
<resource-root path="postgresql-9.4-1201-jdbc41.jar"/>
</resources>
<dependencies>
<module name="javax.api" />
<module name="javax.transaction.api" />
</dependencies>
</module>
然后我修改standalone.xml并添加:
<datasource jta="true" jndi-name="java:jboss/datasources/PostgreDS" pool-name="PostgresDS" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:postgresql://localhost:5432/postgres2</connection-url>
<driver>postgresql</driver>
<security>
<user-name>postgres</user-name>
<password>POSTGRES</password>
</security>
</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.PGXADataSource</xa-datasource-class>
</driver>
</drivers>
不工作。当我使用 :9990 控制台时,它看不到驱动程序,我无法正确注册驱动程序模块?