Configuration of XA dataSources on Jboss eap 6.4 with sql server - sql-server-2005

I have configured the XA-datasources on sql server by the following ways:
https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6/html/Administration_and_Configuration_Guide/Example_Microsoft_SQLServer_XA_Datasource.html
enter code here
<datasources>
<xa-datasource jndi-name="java:/jdbc/MyDataSource" pool-name="SQLServerPool">
<driver>sqlserver</driver>
<xa-datasource-property name="ServerName">localhost</xa-datasource-property>
<xa-datasource-property name="DatabaseName">mydb</xa-datasource-property>
<xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
<security>
<user-name>admin</user-name>
<password>admin</password>
</security>
<xa-pool>
<is-same-rm-override>false</is-same-rm-override>
</xa-pool>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"></valid-connection-checker>
</validation>
</xa-datasource>
<drivers>
<driver name="sqlserver" module="com.microsoft">
<xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
And enabled XA transaction database side by following
https://technet.microsoft.com/en-us/library/aa342335%28v=sql.105%29.aspx
But the Database I have been using for my project is not a master database .Since XA-transactions are enabled on master, by default data is taking from master db and not from my database.
Is it that I need to configure XA-transactions on "my database" for the problem to be resolved?
How to give the server name under inorder to fetch from "my database "
My loginUserName is the owner of both master schema and "mydatabase" schema and have created Role SqlJDBCXA user both in master and "mydatabase".
Referred the following but couldnot help
Exception with MS-SQL Server,JDBC and XA Transactions
I'm using sqljdbc4.jar and driver class is "com.microsoft.sqlserver.jdbc.SQLServerDriver"
The JDBC jar is being detected in the jboss Management console and when i test it ,i'm getting the following error:
"failed to create JDBC connection.There are no running servers bound to this datasource"
Can anyone Suggest?
ThankYou

Related

JNDI lookup error for name: java:comp/env/jdbc/DynaPropDB

Am getting below error while starting the liberty server:
[ERROR ]
com.it.properties.PropertyResourceException for user [UnKnown] self logged on Jan 23, 2019 12:43:12 PM.
Exception instance reference code [13EE91EC-BCA0-49C1-7ABC-5F537ABC5F53].
I have DynaPropAdminWeb Access for the application
Correctly placed lookup-name and binding-name in web.xml file and ibm-web-bnd.xml file
It would be helpful if you provide the relevant web.xml, ibm-web-bnd.xml, and server.xml config snippets for the resource reference and data source. Absent that, taking your word that the deployment descriptor and binding file are correct, then the problem will be in the server config, either in incorrectly specifying the dataSource/jdbcDriver/library or with feature enablement. A common mistake in Liberty is forgetting to enable the jndi-1.0 feature (which is needed for JNDI lookups) alongside the jdbc-4.x feature. In case that is the problem, here is an example,
<server>
<featureManager>
<feature>jdbc-4.2</feature>
<feature>jndi-1.0</feature>
<feature>servlet-4.0</feature>
</featureManager>
<dataSource jndiName="jdbc/DynaPropDB">
<jdbcDriver libraryRef="jdbcLib"/>
<properties serverName="localhost" portNumber="1234" databaseName="exampleDB"/>
</dataSource>
<library id="jdbcLib">
<file name="C:/drivers/jdbc/myJdbcDriver.jar"/>
</library>
</server>
Also, here is a link to a knowledge center page with configuration examples for various commonly-used databases.

Configuring a xa-datasource(Wildfly) in HA mode with a Postgresql JDBC driver

After many attempts, it seems that the combination xa-datasource <-> postgres driver does not support a failover configuration with non default port(5432).
I guess, that the driver does not implements all methods expected by xa.
I'd be glad if somebody can show me that I'm wrong about that...
This example is working, but use the default port:
<xa-datasource jndi-name="java:/Foo" pool-name="Foo" enabled="true" use-ccm="true" statistics-enabled="true">
<xa-datasource-property name="url">
jdbc:postgresql://server1,server2/db_name
</xa-datasource-property>
<xa-datasource-property name="ApplicationName">
MyApp
</xa-datasource-property>
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
<driver>postgresql-jdbc4</driver>
<url-delimiter>,</url-delimiter>
<xa-pool>
<min-pool-size>6</min-pool-size>
<max-pool-size>40</max-pool-size>
<prefill>true</prefill>
<is-same-rm-override>false</is-same-rm-override>
<interleaving>false</interleaving>
<pad-xid>false</pad-xid>
<wrap-xa-resource>false</wrap-xa-resource>
</xa-pool>
<security>
<user-name>foo</user-name>
<password>blah</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<blocking-timeout-millis>3000</blocking-timeout-millis>
<idle-timeout-minutes>60</idle-timeout-minutes>
</timeout>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</xa-datasource>
For Oracle database you can use below configuration.
jdbc:oracle:thin:#(description=(connect_timeout=5)(address_list=(load_balance=on)(failover=on) (address=(protocol=tcp)(host= server1)(port=1521)) (address=(protocol=tcp)(host= server2)(port=1521)) )(connect_data=(service_name=xyzabc)))
This might be late reply but it might help someone who is looking for postgres xa-datasource configuration.
First of all you need to install postgre driver in Wildfly modules then do the configuration.
You can install it via command line using subsystems or set postgresql(enterprise) driver name as "org.edb.Driver" for enterprise driver. Place edb-jdbc17.jar under WILDFLY_HOME\modules\system\layers\base\org\edb\main directory with module.xml.
Some of the drivers does not have getURL() method implemented in their datasource classes. So, we have to specify datasource configuration differently for them.
Postgres does not have getURL method. So, we will specify properties like this in our stanalone.xml/domain.xml file.
<xa-datasource-property name="ServerName">DatabaseHostName</xa-datasource-property>
<xa-datasource-property name="PortNumber">DatabasePortName</xa-datasource-property>
<xa-datasource-property name="DatabaseName">DatabaseName</xa-datasource-property>
<xa-datasource-class>com.edb.xa.PGXADataSource</xa-datasource-class>
<driver>postgresql</driver>
<xa-pool>
<min-pool-size>5</min-pool-size>
<initial-pool-size>5</initial-pool-size>
<max-pool-size>30</max-pool-size>
<use-strict-min>true</use-strict-min>
<is-same-rm-override>false</is-same-rm-override>
<no-tx-separate-pools>true</no-tx-separate-pools>
</xa-pool>
<security>
<user-name>database.username</user-name>
<password>database.password</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>
<background-validation>true</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
</validation>

How do I set the JDBC driver's securityMechanism property with TLS_CLIENT_CERTIFICATE_SECURITY option on Liberty?

I tried to set the JDBC driver's securityMechanism property with the TLS_CLIENT_CERTIFICATE_SECURITY option on Websphere Liberty® referring to the following IBM® Knowledge Center, but got a CWWKG0032W warning message when I started Websphere Liberty (beta for July 2015).
Can you show me how to set the JDBC driver's securityMechanism property with the TLS_CLIENT_CERTIFICATE_SECURITY option on Websphere Liberty?
IBM Data Server Driver for JDBC and SQLJ support for certificate authentication
The IBM® Data Server Driver for JDBC and SQLJ provides support for
client support for certificate authentication for connections to DB2®
for z/OS® Version 10 or later data servers.
console.log when the Websphere Liberty Server started
CWWKG0032W: Unexpected value specified for property
[securityMechanism], value = [18]. >Expected value(s) are:
[3][4][7][9][11][12][13][15][16].
securityMechanism="18" is TLS_CLIENT_CERTIFICATE_SECURITY, I confirmed the value by the following:
\>javac -classpath .;db2jcc4.jar; JDBCCheck
\>java -classpath .;db2jcc4.jar; JDBCCheck
TLS_CLIENT_CERTIFICATE_SECURITY: 18
JDBCCheck class:
class JDBCCheck{
public static void main(String args[]){
com.ibm.db2.jcc.DB2SimpleDataSource dataSource =
new com.ibm.db2.jcc.DB2SimpleDataSource();
System.out.println( "TLS_CLIENT_CERTIFICATE_SECURITY: "
+ dataSource.TLS_CLIENT_CERTIFICATE_SECURITY);
}
}
server.xml:
<library id="db2-library">
<fileset dir="lib" id="db2-fileset" includes="db2jcc4.jar db2jcc_license_cu.jar"/>
</library>
<dataSource id="db2" jndiName="jdbc/sampledb">
<jdbcDriver libraryRef="db2-library"/>
<properties.db2.jcc databaseName="SAMPLEDB" password="password" portNumber="10443"
serverName="XX.XX.XX.XX" user="db2inst1" sslConnection="true"
sslTrustStoreLocation="ssld/defaultTrustStore"
sslTrustStorePassword="trustpassword" securityMechanism="18"/>
</dataSource>
Update 01:
db2jcc4.jar level/version is DB2 10.5FP1.
Websphere Liberty started without the CWWKG0032W warning when I used the generic JDBC driver properties properties instead of DB2® JCC properties properties.db2.jcc
Based on this topic in IBM® Knowledge Center:
Java EE Full Platform 7.0 section: transaction > dataSource > properties.db2.jcc
Currently WebSphere Liberty only supports the following values for securityMechanism:
value="3" name="CLEAR_TEXT_PASSWORD_SECURITY"
value="4" name="USER_ONLY_SECURITY"
value="7" name="ENCRYPTED_PASSWORD_SECURITY"
value="9" name="ENCRYPTED_USER_AND_PASSWORD_SECURITY"
value="11" name="KERBEROS_SECURITY"
value="12" name="ENCRYPTED_USER_AND_DATA_SECURITY"
value="13" name="ENCRYPTED_USER_PASSWORD_AND_DATA_SECURITY"
value="15" name="PLUGIN_SECURITY"
value="16" name="ENCRYPTED_USER_ONLY_SECURITY"
If you would like to have TLS_CLIENT_CERTIFICATE_SECURITY added as a securityMechanism in Liberty, I would recommend opening an RFE so that Liberty development is aware of the demand for supporting this.
Update:
To work around this, you can still specify securityMechanism="18", but just do so in a generic <properties> element as opposed to the db2 specific <properties.db2.jcc> element (which it looks like you have figured out already).
Another way of setting TLS_CLIENT_CERTIFICATE_SECURITY is:
com.ibm.db2.jcc.DB2SimpleDataSource dataSource = new
com.ibm.db2.jcc.DB2SimpleDataSource();
dataSource.setSecurityMechanism
(com.ibm.db2.jcc.DB2BaseDataSource.TLS_CLIENT_CERTIFICATE_SECURITY);
Check this IBM® Knowledge Center for more info:
IBM Data Server Driver for JDBC and SQLJ support for certificate authentication
This should work with both Websphere Full Profile and Websphere Liberty Profile.
Here is the code to set the security mechanism with user id and encrypted password to make DB2 connection. pass the user name, password and url string.
Properties properties = new Properties(); // Create a Properties object
properties.put("user", user); // Set user ID for the connection
properties.put("password", password); // Set password for the connection
properties.put("securityMechanism",
new String("" +
DB2BaseDataSource.ENCRYPTED_USER_AND_PASSWORD_SECURITY +
""));
// Set security mechanism to
// user ID and encrypted password
properties.put("encryptionAlgorithm", "2");
Connection connection = DriverManager.getConnection("jdbc:db2://" + url, properties);

WSO2 - MSSQL causes error for commits

When configuring WSO2 API Manager version 1.5.0 to use SQL Server as my database the instructions at:
http://docs.wso2.org/display/AM150/Setting+up+with+MS+SQL
For step 1 for Setup Configuration File, they tell you to update the master-datasources.xml file to match their example.
After updating and starting the API Manager, I got the following error in the logs:
ERROR {org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO} - Failed to rollback getting user ratings {org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO}
java.sql.SQLException: commit() should not be called while in auto-commit mode.
We tried a couple of things. First we disabled auto-commit on our SQL Server (2008r2).
That did not help and the error continued. After researching jdbc connections at: http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html
I discovered that a setting for:
<defaultAutoCommit>false</defaultAutoCommit>
was needed for each database definition in master-datasources.xml
For example:
<datasource>
<name>WSO2_CARBON_DB</name>
<description>The datasource used for registry and user manager</description>
<jndiConfig>
<name>jdbc/WSO2CarbonDB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<defaultAutoCommit>false</defaultAutoCommit>
<url>jdbc:jtds:sqlserver://server:port/db_name</url>
<username>user</username>
<password>pwd</password>
<driverClassName>net.sourceforge.jtds.jdbc.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>
The documentation from WSO2 does not reference this setting that I have found. It 'might' set it correctly when using the ../carbon admin site for your product.

Infinispan Cluster

I need to form a infinispan cluster in distributed mode. This cache is used for storing session data. Currently I am using tomcatInfinispanSessionManager developed by Manik from Jboss team.
I have created the infinispan xml in distributed mode and using two tomcats for testing. Using apache as a load balancer. Each machine has its own copy of infinispan cache entry. When any of the tomcat is shut down the session is retrieved from other infinispan cache.
My question is: how to make this cache entry into an infinispan server (either using hotrod/memcached) that is running on a separate machine?
If you add a remote cache loader to the cache configuration you have, it'll back up the data in a remote Hot Rod server, assuming you configure the IP:Port address of the Hot Rod server(s) correctly.
However, if you're trying to cluster your session data, I'd highly recommend you download JBoss EAP 6.1, which comes with Infinispan-based cluster-ready session data storage out of the box. The session cache can still be configured with a remote cache loader too, but the configuration will be slightly different since it uses JBoss EAP configuration format.
I am using ispn 5.1 version and started the server in hotrod mode. My cache config xml is as follows.
<?xml version="1.0" encoding="UTF-8"?>
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:5.3 http://www.infinispan.org/schemas/infinispan-config-5.3.xsd
urn:infinispan:config:remote:5.3 http://www.infinispan.org/schemas/infinispan-cachestore-remote-config-5.3.xsd"
xmlns="urn:infinispan:config:5.3" xmlns:remote="urn:infinispan:config:remote:5.3">
<global>
<transport clusterName="tomcatSession">
<properties>
<property name="configurationFile"
value="E:/Software/apache-tomcat-7.0.34/conf/jgroups.xml">
</property>
</properties>
</transport>
<globalJmxStatistics enabled="true" />
</global>
<namedCache name="tc_session_ispn-sess-mgr">
<clustering mode="distribution">
<l1 enabled="true" lifespan="600000" />
</clustering>
<loaders>
<remoteStore xmlns="urn:infinispan:config:remote:5.3"
fetchPersistentState="false" ignoreModifications="false"
purgeOnStartup="false" remoteCache="myCache" rawValues="true">
<servers>
<server host="10.145.4.172" port="11222" />
</servers>
<connectionPool maxActive="10" exhaustedAction="CREATE_NEW" />
<async enabled="true" />
</remoteStore>
</loaders>
</namedCache>
</infinispan>
While using this cache config xml I am gettong the following exception
Exception in thread "main" org.infinispan.config.ConfigurationException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[39,104]
Message: Unexpected element '{urn:infinispan:config:remote:5.3}remoteStore' encountered
at org.infinispan.configuration.parsing.Parser.parse(Parser.java:168)
at org.infinispan.configuration.parsing.Parser.parse(Parser.java:130)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:368)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:340)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:327)
Kindly correct me if I am wrong and suggest how to proceed further?