Bug 1002518

Summary: Generic resource adapter doesn't allow to use XAConnectionFactory instances of TIBCO EMS for non-transaction operations
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Vladimir Rastseluev <vrastsel>
Component: JCA, Documentation, JMSAssignee: Jeff Mesnil <jmesnil>
Status: CLOSED WONTFIX QA Contact: Vladimir Rastseluev <vrastsel>
Severity: unspecified Docs Contact: Russell Dickenson <rdickens>
Priority: unspecified    
Version: 6.1.1CC: jkudrnac, jpederse, mnovak, ochaloup, pslavice, smumford, twells
Target Milestone: ---Keywords: Reopened
Target Release: EAP 6.3.0Flags: smumford: needinfo-
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Known Issue
Doc Text:
In this release of JBoss EAP 6, when a session is created in a transaction context like: `connection.createSession(false,0);` an `IllegalArgumentException` occurs. This is because generic RA does not ignore parameters passed to createSession where first sets session not transacted and second to mode transacted session (0). To avoid this issue, create a transacted session: `connection.createSession(true,0);`.
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-04 13:21:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1082617    
Bug Blocks:    
Attachments:
Description Flags
patch none

Description Vladimir Rastseluev 2013-08-29 11:33:05 UTC
Created attachment 791725 [details]
patch

Description of problem:
During TIBCO EMS certification we use generic resource adapter(https://github.com/jbertram/generic-jms-ra). Sometimes in test case we need to use XAConnectionFactory instance for non-transaction environement or operation. Current version of generic RA doesn't allow this both for inbound and outgoing connections.

Version-Release number of selected component (if applicable):
EAP 6.1.1.ER7

How reproducible:
easy

Steps to Reproduce:
inbound:
try to use MDB with no transaction support and XAConnectionFactory for endpoint activation. Due to TIBCO EMS implementation you'll get  e.g. java.lang.ClassCastException: com.tibco.tibjms.naming.TibjmsFederatedXAConnectionFactory cannot be cast to javax.jms.ConnectionFactory

outgoing:
when XAConnectionFactory is used for message delivery, resource adapter always returns transactional session, even if we try to get non-transactional one.
 
Both problems lead to TCK tests failures.

Please, make appropriate changes in resource adapter code.
Applied patch can be used to fix this issue.

Comment 1 Vladimir Rastseluev 2013-08-30 08:49:39 UTC
Please, don't apply patch. Seems, that MDBs don't work correctly this way. But we still need a fix to use XAConnections in non-transactional operations.

Comment 2 Jeff Mesnil 2013-09-04 14:46:34 UTC
which tck tests highlight this issue?

Comment 4 Vladimir Rastseluev 2013-09-05 05:29:42 UTC
I changed a bit configuration in com.sun.ts.tests.jms.ee.all.queuetests to pass this test (you can see it in setup script as #workaround). 
To pass MDB tests I changed RA code. Original RA fails on MDB deployment.

Comment 5 Miroslav Novak 2013-11-12 09:39:17 UTC
This issue does not appear now. Vladmir can you point out what was changed, please?

Thanks,

Mirek

Comment 6 Jeff Mesnil 2013-11-12 09:41:13 UTC
Mirek, the generic JMS RA has been updated  to 1.0.1.Final with a fix for this issue:

https://github.com/jms-ra/generic-jms-ra/commit/b2d96fe15168d07c2debb2c23c42b93de1aec4ea

Comment 7 Miroslav Novak 2013-11-12 10:54:50 UTC
Thanks Jeff for info. Setting bz as verified since related TCK tests are passing.

Comment 8 Miroslav Novak 2014-03-25 15:40:57 UTC
Re-opening. Fix for this issue was reverted in tag 1.0.3.Final to fix bz#1033008. 

This is more problem on Tibco side as their XAConnectionFactory does not extend ConnectionFactory. See related jiras. [1][2] Problem is that this will be hard requirement in JMS 2.0 spec and we should try to handle this case.

Following TCK tests fail because of it:
com/sun/ts/tests/jms/ee/mdb/xa/MDBClient.java#Test4	
com/sun/ts/tests/jms/ee/mdb/xa/MDBClient.java#Test5	
com/sun/ts/tests/jms/ee/mdb/xa/MDBClient.java#Test6	
com/sun/ts/tests/jms/ee/mdb/xa/MDBClient.java#Test8	
com/sun/ts/tests/jms/ee/mdb/xa/MDBClient.java#Test9

@Jeff 
In server log this is exception:
11:07:40,060 ERROR [org.jboss.resource.adapter.jms.inflow.JmsActivation] (default-threads - 1) Unable to reconnect org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@33935a68(ra=org.jboss.resource.adapter.jms.JmsResourceAdapter@75c5f1fb destination=TCK.Q3 destinationType=javax.jms.Queue acknowledgeMode=Auto-acknowledge subscriptionDurability=false reconnectInterval=10 reconnectAttempts=-1 user=null maxMessages=1 minSession=1 maxSession=15 connectionFactory=XACF jndiParameters={java.naming.provider.url=tcp://dev134.mw.lab.eng.bos.redhat.com:7222, java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory}): java.lang.ClassCastException: com.tibco.tibjms.naming.TibjmsFederatedXAConnectionFactory cannot be cast to javax.jms.ConnectionFactory
	at org.jboss.resource.adapter.jms.inflow.JmsActivation.setupConnection(JmsActivation.java:428) [generic-jms-ra-jar-1.0.2.Final.jar:1.0.3.Final-SNAPSHOT]
	at org.jboss.resource.adapter.jms.inflow.JmsActivation.setupConnection(JmsActivation.java:398) [generic-jms-ra-jar-1.0.2.Final.jar:1.0.3.Final-SNAPSHOT]
	at org.jboss.resource.adapter.jms.inflow.JmsActivation.setupActivation(JmsActivation.java:302) [generic-jms-ra-jar-1.0.2.Final.jar:1.0.3.Final-SNAPSHOT]
	at org.jboss.resource.adapter.jms.inflow.JmsActivation.handleFailure(JmsActivation.java:253) [generic-jms-ra-jar-1.0.2.Final.jar:1.0.3.Final-SNAPSHOT]

I've checked the code and there problem is in JmsActivation.setupConnection:420-
"if (preliminaryObject instanceof XAConnectionFactory && isDeliveryTransacted) {"

where isDeliveryTransacted is set to false and preliminaryObject (which implements XAConnectionFactory) is then cast to ConnectionFactory which fails with above ClassCastException. Can we just return normal javax.jms.Connection when preliminaryObject is instance of XAConnectionFactory and isDeliveryTransacted is set to false. 

Related Jenkins job:
https://jenkins.mw.lab.eng.bos.redhat.com/hudson/view/EAP6/view/EAP6-TIBCO-EMS/job/tibco-ems-EAP6.x-tck6-jms-matrix-clone/

[1] https://java.net/jira/browse/GENERICJMSRA-55
[2] https://java.net/jira/browse/JMS_SPEC-71

Comment 10 Miroslav Novak 2014-05-19 08:30:22 UTC
At this moment there no class cast exception but:
07:29:20,167 WARN  [org.jboss.jca.core.connectionmanager.pool.strategy.PoolByCri] (default-threads - 4) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: java.lang.IllegalArgumentException: Invalid acknowledge mode value 0
	at org.jboss.resource.adapter.jms.JmsManagedConnection.<init>(JmsManagedConnection.java:191)
	at org.jboss.resource.adapter.jms.JmsManagedConnectionFactory.createManagedConnection(JmsManagedConnectionFactory.java:109)
	at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.createConnectionEventListener(SemaphoreArrayListManagedConnectionPool.java:842)
	at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.getConnection(SemaphoreArrayListManagedConnectionPool.java:386)
	at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:404)
	at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:372)
	at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:353)
	at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:368)
	at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:488)
	at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.allocateConnection(JmsSessionFactoryImpl.java:362)
	at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.createQueueSession(JmsSessionFactoryImpl.java:149)
	at com.sun.ts.tests.jms.common.ParentMsgBeanNoTx.onMessage(ParentMsgBeanNoTx.java:113) [mdb_msg_ejb.jar:]

This happens when session is created with transacted false and session transacted mode:
connection.createSession(false,0);

We have to document this issue to release notes:
"When a session is created in a transaction context like:
connection.createSession(false,0);

an IllegalArgumentException occurs. Root cause is that generic RA does not ignore parameters passed to createSession where first sets session not transacted and second to mode transacted session (0). Workaround is to create transacted session:
connection.createSession(true,0);

Comment 11 Scott Mumford 2014-05-19 22:41:20 UTC
Removed component 'doc-release-notes' as this is not a bug with the Release Notes document. 

Reset Assignee to default for component. 

Leaving requires_doc_text flag as is to ensure entry in future release notes. The Target Release needs to be populated for this release note to appear in the appropriate Release Notes document (NEEDIINFO).

Comment 12 Jeff Mesnil 2014-05-22 09:31:58 UTC
There is no requirements for TIBCO to be able to use XAConnectionFactory for non-transacted operations in JMS 1.1.

The solution is clear and simple: use a regular connection factory for non XA transacted operations and use a XA Connection factory for XA operations.

Comment 13 Jeff Mesnil 2014-05-22 12:10:59 UTC
This issue is not blocker. Relying on a XAConnectionFactory to perform non-transacted operation is not correct and the root error comes from TIBCO.

Comment 14 Miroslav Novak 2014-05-23 13:22:44 UTC
Removing blocker flag. This will be documented in Release Notes for EAP 6.3.0.