I'm migrating some projects from JBoss 6.4 to JBoss 7.2, these projects needs different datasources to configurate DB connections. I added the datasources to the JBoss server config file (standalone.xml):
<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 jndi-name="java:/jdbc/SCL" pool-name="SCL" enabled="true">
<connection-url>jdbc:oracle:thin:#someIP:somePort:RCBDDES</connection-url>
<driver>oracle</driver>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>5</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>user</user-name>
<password>pass</password>
</security>
</datasource>
<datasource jta="true" jndi-name="java:/jdbc/Oracle" pool-name="jdbc/dsOracle" enabled="true" use-ccm="true" statistics-enabled="false">
<connection-url>jdbc:oracle:thin:#someIP:somePort:RCBDDES</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>oracle</driver>
<pool>
<min-pool-size>25</min-pool-size>
<max-pool-size>35</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>user</user-name>
<password>pass</password>
</security>
<validation>
<check-valid-connection-sql>SELECT 1 FROM DUAL</check-valid-connection-sql>
<validate-on-match>false</validate-on-match>
<background-validation>true</background-validation>
<exception-sorter class-name="org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter"/>
</validation>
<timeout>
<set-tx-query-timeout>false</set-tx-query-timeout>
<blocking-timeout-millis>6000</blocking-timeout-millis>
<idle-timeout-minutes>1</idle-timeout-minutes>
<query-timeout>60</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>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<datasource jta="true" jndi-name="java:/jdbc/dsSQLServer" pool-name="jdbc/dsSQLServer" enabled="true" use-ccm="true">
<connection-url>jdbc:sqlserver://someIP:somePort;DatabaseName=name</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<driver>sqlserver</driver>
<pool>
<min-pool-size>25</min-pool-size>
<max-pool-size>35</max-pool-size>
</pool>
<security>
<user-name>user</user-name>
<password>pass</password>
</security>
<timeout>
<idle-timeout-minutes>1</idle-timeout-minutes>
</timeout>
<statement>
<track-statements>true</track-statements>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<datasource jta="true" jndi-name="java:/jdbc/dsSQLServerHH" pool-name="jdbc/dsSQLServerHH" enabled="true" use-ccm="true">
<connection-url>jdbc:sqlserver://someIP:somePort;DatabaseName=name</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<driver>sqlserver</driver>
<pool>
<min-pool-size>25</min-pool-size>
<max-pool-size>35</max-pool-size>
</pool>
<security>
<user-name>user</user-name>
<password>pass</password>
</security>
<timeout>
<idle-timeout-minutes>1</idle-timeout-minutes>
</timeout>
<statement>
<track-statements>true</track-statements>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="oracle" module="oracle.jdbc">
<driver-class>oracle.jdbc.OracleDriver</driver-class>
</driver>
<driver name="sqlserver" module="com.microsoft">
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
</driver>
</drivers>
</datasources>
The server starts without problems and I can execute store procedures used in the project, but I'm receiving constantly the following warning in the server console [ORA-12519] (even without making a request, only starting the server):
[#2020-05-21 17:25:12,983 WARN [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (JCA PoolFiller) IJ000610: Unable to fill pool: java:/jdbc/Oracle: javax.resource.ResourceException: IJ031084: Unable to create connection
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:345)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:352)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:287)
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1326) [ironjacamar-core-impl-1.4.11.Final-redhat-00001.jar:1.4.11.Final-redhat-00001]
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.fillTo(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1138) [ironjacamar-core-impl-1.4.11.Final-redhat-00001.jar:1.4.11.Final-redhat-00001]
at org.jboss.jca.core.connectionmanager.pool.mcp.PoolFiller.run(PoolFiller.java:97) [ironjacamar-core-impl-1.4.11.Final-redhat-00001.jar:1.4.11.Final-redhat-00001]
at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_191]
Caused by: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:419)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:536)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:321)
... 6 more
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:386)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1054)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:308)
... 11 more
#]
Can someone give me and advice?
It is obviously caused by the fact that the listener was not accepting connections, Could you connect your database through sqlplus? Also, you can navigate through the Jboss admin console/localhost:9990 by default/ and click test connection button to check your configuration. Maybe your database client version and DB version are not compatible. You may have connection leak that means there is no room for your pool size of respective datasource or at the database. And check out this link http://www.dba-oracle.com/sf_ora_12519_tns_no_appropriate_service_handler_found.htm
Related
I am using WildFly 11, I am trying to understand when we configure a data source with a specific driver and we don't set the data source class name explicitly, which actual implementation of javax.sql.DataSource does WF ends up using ?
<datasource jndi-name="java:jboss/datasources/myDB" pool-name="myDB" enabled="true" use-java-context="true" spy="false">
<connection-url>jdbc:mysql://localhost:3306/db?useUnicode=true&characterEncoding=utf8&useSSL=false</connection-url>
<driver>mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>2</min-pool-size>
<max-pool-size>5</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>root</password>
</security>
<validation>
<check-valid-connection-sql>select 1</check-valid-connection-sql>
<validate-on-match>false</validate-on-match>
<background-validation>true</background-validation>
<background-validation-millis>10000</background-validation-millis>
</validation>
</datasource>
my application certainly works and I can see the interaction with the DB just fine, however I am not sure which actual datasource implementation is in use, I tried to configure a logger against MySQL packages that contains the default data sources, but nothing seems to get logged as a result.
WildFly is using ironjacamar (http://www.ironjacamar.org/) as its datasource implementation.
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>
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>
I'm reading the examples from here, and I found an interesting piece:
<datasources>
<datasource jndi-name="java:jboss/PostgresDS" pool-name="PostgresDS">
<connection-url>jdbc:postgresql://localhost:5432/postgresdb</connection-url>
<driver>postgresql</driver>
<security>
<user-name>admin</user-name>
<password>admin</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"></valid-connection-checker>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"></exception-sorter>
</validation>
</datasource>
<drivers>
<driver name="postgresql" module="org.postgresql">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
It's not a xa-datasource, but the driver is declaring a xa-datasource-class apontando using org.postgresql.xa.PGXADataSource.
Why not use org.postgresql.Driver? What are the diferences? And why not use driver-class instead of xa-datasource-class?
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&useUnicode=yes&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&useUnicode=yes&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>