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/
Related
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
I am using wildfly 8.2 and oracle 11g and I have my connection pool flushing an invalid connection and creating a new one if possible. I'm using Spring and Hibernate at the back-end too (we are looking up the connection via JNDI)
I could not find a concise example of pool configuration for oracle on the net that I could get to work, so I cribbed bits and bobs from various sources and managed to get it working.
My question is this. I am setting "Validate On Match" equal to true, but the Jboss documention (https://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/beta500/html/ch13s13.html) states that
<validate-on-match> - Prior to JBoss 4.0.5, connection validation occurred when the JCA layer attempted to match a managed connection. With the addition of <background-validation> this is no longer required. Specifying <validate-on-match> forces the old behavior. NOTE: this is typically NOT used in conjunction with <background-validation>
I would not like to use "old behaviour" if I can avoid it. Does anyone have an example of auto recovering connection pools with Oracle 11g Wildfly 8.2. and using the ojdbc6 driver.
Thanks
Btw my current set up for the pool is as below (nb I know I have the pool size set to 1, it was so I could easily kill the session and know the pool recovers).
<datasource jta="true" jndi-name="java:/jboss/datasources/mydatabase" pool-name="mydatabase" enabled="true" use-ccm="true">
<connection-url>jdbc:oracle:thin:#localhost:1521:mydatabase</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>ojdbc6-11.1.0.7.0.jar</driver>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>1</max-pool-size>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>mydatabase</user-name>
<password>mydatabase</password>
</security>
<validation>
<check-valid-connection-sql>SELECT 1 FROM DUAL</check-valid-connection-sql>
<validate-on-match>true</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>0</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>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
</datasources>
Cheer to anyone that can help
Try this validation node:
<validation>
<background-validation>true</background-validation>
<background-validation-millis>200000</background-validation-millis>
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
</validation>
Remember to adjust the value of background-validation-millis.
I am using jboss 7.0 for web application. In standalone.xml file, I have defined datasource as ,
<datasource jndi-name="java:jboss/datasources/finacpacds" pool-name="ltmscompanyadmindspool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>
jdbc:mysql://localhost:3306/finacpac?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
</connection-url>
<driver>
mysqldriver
</driver>
<transaction-isolation>
TRANSACTION_READ_COMMITTED
</transaction-isolation>
<pool>
<min-pool-size>
10
</min-pool-size>
<max-pool-size>
50
</max-pool-size>
<prefill>
true
</prefill>
<use-strict-min>
false
</use-strict-min>
<flush-strategy>
FailingConnectionOnly
</flush-strategy>
</pool>
<security>
<user-name>
root
</user-name>
<password>
</password>
</security>
<validation>
<validate-on-match>
false
</validate-on-match>
<background-validation>
false
</background-validation>
<useFastFail>
false
</useFastFail>
</validation>
<statement>
<prepared-statement-cache-size>
100
</prepared-statement-cache-size>
<share-prepared-statements/>
</statement>
</datasource>
Now my question is can i see the number of connection pools created when jboss is running by system.out.print statement. Is there any way to do this.
You cannot print out that info to System.out. You can read datasource statistics via CLI:
/subsystem=datasources/data-source=ltmscompanyadmindspool/statistics=pool:read-resource(include-runtime=true)
/subsystem=datasources/data-source=ltmscompanyadmindspool/statistics=jdbc:read-resource(include-runtime=true)
You can read more about statistics here.
On a side note, your datasource configuration is a bit concerning. Why would you have the validations disabled? If you do this then when there is an outage or a restart of the database server JBoss won't be able to validate/refresh the connections without a restart of the JBoss server.
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 am using jboss7.0.2 final with Oracle 11. Currently I am facing one issue which happens randomly. But during heavy load this error trace keeps growing. Tried so many approaches couldn't succeed.
MyDatasource Config:
<?xml version="1.0" encoding="UTF-8"?>
<datasource jndi-name="sportPool" pool-name="sportPool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:oracle:thin:#10.11.252.200:1521:sportsdb</connection-url>
<driver>oracleDriver</driver>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>75</max-pool-size>
<prefill>false</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>mportal</user-name>
<password>mobile</password>
</security>
<timeout>
<idle-timeout-minutes>60000</idle-timeout-minutes>
</timeout>
</datasource>
StackTrace:
nested exception is java.sql.SQLRecoverableException: Closed Connection
at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.translate(SQLExceptionSubclassTranslator.java:82)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:237)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:604)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:638)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:667)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:683)
... 50 more
Caused by: java.sql.SQLRecoverableException: Closed Connection
at oracle.jdbc.driver.OracleStatement.ensureOpen(OracleStatement.java:4051)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3563)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3628)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1493)
at org.jboss.jca.adapters.jdbc.CachedPreparedStatement.executeQuery(CachedPreparedStatement.java:111)
at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:462)
at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:645)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:588)
... 56 more
Take a look at your database settings - it's possible, that the timeout set in database is shorter than the timeout set in datasource deployment descriptor, and the database closes the connections.
Check your network - it's possible that there is something wrong with your firewall / routing settings, and the connections are closed/dropped somewhere in the middle of the route.
Take a look at this link JBoss 7 Datasource Configuration. There is a way of configuring a datasource descriptor, forcing the JBoss to check the connection when checking it out from the pool. Use the valid-connection-checker (faster) or check-valid-connection-sql (slower) setting and set the
<valid-connection-checker>
org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker
</valid-connection-checker>
or
<check-valid-connection-sql>
SELECT 1 FROM DUAL
</check-valid-connection-sql>
A quick update on how I fixed this issue.
I've done following changes outside of the application i.e in JBOSS
**ironjacamar-jdbc**
Updateed ironjacamar-jdbc jar from 1.0.3 to 1.1.0 at this location "{JBOSS_HOME_7.0.2}/modules/org/jboss/ironjacamar/jdbcadapters/main/"
Stanalone.xml
As suggested by npe added <check-valid-connection-sql>.
<datasource jndi-name="sportPool" pool-name="sptPool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>
jdbc:oracle:thin:#10.11.252.200:1521:sprtsdb
</connection-url>
<driver>
oracleDriver
</driver>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>90</max-pool-size>
<prefill>false</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>mtal</user-name>
<password>mle</password>
</security>
<validation>
<check-valid-connection-sql>SELECT 1 FROM DUAL</check-valid-connection-sql>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
<use-fast-fail>false</use-fast-fail>
</validation>
<timeout>
<idle-timeout-minutes>15</idle-timeout-minutes>
</timeout>
</datasource>
This solved the problem. But jboss prints warning message "IJ000612" in console which I think should be ok as long as application is getting valid connection object from jboss.
Seems like your are losing connection, in most cases this happens when there network problems. The configuration you are using is a bit strange;
idle-timeout-minutes = 41 days , default is 15 minutes
min-pool-size = 1
probably the idle-timeout-minutes causing your SQLRecoverableExceptions, I would use a config like;
idle-timeout-minutes = 15 minutes
min-pool-size = 10
max-pool-size = 50 or even less You are using 150MB memory for 75 connections
if you don't have long blocking connection to the database 20 max pool size should be enough.