My java app deployed in jboss AS 7, queries a MS SQL server database using spring data. I also need to call a DB2 function on zOS for which I use Spring JdbcTemplate. The SQL is:
public String getUniqueId()
{
String sql = "SELECT " + schemaName + ".SGB_LON_ID_NEXT() FROM SYSIBM.SYSDUMMY1" ;
return (jdbcTemplate.queryForLong(sql));
}
Unit tests in Eclipse work fine.
When I deploy in the jboss server, the first call works.
However, the second transaction onwards, the call itself works, but a few warnings appear in the server.log for each call.
I wonder if it could be the fact that the JDBC call is NOT a part of the JPA transaction. (note that the jdbc call is a simple - the DB2 function just returns the next serial number for a field )
Here are the warning messages from the error stack:
21:50:33,955 WARN [org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory] (http-/127.0.0.1:8080-14)
Destroying connection that is not valid, due to the following exception: com.ibm.db2.jcc.t4.b#1167bd5: com.ibm.db2.jcc.am.SqlSyntaxErrorException:
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=<END-OF-STATEMENT>;MICROSECONDS MICROSECOND SECONDS SECOND MINUTES MIN, DRIVER=3.63.123
21:50:34,096 WARN [org.jboss.jca.core.connectionmanager.listener.TxConnectionListener] (http-/127.0.0.1:8080-14)
IJ000305: Connection error occured:org.jboss.jca.core.connectionmanager.listener.TxConnectionListener#f79f0f[state=NORMAL managed connection=org.jboss.jca.adapters.jdbc.local.LocalManagedConnection#136e43e connection handles=0 lastUse=1359255001136 trackByTx=false
pool=org.jboss.jca.core.connectionmanager.pool.strategy.PoolByCri#c2c2de pool internal context=SemaphoreArrayListManagedConnectionPool#8793c7[pool=DB2_zOS_DS]
xaResource=LocalXAResourceImpl#f70194[connectionListener=f79f0f connectionManager=112dadb warned=false currentXid=null] txSync=null]:
com.ibm.db2.jcc.am.SqlSyntaxErrorException:
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=<END-OF-STATEMENT>;MICROSECONDS MICROSECOND SECONDS SECOND MINUTES MIN, DRIVER=3.63.123
21:50:34,196 WARN [org.jboss.jca.core.connectionmanager.pool.strategy.PoolByCri] (http-/127.0.0.1:8080-14)
IJ000612: Destroying connection that could not be successfully matched: org.jboss.jca.core.connectionmanager.listener.TxConnectionListener#f79f0f[state=DESTROYED managed connection=
org.jboss.jca.adapters.jdbc.local.LocalManagedConnection#136e43e connection handles=0 lastUse=1359255001136 trackByTx=false
pool=org.jboss.jca.core.connectionmanager.pool.strategy.PoolByCri#c2c2de pool internal context=SemaphoreArrayListManagedConnectionPool#8793c7[pool=DB2_zOS_DS]
xaResource=LocalXAResourceImpl#f70194[connectionListener=f79f0f connectionManager=112dadb warned=false currentXid=null] txSync=null]
Any suggestions on how to fix?
I am not clear on how to add the JDBC call to the current transaction (JPA). Or should it be a separate transaction. As stated earlier the jdbc call is a db2 function that returns the next value for a sequence number.
The problem turned out to be in my datasource setup in JBOSS_HOME/standalone/configuration/standalone.xml.
In the validation section, I had this which was incorrect.
<validation>
<check-valid-connection-sql>select 1</check-valid-connection-sql>
<validation>
The above was incorrect and DB2 was giving a validation error.
I changed that to the following instead:
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ValidConnectionChecker"/>
<stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2StaleConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ExceptionSorter"/>
</validation>
Here is the complete datasource set up in case anybody else finds it useful.
<datasource jndi-name="java:jboss/datasources/DB2_zOS_DS" pool-name="DB2_zOS_DS" enabled="true" use-java-context="true">
<connection-url>jdbc:db2://MyHostName:MyPortNo/MyDBQA1:currentSchema=MySchemaQA1;</connection-url>
<driver>db2zOS</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>9</min-pool-size>
<max-pool-size>50</max-pool-size>
<prefill>true</prefill>
<allow-multiple-users/>
</pool>
<security>
<user-name>MY-APP-ID</user-name>
<password>My-APP-ID-PASSWORD</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ValidConnectionChecker"/>
<stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2StaleConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ExceptionSorter"/>
</validation>
<timeout>
<set-tx-query-timeout>true</set-tx-query-timeout>
<blocking-timeout-millis>500</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
</timeout>
<statement>
<track-statements>false</track-statements>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="db2zOS" module="com.ibm.db2">
<driver-class>com.ibm.db2.jcc.DB2Driver</driver-class>
</driver>
</drivers>
Related
In ActiveMQ classic ra.xml we have several definitions of Connection Factories.
There are the following, mentioned as Outbound(meaning used only for sending messages?), documented here:
<outbound-resourceadapter>
<connection-definition>
<managedconnectionfactory-class>org.apache.activemq.ra.ActiveMQManagedConnectionFactory</managedconnectionfactory-class>
<connectionfactory-interface>javax.jms.ConnectionFactory</connectionfactory-interface>
<connectionfactory-impl-class>org.apache.activemq.ra.ActiveMQConnectionFactory</connectionfactory-impl-class>
<connection-interface>javax.jms.Connection</connection-interface>
<connection-impl-class>org.apache.activemq.ra.ManagedConnectionProxy</connection-impl-class>
</connection-definition>
<connection-definition>
<managedconnectionfactory-class>org.apache.activemq.ra.ActiveMQManagedConnectionFactory</managedconnectionfactory-class>
<connectionfactory-interface>javax.jms.QueueConnectionFactory</connectionfactory-interface>
<connectionfactory-impl-class>org.apache.activemq.ra.ActiveMQConnectionFactory</connectionfactory-impl-class>
<connection-interface>javax.jms.QueueConnection</connection-interface>
<connection-impl-class>org.apache.activemq.ra.ManagedConnectionProxy</connection-impl-class>
</connection-definition>
<connection-definition>
<managedconnectionfactory-class>org.apache.activemq.ra.ActiveMQManagedConnectionFactory</managedconnectionfactory-class>
<connectionfactory-interface>javax.jms.TopicConnectionFactory</connectionfactory-interface>
<connectionfactory-impl-class>org.apache.activemq.ra.ActiveMQConnectionFactory</connectionfactory-impl-class>
<connection-interface>javax.jms.TopicConnection</connection-interface>
<connection-impl-class>org.apache.activemq.ra.ManagedConnectionProxy</connection-impl-class>
</connection-definition>
Additionally, I see a number of connection factories declared as admin objects:
<adminobject>
<adminobject-interface>javax.jms.ConnectionFactory</adminobject-interface>
<adminobject-class>org.apache.activemq.ActiveMQConnectionFactory</adminobject-class>
<config-property>
<config-property-name>brokerUrl</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
</adminobject>
<adminobject>
<adminobject-interface>javax.jms.ConnectionFactory</adminobject-interface>
<adminobject-class>org.apache.activemq.pool.XaPooledConnectionFactory</adminobject-class>
<config-property>
<config-property-name>brokerUrl</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
<config-property>
<config-property-name>tmFromJndi</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
</config-property>
</adminobject>
<adminobject>
<adminobject-interface>javax.jms.XAConnectionFactory</adminobject-interface>
<adminobject-class>org.apache.activemq.ActiveMQXAConnectionFactory</adminobject-class>
<config-property>
<config-property-name>brokerURL</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
</adminobject>
My question is what is the use of all these implementations?
Which one should be used from a consumer such as Message Driven Bean(MDB)?
I am migrating a WAS6 application to Liberty profile.
In my project I have a section which is not under global transaction and there I read a message from one queue and drop it into another.
For that I use a transacted queue session and at end of all I do a commit method call and for all exceptions I do a rollback.
Queue session:
QueueSession session = connection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
Exception:
com.ibm.msg.client.jms.DetailedIllegelStateException:JMSCC0014:It is not valid to call the 'commit' method on a nontransacted session
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessoImpl.java)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at com.ibm.msg.client.commonservices.j2se.NSLServices.createException(NSLServices.java)
at com.ibm.msg.client.commonservices.nls.NSLServices.createException(NSLServices.java)
at com.ibm.msg.client.jms.internal.JmsErrorUtils.createException(JmsErrorUtils.java)
at com.ibm.msg.client.jms.internal.JmsSessionImpl.commit(JmsSessionImpl.java)
at com.ibm.mq.jms.MQSession.commit(MQSession.java)
at com.ibm.mq.connector.outbound.SessionWrapper.commit(SessionWrapper.java)
at .....my package....JMSHelper.commit(JMSHelper.java)
at .......my code..........(myclass.java)
at ..............mycode............................
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor$ListenerWrapper.handleNotification(DefaultMBeanServerInterceptor.java)
at javax.management.NotificationBroadcasterSupport.handleNotification(NotificationBroadcasterSupport.java)
at javax.management.NotificationBroadcasterSupport$SendNotifJob.run(NotificationBroadcasterSupport.java)
at javax.management.NotificationBroadcasterSupport$1.execute(NotificationBroadcasterSupport.java)
at javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.java)
at javax.management.timer.Timer.sendNotification(Timer.java)
at javax.management.timer.TimernotifyAlarmClock(Timer.java)
at javax.management.timer.TimerAlarmClock.run(Timer.java)
at java.util.TimerThread.mainLoop(Timer.java)
at java.util.TimerThread.run(Timer.java)
JMSCC0014:It is not valid to call the 'rollback' method on a nontransacted session
QCF settings
<variable name="wmqJmsClient.rar.location" value="..\path\wmq.jmsra.rar">
<jmsQueueConnectionFactory id="qcfId" jndiName="jms/myQCF" >
<properties.wmqJms channel="mychannel" hostName="myhost" port="1234" queueManager="myQManager" />
</jmsQueueConnectionFactory>
Could you please advise.
We have oracle database and we need to push data to Oracle system via linked server using .Net windows application. there are more than one table to insert and we use transaction Scope to call each method to save data.
public void m1(){
try{
using(TranasctionScope scope = new TransactionScope()){
M1();
M2();
M3();
scope.complete();
}
}catch(exception ex){
throw ex;
}
}
Above M1(),M2() and M3() is used to insert data to oracle,But here i get error,
The operation could not be performed because OLE DB provider
"OraOLEDB.Oracle" for linked server "EBS_PREPROD" was unable to begin
a distributed transaction. OLE DB provider "OraOLEDB.Oracle" for
linked server "EBS_PREPROD" returned message "New transaction cannot
enlist in the specified transaction coordinator. ".
Can anyone solve this???? Thanks
I m using the local system to test session on windows azure. I have done the following config in web.config
<appSettings>
<!-- account configuration -->
<add key="TableStorageEndpoint" value="http://127.0.0.1:10002/devstoreaccount1/" />
<add key="BlobStorageEndpoint" value="http://127.0.0.1:10000/devstoreaccount1/" />
<add key="AccountName" value="devstoreaccount1" />
<add key="AccountSharedKey" value="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" />
<add key="DefaultMembershipTableName" value="Membership" />
<add key="DefaultRoleTableName" value="Roles" />
<add key="DefaultSessionTableName" value="Sessions" />
<add key="DefaultProviderApplicationName" value="ProviderTest" />
<add key="DefaultProfileContainerName" />
<add key="DefaultSessionContainerName" />
</appSettings>
<system.web>
<sessionState mode="Custom" customProvider="TableStorageSessionStateProvider">
<providers>
<clear />
<add name="TableStorageSessionStateProvider" type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider" />
</providers>
</sessionState>
</system.web>
but now i an getting the following error
Configuration Error Description: An
error occurred during the processing
of a configuration file required to
service this request. Please review
the specific error details below and
modify your configuration file
appropriately.
Parser Error Message: Exception has
been thrown by the target of an
invocation.
Source Error:
Line 39: Line 40:
Line 41: Line 42: Line
43:
Source File:
C:\Users\GizaKarthik\Desktop\SessionDemo\SessionDemo\SessionDemo_WebRole\web.config
Line: 41
Assembly Load Trace: The following
information can be helpful to
determine why the assembly
'Microsoft.WindowsAzure.StorageClient,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' could
not be loaded.
WRN: Assembly binding logging is
turned OFF. To enable assembly bind
failure logging, set the registry
value
[HKLM\Software\Microsoft\Fusion!EnableLog]
(DWORD) to 1. Note: There is some
performance penalty associated with
assembly bind failure logging. To turn
this feature off, remove the registry
value
[HKLM\Software\Microsoft\Fusion!EnableLog].
The reason for the exeption is that i used a corrupted dll. Download the additional c# examples from here . Find asp provides project edit the code in TableStorageSessionstateProvider
find this code
else
{
byte[] items = Convert.FromBase64String(reader.ReadLine());
byte[] statics = Convert.FromBase64String(reader.ReadLine());
int timeout = session.Timeout;
// Deserialize the session
result = DeserializeSession(items, statics, timeout);
}
replace the above code with this
else
{
try // Added try statement
{
// Read Items, StaticObjects, and Timeout from the file
byte[] items = Convert.FromBase64String(reader.ReadLine());
byte[] statics = Convert.FromBase64String(reader.ReadLine());
int timeout = session.Timeout;
// Deserialize the session
result = DeserializeSession(items, statics, timeout);
}
catch (Exception e) // Added catch statement
{
// Return an empty SessionStateStoreData
result = new SessionStateStoreData(new SessionStateItemCollection(),
SessionStateUtility.GetSessionStaticObjects(context),
session.Timeout);
}
}
Then compile and use the dll. It should work like a champ. happy coding!!
I've created a console application focused on C#3.5 and added a reference to System.Web, System.Configuration and Subsonic.Core. Also have in config file
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="UpdateCotswolds.Properties.Settings.Live_IntegraConnectionString" connectionString="Data Source=POSERVER;Initial Catalog=Live_Integra;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
I've then edited Settings.ttinclude
const string Namespace = "Integra.Data";
const string ConnectionStringName = "UpdateCotswolds.Properties.Settings.Live_IntegraConnectionString";
//This is the name of your database and is used in naming
//the repository. By default we set it to the connection string name
const string DatabaseName = "Live_Integra";
And dragged in the tt files.
When they run I'm getting the error...
Error 2 Running transformation: System.InvalidOperationException: Sequence contains more than one matching element
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at Microsoft.VisualStudio.TextTemplating47D0892A160210D689C6B90986A9AE0D.GeneratedTextTransformation.LoadTables() in c:\Programming\UpdateCotswolds\UpdateCotswolds\SQLServer.ttinclude:line 134
at Microsoft.VisualStudio.TextTemplating47D0892A160210D689C6B90986A9AE0D.GeneratedTextTransformation.TransformText() in c:\Programming\UpdateCotswolds\UpdateCotswolds\ActiveRecord.tt:line 23
at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result)
This is the line in question...
var pkColumn=tbl.Columns.SingleOrDefault(x=>x.Name.ToLower().Trim()==tbl.PrimaryKey.ToLower().Trim());
I'm guessing I'm making a silly mistake and hopefully someone can set me straight...
Thanks in advance...
It appears that a certain table has more than one primary key? Can you post your schema up?
Or maybe your PK and FK are names the exact same and SS is getting confused.
Maybe you can play around with the string[] ExcludeTables = new string[]{}; property found under "Settings.ttinclude" until it works and provide the schema for that one table.