I have upgraded sybase data base driver from jconn3.jar to jconn4.jar in my project. I get the below error when my application connects to Sybase data source. I have deployed my application on JBOSS 7 server.
[org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory] (default task-48) IJ030027: Destroying connection that is not valid, due to the following exception: com.sybase.jdbc4.jdbc.SybConnection#36d4f39c: com.sybase.jdbc4.jdbc.SybSQLException: dual not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output).
at com.sybase.jdbc4.tds.Tds.processEed(Tds.java:4131)
at com.sybase.jdbc4.tds.Tds.nextResult(Tds.java:3247)
at com.sybase.jdbc4.jdbc.ResultGetter.nextResult(ResultGetter.java:78)
at com.sybase.jdbc4.jdbc.SybStatement.nextResult(SybStatement.java:294)
at com.sybase.jdbc4.jdbc.SybStatement.nextResult(SybStatement.java:276)
at com.sybase.jdbc4.jdbc.SybStatement.executeLoop(SybStatement.java:2828)
at com.sybase.jdbc4.jdbc.SybStatement.execute(SybStatement.java:2815)
at com.sybase.jdbc4.jdbc.SybStatement.execute(SybStatement.java:1447)
at org.jboss.jca.adapters.jdbc.CheckValidConnectionSQL.isValidConnection(CheckValidConnectionSQL.java:74)
at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnectionFactory.isValidConnection(BaseWrapperManagedConnectionFactory.java:1272)
at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnectionFactory.getInvalidConnections(BaseWrapperManagedConnectionFactory.java:1085)
What does 'dual not found' in the error mean?
Can you please let me know what is the root cause of this issue and help to resolve it?
My data source configuration is shown below :
<datasource jta="false" jndi-name="java:/SybaseDS" pool-name="SybaseDS" enabled="true" use-ccm="false">
<connection-url>*********************</connection-url>
<driver-class>com.sybase.jdbc4.jdbc.SybDriver</driver-class>
<driver>sybase</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
</pool>
<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>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.sybase.SybaseExceptionSorter"/>
</validation>
<timeout>
<set-tx-query-timeout>false</set-tx-query-timeout>
<blocking-timeout-millis>0</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
<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>
I will resolved this issue by removing the connection validation query in the data source as shown below :
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
The dual table doesn't exist in Sybase database.
I'm working on the project where I'm trying to get the runtime statistics of my datasource connection pool which I placed into /deployment folder using Wildfly-9.
I searched for it and I found the configuration file which exist inside /standalone folder named as standalone.xml file giving me the statistics of datasource connection poool by using below code :
<datasource jta="true" jndi-name="java:jboss/datasources/DemoDS" pool-name="DemoDS" enabled="true" use-ccm="true" statistics-enabled="true">
<connection-url>jdbc:mysql://localhost:3306/demo?zeroDateTimeBehavior=convertToNull</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>mysql</driver>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>50</max-pool-size>
</pool>
<security>
<user-name>root</user-name>
<password>root</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>
Hit this url I got this:
http://localhost:9990/management/subsystem/datasources/data-source/DemoDS/statistics/pool?include-runtime=true
I get the following json string:
You get the following json string:
{
"ActiveCount":4,
"AvailableCount":48,
"AverageBlockingTime":0,
"AverageCreationTime":21,
"AverageGetTime":17,
"AveragePoolTime":195196,
"AverageUsageTime":43,
"BlockingFailureCount":0,
"CreatedCount":4,
"DestroyedCount":0,
"IdleCount":2,
"InUseCount":2,
"MaxCreationTime":47,
"MaxGetTime":47,
"MaxPoolTime":386185,
"MaxUsageTime":134,
"MaxUsedCount":4,
"MaxWaitCount":0,
"MaxWaitTime":0,
"TimedOut":0,
"TotalBlockingTime":0,
"TotalCreationTime":87,
"TotalGetTime":88,
"TotalPoolTime":780787,
"TotalUsageTime":217,
"WaitCount":0,
"XACommitAverageTime":0,
"XACommitCount":0,
"XACommitMaxTime":0,
"XACommitTotalTime":0,
"XAEndAverageTime":0,
"XAEndCount":0,
"XAEndMaxTime":0,
"XAEndTotalTime":0,
"XAForgetAverageTime":0,
"XAForgetCount":0,
"XAForgetMaxTime":0,
"XAForgetTotalTime":0,
"XAPrepareAverageTime":0,
"XAPrepareCount":0,
"XAPrepareMaxTime":0,
"XAPrepareTotalTime":0,
"XARecoverAverageTime":0,
"XARecoverCount":0,
"XARecoverMaxTime":0,
"XARecoverTotalTime":0,
"XARollbackAverageTime":0,
"XARollbackCount":0,
"XARollbackMaxTime":0,
"XARollbackTotalTime":0,
"XAStartAverageTime":0,
"XAStartCount":0,
"XAStartMaxTime":0,
"XAStartTotalTime":0,
"statistics-enabled":true
}
Since I have many datasource file I cannot place into individual standalone.xml file.
So anyone knows how I will get the runtime statistics of my datasource connection pool which I placed into /deployment folder?
From Wildfly CLI:
Check if stats enabled for datasource
/subsystem=datasources/data-source=(your datasourcename):read-attribute(name=statistics-enabled)
Enable stats: requires restart of Wildfly service afterwards
/subsystem=datasources/data-source=(your datasource):write-attribute(name=statistics-enabled, value=true)
After restart start CLI and run the check command again.
I am using multiple datasources in my java web-application.
Here is Wildfly configuration (standalone mode):
<datasource jta="false" jndi-name="java:jboss/datasources/DS1" pool-name="DS1" enabled="true" use-ccm="false">
<connection-url>URL1</connection-url>
<driver>ojdbc7</driver>
<security>
<user-name>login</user-name>
<password>password</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>
<datasource jta="false" jndi-name="java:jboss/datasources/DS2" pool-name="DS2" enabled="true" use-ccm="false">
<connection-url>URL2</connection-url>
<driver-class>org.h2.Driver</driver-class>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</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>
Jboss.xml in my ejb subproject:
<session>
<ejb-name>Bean1</ejb-name>
<resource-description>
<res-ref-name>DS1</res-ref-name>
<jndi-name>java:jboss/datasources/DS1</jndi-name>
</resource-description>
</session>
<session>
<ejb-name>Bean2</ejb-name>
<resource-description>
<res-ref-name>DS2</res-ref-name>
<jndi-name>java:jboss/datasources/DS2</jndi-name>
</resource-description>
</session>
In EJB Bean1/Bean2 datasources are called via
#Resource(name="DS1/DS2")
private DataSource dataSource;
....
Connection connection = dataSource.getConnection();
Using shown configuration I have faced following problems :
I can access datasource only if it is set as a default in <default-bindings> section of my standalone-full.xml. If it is empty, I get
"JBAS014771: Services with missing/unavailable dependencies"
pointing to the list of datasources used in beans during deployment.
If I set DS1 as a default one, next time DS2 is injected, it will contain
LocalManagedConnectionFactory
pointing to DS1 in dataSource.mcf variable
As I've understood from this topic
Why different persistence units with separated data sources query the same data source?
this problem may be caused by container-managed persistance.
But in given case I am not using any ORM. So I am only able to manipulate datasources using jndi and server configuration.
So is there any way I can resolve this situation by using some additional wildfly configuration / any manipulations with application or I have to use ORM and manage persistance by myself ?
Thanks for replies.
it's recommended to use an ORM (JPA in best case), so you will use entityManager and persitence.xml for using multiple data sources.
<persistence-unit name="DB1_PU">
<jta-data-source>java:jboss/datasources/ds1</jta-data-source>
</persistence-unit>
<persistence-unit name="DB2_PU">
<jta-data-source>java:jboss/datasources/ds2</jta-data-source>
</persistence-unit>
and you can call the DS like :
#PersistenceContext(unitName = "DB1_PU")
protected EntityManager entityManager1;
#PersistenceContext(unitName = "DB2_PU")
protected EntityManager entityManager2;
How to configure a JNDI datasource in jboss configuration file using HikariCP I can't find aything in the help contents of Hikari there is only Tomcat configuration .
I have a Spring webb app, I have a datasource defined inside the application and I want to move this to a JNDI datasource.
My datasource definition is:
<datasource jndi-name="java:jboss/datasources/mydatasource" pool-name="mydatasource" enabled="true" use-java-context="true">
<connection-url>jdbc:postgresql://localhost:5432/database</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<datasource-class>com.zaxxer.hikari.HikariDataSource</datasource-class>
<driver>postgresql</driver>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>10</max-pool-size>
</pool>
<security>
<user-name>user</user-name>
<password>password</password>
</security>
</datasource>
And the driver definition:
<driver name="postgresql" module="org.postgresql.jdbc">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
I'm getting this error among others:
ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "mydatasource")
]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/mydatasource is missing [jboss.jdbc-driver.postgresql]",
"jboss.data-source.java:jboss/datasources/mydatasource is missing [jboss.jdbc-driver.postgresql]"
]}
So what is the right way to configure this?
EDIT:
Following the guide to create the Tomcat resource and using the information provided in this question I have come to this DataSource definition:
<datasource jta="false" jndi-name="java:jboss/mydatasource" pool-name="mydatasource" enabled="true" use-ccm="false">
<connection-url>jdbc:postgresql://localhost:5432/databasename</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgresql</driver>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>10</max-pool-size>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>username</user-name>
<password>password</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>
I installed the postgresql driver in Jboss and declared it.
And in Spring configuration
...
#Bean
public DataSource dataSource() {
final JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
dataSourceLookup.setResourceRef(true);
DataSource dataSourceTemp = null;
try {
dataSourceTemp = dataSourceLookup.getDataSource("jdbc/mydatasource");
} catch (DataSourceLookupFailureException e) {
log.error("DataSource not found.");
}
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setDataSource(dataSourceTemp);
return new HikariDataSource(hikariConfig);
}
...
This code based on HikariJNDIFactory code,everything seems to work but I think I have to create a properties object with the properties of the connection what properties I have to include in the object?
Here is the configuration for a "pure" Tomcat JNDI DataSource:
https://github.com/brettwooldridge/HikariCP/wiki/JNDI-DataSource-Factory-(Tomcat,-etc.)
You might also find this answer Re: Spring + Tomcat + JNDI informative:
How to use JNDI DataSource provided by Tomcat in Spring?
Also recommended is the latest HikariCP 2.0.1.
I try to run a JBoss7x with a quite special XA configuration to enable FCF. I configured my datasource and stuff and want to start the application now. Unfortunately I get the following Exception:
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "javax/transaction/xa/XAResource"
at java.lang.Class.getDeclaredMethods0(Native Method) [rt.jar:1.7.0_25]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2521) [rt.jar:1.7.0_25]
at java.lang.Class.privateGetPublicMethods(Class.java:2641) [rt.jar:1.7.0_25]
JBoss has two different locations to load this special class or interface. the JEE6 jar and the jdk7 himself. Firstly WHY? And secondly, how to solve this Problem?
Here's the configuration of the datasource, but the problem is not related to the datasource. The main issue that this class present in two official oracle
<xa-datasource jta="true" jndi-name="java:/RedSheepOraDS" pool-name="RedSheepOraDSRem" enabled="true" use-java-context="true" use-ccm="true">
<xa-datasource-property name="URL">
jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=ON) (ADDRESS=(PROTOCOL=TCP)(HOST=node1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP) (HOST=node2)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=REDSHEEP_RAC.WORLD)))
</xa-datasource-property>
<xa-datasource-property name="ONSConfiguration">
nodes=node1:6200,node2:6200
</xa-datasource-property>
<xa-datasource-property name="MinPoolSize">
200
</xa-datasource-property>
<xa-datasource-property name="MaxPoolSize">
200
</xa-datasource-property>
<xa-datasource-property name="InactiveConnectionTimeout">
5
</xa-datasource-property>
<xa-datasource-property name="TimeToLiveConnectionTimeout">
5
</xa-datasource-property>
<xa-datasource-property name="AbandonedConnectionTimeout">
5
</xa-datasource-property>
<xa-datasource-property name="ConnectionWaitTimeout">
5
</xa-datasource-property>
<xa-datasource-property name="PropertyCycle">
900
</xa-datasource-property>
<xa-datasource-property name="ValidateConnectionOnBorrow">
true
</xa-datasource-property>
<xa-datasource-property name="ConnectionPoolName">
xaPool
</xa-datasource-property>
<xa-datasource-property name="FastConnectionFailoverEnabled">
true
</xa-datasource-property>
<xa-datasource-property name="ConnectionFactoryClassName">
oracle.jdbc.xa.client.OracleXADataSource
</xa-datasource-property>
<xa-datasource-class>oracle.ucp.jdbc.PoolXADataSourceImpl</xa-datasource-class>
<driver>ojdbc6.jar</driver>
<security>
<user-name>****</user-name>
<password>****</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.vendor.OracleValidConnectionChecker"/>
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
<stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.vendor.OracleStaleConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
</validation>
<timeout>
<blocking-timeout-millis>3000</blocking-timeout-millis>
<idle-timeout-minutes>1</idle-timeout-minutes>
</timeout>
</xa-datasource>
<drivers>
<driver name="ojdbc6.jar" module="com.oracle.db">
<xa-datasource-class>oracle.ucp.jdbc.PoolXADataSourceImpl</xa-datasource-class>
</driver>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
Thanks,
Mike
JBoss 7x does not appear to support the UCP connector as a managed connection pool. If you want to use UCP, you will have to manage the pool and jndi yourself.
Otherwise, use the oracle.jdbc.xa.client.OracleXADataSource as your driver class.