Hoping some one can point me in the right direction.
Trying to get away from hardcoded passwd for postgres in the config file for keycloak 19. I dont want to make changes code nor write a custom class based on sdk aws provides, if possible ; keycloak 19.x and using legacy/wildfly
what is needed here in the code below
jdbc-secretsmanager:postgresql://somename.rds.amazonaws.com:5432/keycloak?ssl=true;sslfactory=org.postgresql.ssl.NonValidatingFactory
<driver>awspostgresql</driver>
<pool>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>_aws_secret_name</user-name>
</security>
</datasource>
<drivers>
<driver name="awspostgresql" module="com.amazonaws">
<driver-class>com.amazonaws.secretsmanager.sql.AWSSecretsManagerPostgreSQLDriver</driver-class>
</driver>
</drivers>
</datasources>
===
After satisfying all dependencies/jars, it throws error
===
Jakarta Enterprise Beans subsystem suspension complete
,522 WARN [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 32) WFLYJCA0003: Unable to instantiate driver class "com.amazonaws.secretsmanager.sql.AWSSecretsManagerPostgreSQLDriver": java.lang.IllegalStateException: Could not load real driver with name, "org.postgresql.Driver".
followed by
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.postgresql"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.KeycloakDS is missing [jboss.jdbc-driver.postgresql]",
"jboss.driver-demander.java:jboss/datasources/KeycloakDS is missing [jboss.jdbc-driver.postgresql]"
==== ]
What or how is this supposed to be configured? Appreciate any pointers. Thanks
Related
I am migrating my project from JBoss EAP 6.4 to JBoss EAP 7.2.
So I am getting this kind of error,
15:45:50,571 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "my.war")]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.module.DefaultDataSource"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.dummy.env.myDS is missing [jboss.naming.context.java.module..DefaultDataSource]"]
}
I got to know that this error occurs because default data source is not defined in standalone.xml. In previous versions of JBoss EAP removing DefaultDataSource was not giving this issue. In this version defining DefaultDataSource is mandatory even though those applications do not need that default data source.
So I tried giving default data source as an already existing datasource. In this kind of statement:
<default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:/jdbc/existing" />
And this worked fine.
Now my problem is our environment has multiple databases and their respective data sources.
So we can't define a particular data source as a default. As this will interfere with our applications regular flow. And can create major issues.
We want the application to use their specific data sources only not the default one.
But JBoss EAP 7 is forcing us to specify default data source.
So we can define a dummy default data source? or is there any other alternative way?
default datasource option is present in default binding in standalone.xml
default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/jdbc/jndi-name" 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"/
Applicable to both JBoss EAP 7.2 and Wildfly :
Modify this part of standalone.xml to set the default datasource :
<?xml version="1.0" encoding="UTF-8"?>
<subsystem xmlns="urn:jboss:domain:datasources:3.0">
<datasources>
<datasource jta="true" jndi-name="java:jboss/datasources/default" pool-name="default" enabled="true" use-java-context="true" use-ccm="true" statistics-enabled="true">
<connection-url>jdbc:mysql://localhost:3306/default?autoReconnect=true&useSSL=false</connection-url>
<driver>mysql</driver>
<security>
<user-name>user</user-name>
<password>password</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>
</subsystem>
JBoss/Wildfly will pick up this as an default datasource.
Hope this helps you :)
Problem
I'm trying test my connection and it keeps giving me the same error while at first sight I can't see what I did wrong. Maybe I'm overlooking something...
Error
nexpected HTTP response: 500
Request
{
"address" => [
("subsystem" => "datasources"),
("data-source" => "ProjectenDS")
],
"operation" => "test-connection-in-pool"
}
Response
Internal Server Error
{
"outcome" => "failed",
"failure-description" => "WFLYJCA0040: failed to invoke operation: WFLYJCA0047: Connection is not valid",
"rolled-back" => true
}
Standalone-full.xml
<subsystem xmlns="urn:jboss:domain:datasources:4.0">
<datasources>
<datasource jta="true" jndi-name="java:/ProjectenDS" pool-name="ProjectenDS" enabled="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:3306/projecten3db</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>mysql-connector-java-5.1.40-bin.jar_com.mysql.jdbc.Driver_5_1</driver>
<pool>
<min-pool-size>10</min-pool-size>
<initial-pool-size>11</initial-pool-size>
<max-pool-size>100</max-pool-size>
</pool>
<security>
<user-name>projecten</user-name>
<password>projecten</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<background-validation>true</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
</datasource>
</datasources>
</subsystem>
The exception you have is generic.
Check on {WILDFLY_HOME}/standalone/log/server.log
You can use tail -f server.log while you test on the web console.
This will give you the right error to work on.
I solved this error by reducing pool size and set prefill attribute to false on datasource settings.
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>10</max-pool-size>
<prefill>false</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>IdleConnections</flush-strategy>
</pool>
If your datasource is not XA, open standalone.xml and remove the datasource-class property from your datasource definition. Wildfly adds it even if you don't specify it whe you create the datasource.
You may have to restart the server to see it working.
We had such error on MS SQL when our user was not mapped to requested database
try to check is there any error like "Establishing SSL connection without server's identity verification is not recommended.
According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set.
For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'.
You need either to explicitly disable SSL by setting useSSL=false,"
wrong :jdbc:mysql://localhost:3306/demodb
right :jdbc:mysql://localhost:3306/demodb?useSSL=false
...this worked for me!.
and also make sure!
1.mysql connector added
2.turn off "windows firewall" plus any "antivirus" firewall
3.driver class,pool size,connection url with port number
refer:
https://mkyong.com/mysql/mysql-establishing-ssl-connection-without-servers-identity-verification-is-not-recommended/
I am new in JBoss and I try to add a jdbc driver for derby as a module in WidlFly 8.2.0.
What I did:
I added the org/apache/derby/main folder in the JBOSS_HOME/modules/system/layers/base directory
In this new folder, I added derbyclient.jar (from jdk 1.8.0_40, it contains the driver) and a new module.xml file.
The module.xml file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.apache.derby">
<resources>
<resource-root path="derbyclient.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
Then, I updated the standalone.xml file as follows:
addition of this tag (in <extensions>): <extension module="org.apache.derby"/>
Declaration of my datasource and of the driver:
<datasource jndi-name="java:/DerbyDS" pool-name="DerbyDS" enabled="true" use-ccm="false">
<connection-url>jdbc:derby:MyDB;create=true</connection-url>
<driver>org.apache.derby</driver>
<security>
<user-name>demo</user-name>
<password>demo</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="org.apache.derby" module="org.apache.derby">
<xa-datasource-class>org.apache.derby.jdbc.ClientXADataSource</xa-datasource-class>
</driver>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
I am getting the following error when I start WildFly:
`16:19:49,856 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "DerbyDS")
]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.data-source.java:/DerbyDS is missing [jboss.jdbc-driver.org_apache_derby]",
"jboss.driver-demander.java:/DerbyDS is missing [jboss.jdbc-driver.org_apache_derby]"
]}
16:19:49,866 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "DerbyDS")
]) - failure description: {
"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.data-source.java:/DerbyDS is missing [jboss.jdbc-driver.org_apache_derby]",
"jboss.driver-demander.java:/DerbyDS is missing [jboss.jdbc-driver.org_apache_derby]"
],
"JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
"Services that were unable to start:" => [
"jboss.data-source.reference-factory.DerbyDS",
"jboss.naming.context.java.DerbyDS"
],
"Services that may be the cause:" => ["jboss.jdbc-driver.org_apache_derby"]
}
}
16:19:49,897 INFO [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "MyApp.ear" (runtime-name : "MyApp.ear")
16:19:49,897 INFO [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "MyApp2.ear" (runtime-name : "MyApp2.ear")
16:19:49,907 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.org_apache_derby (missing) dependents: [service jboss.driver-demander.java:/DerbyDS, service jboss.data-source.java:/DerbyDS]`
Do you know what I did wrong?
Thanks in advance
I finally solved the issue by:
adding derbyclient.jar in the standalone directory (where my applications are deployed)
modifying the datasource declaration in the standalone.xml to make it reference the jar name :
<datasource jndi-name="java:/DerbyDS" pool-name="DerbyDS"enabled="true" use-ccm="false"> <connection-url>jdbc:derby:MyDB;create=true</connection-url> <driver>derbyclient.jar</driver>...
(I deleted the <drivers> tag, I don't use it anymore.)
So, I don't have errors anymore when I start WildFly. The derby driver is not declared as a module, but it will be shared among my different applications, so that's ok.
Your URL jdbc:derby://:MyDB looks invalid.
Jboss EAP 6.3, Oracle 11g Express.
I have this oracle datasource in standalone:
<datasource jta="true" jndi-name="java:/OracleDS" pool-name="OracleDS">
<connection-url>jdbc:oracle:thin:#localhost:1521:XE</connection-url>
<driver>oracleDriver</driver>
<security>
<user-name>Boris</user-name>
<password>password</password>
</security>
</datasource>
<drivers>
<driver name="oracleDriver" module="com.oracle">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
</drivers>
The Oracle database is running, I can connect to it using sqlplus:
SQL> connect
Enter user-name: Boris
Enter password:
Connected.
The datasource shows up in the Jboss admin panel. I run a test connection, but it responds with:
Unexpected HTTP response: 500
Request
{
"address" => [
("subsystem" => "datasources"),
("data-source" => "OracleDS")
],
"operation" => "test-connection-in-pool"
}
Response
Internal Server Error
{
"outcome" => "failed",
"failure-description" => "JBAS010440: failed to invoke operation: JBAS010447: Connection is not valid",
"rolled-back" => true
}
And in the jboss console I found this:
Caused by: java.sql.SQLException: ORA-00604: error occurred at recursive SQL lev
el 1
ORA-12705: Cannot access NLS data files or invalid environment specified
but the solutions to that error I found on the internet didn't help.
What am I doing wrong?
The ORA-12705 error suggests that this might be a locale issue. You could try starting up JBoss with a locale that is supported by Oracle XE when converted into an NLS. For example, try adding this to your JBoss startup configuration (JAVA_OPTS variable in jboss-as/bin/run.conf):
-Duser.language=en -Duser.country=US
I need to have H2 in the classpath. I'm using these values :
# driver=org.h2.jdbcx.JdbcDataSource # it doesn't work
driver=org.h2.Driver # it doesnt work too...
url=jdbc:h2:tcp://localhost/~/mydb;AUTO_SERVER=TRUE
login=sa
password=
And I have declared datasource in my standalone.xml :
<datasource jndi-name="java:jboss/datasources/mydb" pool-name="mydb" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:tcp://localhost/~/mydb</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
</security>
<datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
And I have the default module.xml for H2 in JBoss A7.
But when registering the JDBC using this :
Class.forName(driver);
I get this exception :
java.lang.ClassNotFoundException: org.h2.jdbcx.JdbcDataSource
And the same for the other value :
java.lang.ClassNotFoundException: org.h2.Driver
Please can you help me get the solution?
Thank you a lot!
There is normally no need to register the driver, if your (web) application runs in an application server context. You just use the data source. The application server registers the driver for you, and that's why the driver's class is not necessarily visible to your application.
As for JBoss 7, the H2 driver is provided as a module. So if you really need to register it, you could declare a module dependency (in an .ear or in a .war deployment) by adding a jboss-deployment-structure.xml file.
References (regarding to module dependencies):
What's the module name if deploy jdbc in Jboss AS 7 as web application
Add an Explicit Module Dependency to a Deployment
I have the same problem and fixed when added this dependency in maven
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.199</version>
<scope>runtime</scope>
</dependency>
source