WildFly 18.0.1 JDBC驱动程序:内部错误(newValue为null)


17

我在WildFly(18.0.1)中配置JDBC驱动程序时遇到问题。

每当我打开(配置/子系统/数据源和驱动程序/ JDBC驱动程序)时,

我得到:

内部错误(详细信息:newValue为null)。

错误图片1:

错误图片2:

任何帮助将不胜感激!


服务器日志中是否有任何内容(通常在Wildfly安装目录下的standalone / log / server.log中)?
— stdunbar

日志文件中没有任何内容指示问题。在日志文件中收到错误后,也没有任何更改。
— ayou392

我有同样的问题,不知道为什么。我安装了版本18.0.1_Final和16.0.0_Final,但是存在相同的问题。您是否已经找到解决方案?
— Paigeola

Answers:


3

我可以完全重现您的问题。我已经有一段时间没有使用Wildfly控制台了,但这对我来说似乎是个错误。但是,还有另一种方法具有易于重复和编写脚本的优点。

如果jboss-cli从Wildfly bin目录运行,则可以使用脚本添加JDBC驱动程序和JEE数据源。我的脚本看起来像:

embed-server --server-config=standalone.xml --std-out=echo

batch

module add --name=org.postgres --resources=${user.home}/Downloads/postgresql-42.2.8.jar --dependencies=javax.api,javax.transaction.api

/subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-class-name=org.postgresql.Driver)


/subsystem=datasources/data-source=myDS/:add(connection-url=jdbc:postgresql://localhost:5432/dbname,driver-name=postgres,jndi-name=java:/jdbc/myDS,background-validation=true,background-validation-millis=60000,blocking-timeout-wait-millis=2000,flush-strategy=Gracefully,idle-timeout-minutes=5,initial-pool-size=4,max-pool-size=64,min-pool-size=4,password=the-password,query-timeout=10,track-statements=true,tracking=true,user-name=the-user,validate-on-match=false)

run-batch

该脚本应在服务器未运行的情况下运行。如果您想在服务器上运行,然后删除运行它embed-server,batch和run-batch线条。基本上,这首先要创建一个模块,在本例中为PostgreSQL驱动程序。然后添加一个JDBC驱动程序,最后添加一个数据源。它可以与以下命令一起运行:

jboss-cli.sh --file=the-file-name.cli

假设您将以上内容保存到名为的文件中the-file-name.cli。同样,binWildfly 的目录需要位于您的路径上才能在命令行上运行它。


为我工作,谢谢!
— Paigeola

9

这不是wildfly / jboss问题。该错误位于Hal管理控制台(版本3.2.1)中。我修复了此错误,将HAL控制台版本更改为3.2.4。

  1. 下载版本:
wget https://repository.jboss.org/nexus/content/repositories/ea/org/jboss/hal/hal-console/3.2.4.Final/hal-console-3.2.4.Final-resources.jar
  1. 将jar文件复制到wildfly目录
sudo cp hal-console-3.2.4.Final-resources.jar /opt/wildfly/modules/system/layers/base/org/jboss/as/console/main/
  1. 编辑文件module.xml
sudo vim /opt/wildfly/modules/system/layers/base/org/jboss/as/console/main/module.xml
  1. 更改文件module.xml中的版本
   <resources>
        <resource-root path="hal-console-3.2.4.Final-resources.jar"/>
    </resources>
  1. 重新启动jboss / wildfly
sudo systemctl restart wildfly or sudo service wildfly restart

3
github档案似乎并不包含目标文件夹,而仅包含源代码。因此,我们要么构建该Maven项目,要么从其他位置(例如WildFly 19 beta)中提取控制台jar。
— T-Gergely

1
步骤1a。-安装maven,cd应用程序,mvn软件包(然后等待,然后复制jar)
— David O'Meara

我忘了包括编译src的步骤。我将在答案中添加此内容
— Daniel Xavier Oliveira


1
另一件事:重新启动服务器是不够的,您需要强制浏览器缓存刷新^ _ ^'
— Giampaolo


0

使用此链接how_to_setup_postgresql_datasource_with_wildfly。这将以替代方式解决您的问题。

配置文件版本(单向)

Standalone.xml是服务器的配置文件。管理控制台只是用于编辑此文件的友好UI。

部署JDBC驱动程序

  • 打开文件浏览器,然后转到Wildfly 安装目录中的/ modules / 目录。
  • 创建文件夹/ org / postgresql / main /。这些文件夹需要匹配JDBC驱动程序的层次结构包。
  • 将JDBC驱动程序复制到您创建的“主”目录中。在此目录中,使用以下命令创建一个“ module.xml”文件

        <resources>
            <resource-root path="postgresql-42.2.1.jar"/>
            <!-- Make sure this matches the name of the JAR you are installing -->
        </resources>
        <dependencies>
            <module name="javax.api"/>
            <module name="javax.transaction.api"/>
        </dependencies>
    </module>

创建数据源 -转到Wildfly安装目录中的/ standalone / configuration目录。-打开standalone.xml(这是独立服务器使用的默认配置文件)-搜索“数据源”以转到右侧。-在元素中,您需要同时添加PostgreSQL和

需要重新启动Wildfly,您可以通过在管理控制台中测试连接来验证更改。

<drivers>
    <driver name="postgresql" module="org.postgresql">
        <!-- for xa datasource -->
        <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
        <!-- for non-xa datasource -->
        <driver-class>org.postgresql.Driver</driver-class>
    </driver>
</drivers>
<datasources>
    <datasource jndi-name="java:jboss/datasources/StemoDS" pool-name="StemoDS" enabled="true" use-java-context="true">
        <connection-url>jdbc:postgresql://localhost:5432/StemoDS</connection-url>
        <driver>postgresql</driver>
        <security>
            <user-name>postgres</user-name>
            <password>admin</password>
        </security>
    </datasource>
</datasources>

另一种使用Wildfly CLI的方式(2种方式)

添加数据源的另一种方法是使用控制台行界面(CLI)。同样,该过程分为两个步骤。

部署JDBC驱动程序-转到Wildfly安装目录中的/ bin目录。-在此目录上打开终端并运行

  ./jboss-cli.sh --connect controller=127.0.0.1 (or jboss-cli.bat if you are on Windows)
  • 要安装模块,请运行以下命令

    模块添加--name = org.postgresql --resources = / tmp / postgresql-42.2.1.jar --dependencies = javax.api,javax.transaction.api

  • 创建数据源使用此命令完成驱动程序的创建

    / subsystem = datasources / jdbc-driver = postgres:add(驱动程序名称=“ postgres”,驱动程序模块名称=“ org.postgresql”,驱动程序类名称= org.postgresql.Driver)

  • 然后,最后一条命令添加数据源

    数据源添加--jndi-name = java:jboss / datasources / StenusysDemoDS --name = StenusysDemoDS --connection-url = jdbc:postgresql:// localhost:5432 / StenusysDemo --driver-name = postgres --user-名称= postgres --password = admin

您可以通过在管理控制台中测试连接来验证更改。


0

我遇到了同样的问题,但是解决的方法是使用字母数字和1个非字母数字字符创建一个带有密码的控制台用户。

  1. 运行服务器wildfly phat \ bin \ standalone.bat
  2. wildfly phat \ bin \ add-user.bat
  3. 按if Manager控制台
  4. 用户名:admin或输入所需的用户名
  5. 按更新管理员用户
  6. 密码:例如p @ ssword1或包含1个非字母数字字符的密码
  7. repassword:您使用的相同密码
  8. 输入
  9. 否,然后输入

并最终使用与Chrome不同的网络浏览器

密码不带1个非字母数字字符的配置用户

使用1个非字母数字字符的密码配置用户


清除网络浏览器历史记录的最后一步
— Esteban Vallejo
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.