Unable to use postgres with keycloak - jboss

I am trying to use postgres with keycloak. following Doc
$ ls keycloak-9.0.0/modules/system/layers/keycloak/org/postgresql/main
config.xml postgresql-42.2.10.jar
This is the config.xml file.
config.xml
<?xml version="1.0" ?>
<module xmlns="urn:jboss:module:1.3" name="org.postgresql">
<resources>
<resource-root path="postgresql-42.2.10.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
These are the changes that i have made in standalone.xml
standalone.xml
<datasources>
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
<connection-url>jdbc:postgresql://localhost:5432/test</connection-url>
<driver>postgresql</driver>
<pool>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>postgres</user-name>
<password>StrongPassword</password>
</security>
</datasource>
<drivers>
<driver name="postgresql" module="org.postgresql">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
<default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/KeycloakDS">
The error i am getting.
error
06:13:39,430 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 32) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "postgresql")
]) - failure description: "WFLYJCA0115: Module for driver [org.postgresql] or one of it dependencies is missing: [org.postgresql]"
How can i resolve this?

Can I suggest another way to configure this that is less likely to have an issue? I use the following to configure PostgreSQL and Keycloak and it has been working well. The key is to run this against a stopped Keycloak (using a fresh install). Save the below to something like setup-keycloak.cli:
embed-server --server-config=standalone.xml --std-out=echo
batch
#
# remove the default provided datasource
#
/subsystem=datasources/data-source=KeycloakDS/:remove
#
# add them
#
module add --name=org.postgres --resources=/path/to/postgresql-42.2.10.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=KeycloakDS/:add(connection-url=jdbc:postgresql://localhost:5432/keycloak_database,driver-name=postgres,jndi-name=java:jboss/datasources/KeycloakDS,initial-pool-size=4,max-pool-size=64,min-pool-size=4,password=keycloak_user,user-name=keycloak_pass)
run-batch
Then run this with $KEYCLOAK_HOME/bin/jboss.sh --file=setup-keycloak.cli. This removes the KeycloakDS datasource, adds the PostgreSQL module, and recreates the KeycloakDS datasource with your parameters. You can use this to reproduce the configuration any time as long as you have a local copy of the PostgreSQL JDBC driver.

I think your problem is that you named the settings config.xml and should be module.xml.
Second you have to download postgresql jar to that location:
curl -O https://jdbc.postgresql.org/download/postgresql-X.X.X.jar > /opt/keycloak/modules/system/layers/keycloak/org/postgresql/main
just replace the X.X.X with your version.
Then restart the server.
PS: you should use a vault for your password.

This works for me.
create PostgreSQL module.xml (not config.xml) inside base directory (keycloak-11.0.2/modules/system/layers/base/com/postgresql/)
update standalone.xml
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true"
statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">
<connection-url>jdbc:postgresql://localhost:5432/keycloak</connection-url>
<driver>postgresql</driver>
<security>
<user-name>db-user</user-name>
<password>db-pass</password>
</security>
</datasource>
<drivers>
<driver name="postgresql" module="com.postgresql.h2">
<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>

This works for me in standalone:
In file module.xml
<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>
2.In file standalone.xml
<datasources>
<datasource jndi-name="java:jboss/datasources/KeycloakDS"
pool-name="KeycloakDS"
enabled="true"
use-java-context="true"
statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}" >
<connection-url>jdbc:postgresql://192.168.1.XX:5432/Your-DataBase</connection-url>
<driver>postgresql</driver>
<pool>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>UserName</user-name>
<password>**********</password>
</security>
<statement>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="postgresql" module="org.postgresql">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
3.in file standalone.xml
<default-bindings
context-service="java:jboss/ee/concurrency/context/default"
datasource="java:jboss/datasources/KeycloakDS"
managed-executor-service="java:jboss/ee/concurrency/executor/default"
managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default"
managed-thread-factory="java:jboss/ee/concurrency/factory/default"/>

For those who came here from tutorials with Dockerized jboss/keycloak instance, you have built-in rdbms support without any configuration: https://hub.docker.com/r/jboss/keycloak/
docker run -p 8080:8080 -e KEYCLOAK_USER=kuser -e KEYCLOAK_PASSWORD=kpass -e DB_VENDOR=postgres -e DB_ADDR=host:port -e DB_DATABASE=postgres -e DB_USER=pguser -e DB_PASSWORD=pgpass jboss/keycloak:15.0.2

Related

Oracle DB Connection: failure description: "WFLYJCA0041: Failed to load module for driver [com.oracle]

Setting up connection to Oracle19C from Keycloak 12.0.3
Receiving message: "failure description: "WFLYJCA0041: Failed to load module for driver [com.oracle]"
I've relooked x100 and can't seem to find what is missing. Could any kind soul review the below for what I have missed?
JAR File path:
/modules/system/layers/keycloak/com/oracle/main
module.xml
ojdbc10.jar
standalone.xml
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">
<connection-url>jdbc:oracle:thin:#DBURL:1521:SID</connection-url>
<driver>oracle</driver>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
<flush-strategy>IdleConnections</flush-strategy>
</pool>
<security>
<user-name>USER</user-name>
<password>PASSWORD</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
<background-validation>true</background-validation>
<stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
</validation>
<timeout>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>5</idle-timeout-minutes>
</timeout>
</datasource>
<driver name="oracle" module="com.oracle">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
module.xml
<?xml version=”1.0" ?><?xml version='1.0' encoding='UTF-8'?>
<module xmlns=”urn:jboss:module:1.3" name=”com.oracle”>
<resources>
<resource-root path=”ojdbc10.jar”/>
</resources>
<dependencies>
<module name=”javax.api”/>
<module name=”javax.transaction.api”/>
</dependencies>
</module>
I had this issue, and the only way I could solve it was to place the oracle driver in the keycloak/modules directory.
These did not work:
keycloak/modules/system/layers/keycloak/com/oracle It is here that is described in the KeyCloak documentation, and it worked for me for Postgres, but I could not get the oracle driver to load from here.
keycloak/modules/system/layers/base/com/oracle : Tried this out of desperation.
But this worked for me in:
keycloak/modules/com/oracle
keycloak/modules/com/oracle/main/module.xml
<?xml version='1.0' encoding='UTF-8'?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle">
<resources>
<resource-root path="ojdbc8.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
And the ojdbc8.jar file was also in this directory.
NOTE: The name="com.oracle" has to match the path com/oracle in the module directory.
In the standalone.xml file, I added the following datasource.
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
<connection-url>jdbc:oracle:thin:#hostname:1521:SID</connection-url>
<driver>oraclejdbc</driver>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>user</user-name>
<password>password</password>
</security>
</datasource>
With the matching driver
<driver name="oraclejdbc" module="com.oracle">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
NOTE:
the module="com.oracle" matches the path com/oracle.
the driver name="oraclejdbc" matches the <driver>oraclejdbc</driver> element.
Once working, I saws this in the log.
2021-05-31 14:46:17,376 INFO [org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory] (ServerService Thread Pool -- 60) Database info: {databaseUrl=jdbc:oracle:thin:#server:1521:SID, databaseUser=user, databaseProduct=Oracle Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.10.0.0.0, databaseDriver=Oracle JDBC driver 19.3.0.0.0}
But prior to it working I would see the following errors in the log (which I am including, incase people are googling the error message)
2021-05-31 14:47:12,049 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 50) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "oraclejdbc")
]) - failure description: "WFLYJCA0115: Module for driver [com.oracle] or one of it dependencies is missing: [com.oracle]"
Or this error
2021-05-31 14:47:14,962 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "KeycloakDS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.oraclejdbc"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.KeycloakDS is missing [jboss.jdbc-driver.oraclejdbc]",
"jboss.driver-demander.java:jboss/datasources/KeycloakDS is missing [jboss.jdbc-driver.oraclejdbc]"
]
}
Adde module via commandline.
module add --name=oracle.jdbc --resources=customization/ojdbc10.jar --dependencies=javax.transaction.api
Created under the following structure:
-keycloak
--modules
----oracle
------jdbc
--------main
----------module.xml
----------ojdbc10.jar

java.lang.ClassNotFoundException: com.mysql.jdbc.MysqlDataTruncation while deploying on wildfly

I am trying to deploy application over wildfly. Its throwing exception on run time.
standalone-full.xml
<datasources>
<datasource jndi-name="java:/TDS" pool-name="TDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://test-mysql.com:3306/abc</connection-url>
<driver>mysql</driver>
<security>
<user-name>sa</user-name>
<password>abc</password>
</security>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>

Wildfly 10 with Postgres 9.6.6 and Hibernate 5.2.12.final

I am trying to get a Java8EE application working on Wildfly10 and Postgres 9.6.6.
Somehow I allways bump into the error that the relation cannot be found.
My Postgres is running on localhost, default port. I am connecting with the user postgres and the correct password. The database (hbnac) has a schema with the same name.
Wildfly is configured to use the database and the “Test connection” is confirming a successful connection.
Using pgAdmin 4 I can also browse the database, see the schema, as well as the table group_member.
The config in Jboss looks as follow:
<datasource jta="false" jndi-name="java:jboss/datasources/hbnac" pool-name="hbnac" enabled="true" use-ccm="false">
<connection-url>jdbc:postgresql://localhost:5432/hbnac</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgres</driver>
<pool>
<min-pool-size>1</min-pool-size>
<initial-pool-size>1</initial-pool-size>
<max-pool-size>10</max-pool-size>
<flush-strategy>Gracefully</flush-strategy>
</pool>
<security>
<user-name>postgres</user-name>
<password>password</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>
<background-validation>true</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
</validation>
</datasource>
However, my application fails to select a record from the very same table, resulting in the following error:
Caused by: org.postgresql.util.PSQLException: ERROR: relation "group_member" does not exist
The configuration of my persistence.xml is doing a jndi lookup of the connection defined in Wildfly:
<persistence-unit name="hbnac">
<jta-data-source>java:jboss/datasources/hbnac</jta-data-source>
<class>hbnac.birthday.domain.groupmember.GroupMember</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL94Dialect" />
<!--property name="hibernate.hbm2ddl.auto" value="validate"/-->
<!--property name="hibernate.default_schema" value="hbnac"/-->
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
And obviously, the jta-data-source is matching the working datasource in Wildfly. As you can see, I have experimented a bit with the validate (which fails for the same reason at startup) and with the schema name, which also does not make a difference.
The entity itsel is annoted:
#Entity
#Table(name = "group_member")
public class GroupMember extends AbstractEntity {
public final static String FACEBOOK_NAME_FIELD = "facebookName";
public final static String BIRTHDAY_FIELD = "birthday";
#Id
#GeneratedValue(strategy= GenerationType.IDENTITY)
private long id;
It has getters, setters, hashcode and equals methode for all fields available.
If I copy the query generated by hibernate into pgadmin it also works perfectly...
Any ideas left?
success to test connection, but even couldn't find table
that indicates ,perhaps schema setting is not defined correctly.
then, should put a currentSchema like this
<connection-url>jdbc:postgresql://localhost:5432/hbnac?currentSchema=hbnac</connection-url>
and if you use Hibernate to issue query should enable this comment outed code
<!--property name="hibernate.default_schema" value="hbnac"/-->
I found the error after many tries! It was caused by the configuration of the Postgres module in Wildfly itself.
What I had before:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.postgres">
<resources>
<resource-root path="postgresql-42.1.4.jar" />
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true" />
</dependencies>
and in the standalone.xml:
<driver name="postgres" module="org.postgres">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
<datasource-class>org.postgresql.ds.PGSimpleDataSource</datasource-class>
</driver>
for the datasource itself:
<datasource jta="false" jndi-name="java:jboss/datasources/hbnac" pool-name="hbnac" enabled="true" use-ccm="false">
<connection-url>jdbc:postgresql://localhost:5432/hbnac</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgres</driver>
...
This configuration gave a successful connection but the error that a relation could not be found.
By replacing it with the following configuration, everything is working fine:
For the module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.postgres">
<resources>
<resource-root path="postgresql-42.1.4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
For the driver in the standalone.xml:
<driver name="postgresql" module="org.postgres">
<driver-class>org.postgresql.Driver</driver-class>
</driver>
And finally for the db connection:
<datasource jta="true" jndi-name="java:/PostgresDS" pool-name="PostgresDS" enabled="true" use-java-context="true">
<connection-url>jdbc:postgresql://localhost:5432/hbnac</connection-url>
<driver>postgresql</driver>
<security>
...

WildFly Postgres DataSource remote connection-url ignored

I am running into some configuration troubles in setting up a Keycloak server in standalone clustered mode. Despite configuring the datasource to use a postgres database on {REMOTE_IP}, it is failing to start the server complaining that it cannot connect to localhost:5432.
I've been searching all over but I'm befuddled why the DataSource would try to connect to localhost when the connection-url is set to a remote host.
Is there any mistake in my configuration? How can I figure out why PG is trying to connect to localhost instead of {REMOTE_IP}
My setup is 1 Postgres database server and 2 Keycloak servers
I followed the installation instructions for using a relational database and have added the JDBC drivers v9.4.1212 for Postgres.
My DataSource configuration is as follows:
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
<connection-url>jdbc:postgresql://{REMOTE_IP}:5432/keycloak</connection-url>
<driver>postgresql</driver>
<pool>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>keycloak</user-name>
<password>{PASSWORD}</password>
</security>
</datasource>
The error message from the logs reads:
...
Caused by: org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:262)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:52)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:216)
at org.postgresql.Driver.makeConnection(Driver.java:404)
at org.postgresql.Driver.connect(Driver.java:272)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:86)
at org.postgresql.ds.PGPoolingDataSource.getConnection(PGPoolingDataSource.java:309)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:312)
... 43 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.postgresql.core.PGStream.<init>(PGStream.java:61)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:144)
... 52 more
I've verified that I can connect to postgres using psql
# psql -h {REMOTE_IP} keycloak keycloak
psql (9.5.7)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384,
bits: 256, compression: off)
Type "help" for help.
keycloak=>
I managed to figure this out for my case. The JDBC driver for postgres was configured to use a PGPoolingDataSource and had a datasource-class defined.
<driver name="postgresql" module="org.postgresql">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
<datasource-class>org.postgresql.ds.PGPoolingDataSource</datasource-class>
</driver>
When the datasource-class is defined, the connection url must be passed through a connection-property instead of connection-url. I updated my configuration and the server booted up fine.
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
<connection-url>jdbc:postgresql://{REMOTE_IP}:5432/keycloak</connection-url>
<connection-property name="url">jdbc:postgresql://{REMOTE_IP}:5432/keycloak</connection-property>
<driver>postgresql</driver>
<pool>
<max-pool-size>20</max-pool-size>
</pool>
<driver-class>org.postgresql.Driver</driver-class>
<security>
<user-name>keycloak</user-name>
<password>{PASSWORD}</password>
</security>
</datasource>
This issue is noted in the wildfly issue tracker
https://issues.jboss.org/browse/WFLY-6157
a) Below is the snapshot of standalone.xml of wildfly 18.0.1.Final :
<datasources>
<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>
<datasource jndi-name="java:jboss/jdbc/myapp-ds" pool-name="myapp-ds" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">
<connection-url>jdbc:postgresql://mydatabase.mycompany.com:5445/customerdb</connection-url>
<connection-property name="url">
jdbc:postgresql://mydatabase.mycompany.com:5445/customerdb
</connection-property>
<driver>postgresql</driver>
<pool>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>postgres</user-name>
<password>password123$</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>
<datasource-class>org.postgresql.ds.PGPoolingDataSource</datasource-class>
</driver>
</drivers>
</datasources>
b) Also make sure that following files are added in the path wildfly-18.0.1.Final\modules\org\postgresql\main (create if the folder does not exist):
module.xml:
postgresql-42.2.22.jar (download the jar file from internet)
Module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.postgresql">
<resources>
<resource-root path="postgresql-42.2.22.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

Setting Up Mysql Connector Module in JBoss

I've got some issues with MySQL module my local JBoss.
In $JBOSS_HOME I created com/mysql/main
There, I dropped mysql-connector-java-5.1.26-bin.jar and module.xml
I then configured my datasource.
In the Netbeans project, persistence.xml was configured as attached via the Persistence Unit wizard and Netbeans automatically recognizes the configured datasource which is cool.
The issue now is that when I want to "Create Entity Classes From Database", I get this error.
I've checked all over the web. I think I have a good config but this error still persists.
Netbeans: 7.3.1; Mysql connector: 5.1.26; App Server: JBoss EAP 6.1.0; Mysql: 5.6.14; Windows 7; Java 7
Kindly advise.
Thanks.
In $JBOSS_HOME I created com/mysql/main There, I dropped mysql-connector-java-5.1.26-bin.jar and module.xml
Can you make sure the folder is under $JBOSS_HOME/modules location
I found answer today,
just set driver-class and driver the same name
com.mysql.jdbc.Driver
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>com.mysql.jdbc.Driver</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<use-strict-min>true</use-strict-min>
<flush-strategy>IdleConnections</flush-strategy>
</pool>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
And also create jboss-ds xml file and put it into -ejb\src\main\setup
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<datasource jta="false" jndi-name="java:/MysqlDS" pool-name="MysqlDS" enabled="true" use-ccm="false" statistics-enabled="false">
<connection-url>jdbc:mysql://localhost:3306/dmbs?zeroDateTimeBehavior=convertToNull&amp;useUnicode=yes&amp;characterEncoding=UTF-8</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>com.mysql.jdbc.Driver</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<use-strict-min>true</use-strict-min>
<flush-strategy>IdleConnections</flush-strategy>
</pool>
<security>
<user-name>root</user-name>
<password>root</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>3</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>
<track-statements>true</track-statements>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
</datasources>
and my standalone.xml config
<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="false" jndi-name="java:/MysqlDS" pool-name="MysqlDS" enabled="true" use-ccm="false" statistics-enabled="false">
<connection-url>jdbc:mysql://localhost:3306/dmbs?zeroDateTimeBehavior=convertToNull&amp;useUnicode=yes&amp;characterEncoding=UTF-8</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>com.mysql.jdbc.Driver</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<use-strict-min>true</use-strict-min>
<flush-strategy>IdleConnections</flush-strategy>
</pool>
<security>
<user-name>root</user-name>
<password>root</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>3</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>
<track-statements>true</track-statements>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="com.mysql.jdbc.Driver" module="com.mysql.jdbc">
<driver-class>com.mysql.jdbc.Driver</driver-class>
<!-- <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>-->
</driver>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
My module.xml file in
C:\wildfly-9.0.0\modules\system\layers\base\com\mysql\jdbc\main
and near mysql driver jar
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql.jdbc">
<resources>
<resource-root path="mysql-connector-java-5.1.32-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>