Datasource configuration in wildfly 10

不想你离开。 提交于 2019-12-04 09:48:52

I'd like to recommend a change to your process. While you certainly can do this by hand, if you script this you can do it again with repeatability.

This is dependent on the jboss-cli.sh. I have a script that looks like:

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

batch

module add --name=org.postgres --resources=/tmp/postgresql-42.0.0.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=myDataSource/:add(connection-url=jdbc:postgresql://localhost:5432/thedatabasename,driver-name=postgres,jndi-name=java:/jdbc/myDataSource,initial-pool-size=4,max-pool-size=64,min-pool-size=4,password=theDatabasePassword,user-name=theDatabaseUsername)

run-batch

This is run with:

bin/jboss-cli.sh --file=/path/to/file/wildflyconf.cli

The script starts by using the "embed-server" command so that your Wildfly instance does not need to be running. Then it starts a batch of commands to run as one unit.

The important part is that we create the module via the command line. You will have to put the PostgreSQL jar somewhere but other than that the script takes care of creating all of the needed files under "modules".

Next, we add the JDBC driver and then we create a Datasource based on the driver.

The advantage of a script is that you can check this into your source code control system and anyone can run it. It reduces the possibility of a typo and you don't need to manually create and modify files.

Just a thought. Having a repeatable process that your development team can use is always a useful thing.

You are defining your Driver class as a Datasource class :

<datasource-class>org.postgresql.Driver</datasource-class>

please use the correct element:

<driver-class>org.postgresql.Driver</driver-class>

just like @stdunbar showed you in his CLI command :

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

in your file module.xml in the 2nd line change

<module xmlns="urn:jboss:module:1.3" name="org.postgresql“>

to

<module xmlns="urn:jboss:module:1.3" name="org.postgresql">

the ' " ' may be the problem in your module.xml

bibekaa

Set the following system properties in standalone.xml and it should work fine:

-Dorg.kie.server.persistence.dialect=org.hibernate.dialect.PostgreSQLDialect

-Dorg.kie.server.persistence.ds=java:jboss/datasources/yourDataSource

<system-properties>
    <property name="org.kie.server.persistence.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
    <property name="org.kie.server.persistence.ds" value="java:jboss/datasources/ExampleDS"/>
</system-properties>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!