【问题标题】:wildfly wont start because of new missing/unsatisfied dependencies由于新的缺失/不满足的依赖关系,wildfly 无法启动
【发布时间】:2018-11-17 19:43:46
【问题描述】:

当我尝试启动我的 WildFly 服务器时,我收到了这个错误:

2018-11-17 21:29:55,203 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 33) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "org.postgresql")
]) - failure description: "WFLYJCA0041: Failed to load module for driver [org.postgresql]"
ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "swap")
]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/swap is missing [jboss.jdbc-driver.org_postgresql]",
"jboss.data-source.java:jboss/datasources/swap is missing [jboss.jdbc-driver.org_postgresql]"
]}
2018-11-17 21:30:07,625 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "swap")
]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/swap is missing [jboss.jdbc-driver.org_postgresql]",
"jboss.data-source.java:jboss/datasources/swap is missing [jboss.jdbc-driver.org_postgresql]",
"jboss.data-source.java:jboss/datasources/swap is missing [jboss.jdbc-driver.org_postgresql]"
]}

还有我的 standalone.xml:

<datasources>
     <datasource jndi-name="java:jboss/datasources/swap" pool-name="swap" enabled="true" use-java-context="true">
        <connection-url>jdbc:postgresql://127.0.0.1:5432/swap?useUnicode=yes&amp;characterEncoding=UTF-8</connection-url>
        <driver>org.postgresql</driver>
        <security>
            <user-name>postgres</user-name>
            <password>postgres</password>
        </security>
     </datasource>
     <drivers>
         <driver name="org.postgresql" module="org.postgresql">
             <driver-class>org.postgresql.Driver</driver-class>
             <xa-datasource-class>org.postgresql.Driver</xa-datasource-class>
         </driver>
     </drivers>
</datasources>

我的 PostgreSQL module.xml:

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

可能是什么问题?请帮忙,谢谢。

【问题讨论】:

    标签: postgresql jdbc wildfly


    【解决方案1】:

    您的module.xml 无效。缺少&lt;dependencies&gt; 标签。尝试以下方法:

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

    编辑:

    module.xml 文件和postgresql-42.2.5.jar 必须在

    C:\wildfly\wildfly-9.0.2.Final\modules\system\layers\base\org\postgresql\main.

    也建议将你的模块直接放入

    C:\wildfly\wildfly-9.0.2.Final\modules\.

    所以在你的情况下C:\wildfly\wildfly-9.0.2.Final\modules\org\postgresql\main,这可能是个问题。

    作为参考,还可以查看EAP7 Documentation,您还应该考虑使用jboss-cli。

    【讨论】:

    • 编辑 module.xml 后问题依旧。还有其他想法吗?
    • module.xml 的位置是什么?告诉我你的目录和文件布局
    • C:\wildfly\wildfly-9.0.2.Final\modules\system\layers\base\org\postgresql
    【解决方案2】:

    为 WildFly 服务器配置 PostgresSQL,您应该按照以下步骤操作。

    第 1 步:添加 PostgreSQL 模块

    如果不存在,则创建新文件夹${wildfly_home}/modules/system/layers/base/org/postgresql/main/。

    通过此链接下载最新的驱动程序 Jar => https://jdbc.postgresql.org/download.html 并放在上述文件夹下。

    同样在那个新文件夹中,创建module.xml 并放入以下配置。

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

    可能是jar版本需要在resource-root更新。

    第 2 步:从 standalone.xml 更新数据库配置

    删除现有的 &lt;driver&gt; 配置并添加新配置如下。

    <driver name="postgresql" module="org.postgresql">
        <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
    </driver>
            
    

    删除现有的 &lt;datasource&gt; 配置并添加新配置,如下所示。

    <datasource jndi-name="java:jboss/datasources/PostgresDS" pool-name="PostgresDS" enabled="true" use-java-context="true">
        <connection-url>jdbc:postgresql://127.0.0.1:5432/swap?useUnicode=yes&amp;characterEncoding=UTF-8</connection-url>
        <driver>postgresql</driver>
        <security>
            <user-name>postgres</user-name>
            <password>postgres</password>
        </security>
        <pool>
            <max-pool-size>20</max-pool-size>
        </pool>
    </datasource>
            
    

    将default-bindings数据源名称从ExampleDS修改为PostgresDS。

    <default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/PostgresDS" ...
    

    确保您已在 PostgreSQL 数据库服务器中创建了 swap 数据库。

    现在,运行服务器就可以了。

    【讨论】:

      猜你喜欢
      • 2017-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-06
      • 2022-12-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多