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.
Related
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 have deployed an EAR in Wildfly-8.2.0.Final application server. After some hours of inactivity, I am getting the below error:
Caused by: java.sql.SQLException - JZ0C0: Connection is already closed.
at com.sybase.jdbc4.jdbc.ErrorMessage.raiseError(Unknown Source)
at com.sybase.jdbc4.jdbc.SybConnection.checkConnection(Unknown Source)
at com.sybase.jdbc4.jdbc.SybConnection.setAutoCommit(Unknown Source)
at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.checkTransaction(BaseWrapperManagedConnection.java:893)
at org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransaction(WrappedConnection.java:1594)
at org.jboss.jca.adapters.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:398)
at com.test.it.TestConnection.prepareStatement(TestConnection.java:1045)
Please find below the datasource subsystem definition used in standalone-full-ha.xml.
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasources>
<datasource jta="true" jndi-name="java:/SybaseDB" pool-name="SybaseDB" enabled="true" use-java-context="true" spy="false" use-ccm="true">
<connection-url>jdbc:sybase:Tds:id_address:port/DBname</connection-url>
<driver-class>com.sybase.jdbc4.jdbc.SybDriver</driver-class>
<connection-property name="HOSTNAME">TestHost</connection-property>
<connection-property name="SQLINITSTRING">set quoted_identifier,forceplan off</connection-property>
<connection-property name="LANGUAGE">us_english</connection-property>
<connection-property name="CHARSET">iso_1</connection-property>
<connection-property name="APPLICATIONNAME">TestApp</connection-property>
<connection-property name="IS_CLOSED_TEST">select 1</connection-property>
<connection-property name="PACKETSIZE">1024</connection-property>
<driver>SybaseDB</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>5</min-pool-size>
<initial-pool-size>5</initial-pool-size>
<max-pool-size>200</max-pool-size>
<prefill>false</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<security-domain>EncryptDBPassword</security-domain>
</security>
<validation>
<check-valid-connection-sql>select 1</check-valid-connection-sql>
<use-fast-fail>true</use-fast-fail>
</validation>
<timeout>
<blocking-timeout-millis>15000</blocking-timeout-millis>
<idle-timeout-minutes>30</idle-timeout-minutes>
</timeout>
<statement>
<track-statements>false</track-statements>
</statement>
</datasource>
<drivers>
<driver name="SybaseDB" module="jdbc.jconn4"/>
</drivers>
</datasources>
</subsystem>
Could anyone please help me whether I am missing an attribute in datasource definition which gives me this error.
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 have this datasource configuration on my JBOSS AS 7 in standalone.xml:
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource jndi-name="java:jboss/MyJndiDS" pool-name="MyPoolDS" enabled="true" jta="true" use-java-context="false" use-ccm="true">
<connection-url>
jdbc:postgresql://192.168.2.125:5432/t_report
</connection-url>
<driver>
org.postgresql
</driver>
<transaction-isolation>
TRANSACTION_READ_COMMITTED
</transaction-isolation>
<pool>
<min-pool-size>
3
</min-pool-size>
<max-pool-size>
7
</max-pool-size>
<prefill>
true
</prefill>
<use-strict-min>
false
</use-strict-min>
<flush-strategy>
FailingConnectionOnly
</flush-strategy>
</pool>
<security>
<user-name>
my_user
</user-name>
<password>
my_pass
</password>
</security>
<statement>
<prepared-statement-cache-size>
32
</prepared-statement-cache-size>
</statement>
</datasource>
...
...
</datasources>
</subsystem>
And when I login and logout 7 times with one and the same user the next time i try to login I get Transaction not active error. How can I fix this? I don't want to increase the max-pool-size. Here is my logout method:
import javax.faces.context.ExternalContext;
#Inject ExternalContext ec;
public void validateUserLogOut() {
HttpServletRequest request = (HttpServletRequest)ec.getRequest();
request.getSession().invalidate();
this.setUserLoggedIn(false);
navigation.logout();
}
I think your issue is less the datasource (this only exposes it), but rather the fact that the login module seems to keep connections open and is not returning them into the pool.
Due to request of user503413 I will admit the mistake I've made with a disgrace: I have forgotten to close the connection after using it (connection.close()). If you don't close your connection it will not return it to the pool and since you've limited and reached the max-pool-size (7 in my case) no new connection is going to be created. So the lesson here is always be sure to close your connections. Also close your prepared statements or else you'll get a memory leak.