Wildfly Post_Module& Postgres.jdbc.driver错误

时间:2015-02-26 10:38:38

标签: jdbc java-ee-7 wildfly-8 postgresql-9.4

我正在使用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控制台它没有看到驱动程序,我无法正确注册驱动程序模块?

2 个答案:

答案 0 :(得分:1)

standalone.xml - &gt;的PostgreSQL-9.3-1102.jdbc41.jar

模块中的

配置 - &gt;的PostgreSQL-9.4-1201-jdbc41.jar

在任何情况下,Wildfly都会建议直接在服务器上部署驱动程序,而不是创建模块。

答案 1 :(得分:0)

一个疯狂的猜测:修改过的 standalone.xml 中的拼写错误:Postgre[s]DS