Jboss 操作(“添加")失败 [英] Jboss Operation("add") failed

查看:42
本文介绍了Jboss 操作(“添加")失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Jboss 的新手.我正在尝试使用 Jboss 启动 Spring Boot,但遇到了 postgres 驱动程序的问题.当我启动服务器时,弹出以下错误并崩溃.

I am new in Jboss. I am trying to start Spring Boot with Jboss and encountered a problem with postgres driver. when I start server the following error pops up and crashes .

  > 13:00:47,681 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
        ("subsystem" => "datasources"),
        ("data-source" => "DigitalFarm_DS")
    ]) - failure description: {
        "WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.postgresql"],
        "WFLYCTL0180: Services with missing/unavailable dependencies" => [
            "org.wildfly.data-source.DigitalFarm_DS is missing [jboss.jdbc-driver.postgresql]",
            "jboss.driver-demander.java:jboss/datasources/DigitalFarmDS is missing [jboss.jdbc-driver.postgresql]"
        ]
    }
    13:00:47,682 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
        ("subsystem" => "datasources"),
        ("data-source" => "DigitalFarm_DS")
    ]) - failure description: {
        "WFLYCTL0412: Required services that are not installed:" => [
            "jboss.jdbc-driver.postgresql",
            "jboss.jdbc-driver.postgresql"
        ],
    
    

还有我的独立文件

    <datasources>
                <datasource jndi-name="java:jboss/datasources/DigitalFarmDS" pool-name="DigitalFarm_DS" enabled="true" use-java-context="true" statistics-enabled="true">
                    <connection-url>jdbc:postgresql://localhost:5432/DigitalFarm</connection-url>
                    <driver>postgresql</driver>
                    <security>
                        <user-name>_db_username</user-name>
                        <password>_db_password_</password>
                    </security>
                </datasource>
                <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">
                    <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>
                <drivers>
                    <driver name="postgresql" module="org.postgresql">
                        <driver-class>org.postgresql.Driver</driver-class>
                        <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
                    </driver>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>

我正在为wildfly使用这个依赖

and I am using this dependency for wildfly

    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.tomcat.embed</groupId>
                    <artifactId>tomcat-embed-websocket</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

请帮帮我.你遇到过这样的问题吗?.

help me please. have you ever had this issue happen to you?.

推荐答案

服务器找不到postgresql"的驱动jar的问题;在您的类路径中.

The problem that the server could not find the driver jar for "postgresql" in your classpath.

        "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "org.wildfly.data-source.DigitalFarm_DS is missing [jboss.jdbc-driver.postgresql]"

实际上,Jboss 中的 Datasource 子系统默认获取应用程序类路径中的驱动程序类,该类是通过驱动程序部分中的模块名称加载的.在 Jboss 中,您可以通过两种方式加载模块:

Actually, the Datasource subsystem in Jboss by default fetch the driver class in the application classpath, which is loaded by the module name in the driver section. In Jboss you can load modules in 2 ways:

首先:使用应用部署库

如果您使用具有以下结构的部署扫描器 (JBOSS_APP//.),请将 Postgres 驱动程序 jar 添加到您的应用程序部署资源:

Add the Postgres driver jar to your application deployment resource if you are using a deploymen-scanner (JBOSS_APP/<Deployment_directory>/<deployment_filename>.<compress_extension>) with this structure :

app-deployment.war
 |_WEB-INF
  |_lib
   |_postgresql-42.2.5.jar (example version)

第二:外部模块

在您的 jboss 实例中创建一个与您的案例中的模块名称匹配的新模块,它应该是这样的:

Create a new module in your jboss instance that match the module name in your case it should something like this :

modules
|_org
 |_postgresql
  |_main
   |_postgresql-42.2.5.jar
   |_module.xml

其中 module.xml 描述了这个新的模块资源(驱动 jar 文件),例如:

where the module.xml describes this new module resources (the driver jar file), example:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.7" name="org.postgresql">

    <resources>
        <resource-root path="postgresql-42.2.5.jar.jar"/>
    </resources>

    <dependencies>
        <module name=""/>
      ...
    </dependencies>

</module>

最后,您需要将该模块添加到 jboss-deployment-structure.xml (app-deployment/WEB-INF/jboss-deployment-structure.xml) 中,以便在部署应用程序时将其视为外部依赖项,示例:

and finally, you need to add the module to the jboss-deployment-structure.xml (app-deployment/WEB-INF/jboss-deployment-structure.xml) to be considred as an external dependncy while deploying the app, example :

<?xml version='1.0' encoding='UTF-8'?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
    <deployment>
         <dependencies>
            ...
             <module name="org.postgresql"/>
            ...
        </dependencies>

    </deployment>         
    
</jboss-deployment-structure>

当驱动程序应由外部管理时使用此解决方案.

This solution is used when the drivers should be managed externally.

这篇关于Jboss 操作(“添加")失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆