You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Edwin van der Elst (JIRA)" <ji...@apache.org> on 2010/03/25 12:35:08 UTC

[jira] Created: (AMQ-2670) ClassCast Exception in JBoss when using XA

ClassCast Exception in JBoss when using XA 
-------------------------------------------

                 Key: AMQ-2670
                 URL: https://issues.apache.org/activemq/browse/AMQ-2670
             Project: ActiveMQ
          Issue Type: Bug
          Components: Connector
    Affects Versions: 5.3.0
         Environment: activemq-rar-5.3.0.rar deployed in jboss-5.1.0-GA
            Reporter: Edwin van der Elst


When deploying the rar under JBoss, the connectionfactory bound in de JNDI tree is always of type 'ActiveMQConnectionFactory'., while it should be ActiveMQXAConnectionFactory (which implements XAConnectionFactory).

I attached a new class that creates the correct type of factory, and this can be configured in the ra.xml (also attached).


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2670) ClassCast Exception in JBoss when using XA

Posted by "Edwin van der Elst (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58450#action_58450 ] 

Edwin van der Elst commented on AMQ-2670:
-----------------------------------------

An mdb:
@MessageDriven(mappedName = "jms/SimpleMDB", messageListenerInterface = javax.jms.MessageListener.class, activationConfig = {
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue.test"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "NonDurable"),
        @ActivationConfigProperty(propertyName = "maximumRedeliveries", propertyValue = "0") })
@ResourceAdapter(value = "activemq-rar-5.3.0.rar")
public class SimpleMDB implements MessageListener {
...
}

But it is not related to the MDB. The problem is that the connectionfactory is not the XA variant. This is deployed in a -ds.xml ike this:
<connection-factories>

   <tx-connection-factory>
      <jndi-name>activemq/QueueConnectionFactory</jndi-name>
      <xa-transaction/>
      <track-connection-by-tx/>
      <rar-name>activemq-rar-5.3.0.rar</rar-name>
      <connection-definition>javax.jms.QueueConnectionFactory</connection-definition>
      <ServerUrl>tcp://localhost:61616</ServerUrl>
      <min-pool-size>10</min-pool-size>
      <max-pool-size>200</max-pool-size>
      <blocking-timeout-millis>30000</blocking-timeout-millis>
      <idle-timeout-minutes>3</idle-timeout-minutes>
   </tx-connection-factory>

   <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
          name="activemq:service=JMSProviderLoader,name=ActiveMQJMSProvider">
      <attribute name="ProviderName">ActiveMQJMSProvider</attribute>
      <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
      <attribute name="FactoryRef">java:/activemq/QueueConnectionFactory</attribute>
      <attribute name="QueueFactoryRef">java:/activemq/QueueConnectionFactory</attribute>
      <attribute name="TopicFactoryRef">java:/activemq/QueueConnectionFactory</attribute>
   </mbean>
   
...
/>

This will result in a call to ActiveMQManagedConnectionFactory.createConnectionFactory during startup of JBoss (as configured in the ra.xml). But that will always create a ActiveMQConnectionFactory and never the ActiveMQXAConnectionFactory. 
And therefore, a ConnectionFactory instance is always bound in the JNDI and not an XAConnectionFactory.
So, it is not a bypass for the rar (it is still needed).

I see in the sources for ActiveMQXAConnectionFactory that all work is handled by the superclass (ActiveMQConnectionFactory), so it is only in JBoss actually performing the cast on the connectionfactory that causes a problem.

> ClassCast Exception in JBoss when using XA 
> -------------------------------------------
>
>                 Key: AMQ-2670
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2670
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Connector
>    Affects Versions: 5.3.0
>         Environment: activemq-rar-5.3.0.rar deployed in jboss-5.1.0-GA
>            Reporter: Edwin van der Elst
>         Attachments: ActiveMQXAManagedConnectionFactory.java, ra.xml
>
>
> When deploying the rar under JBoss, the connectionfactory bound in de JNDI tree is always of type 'ActiveMQConnectionFactory'., while it should be ActiveMQXAConnectionFactory (which implements XAConnectionFactory).
> I attached a new class that creates the correct type of factory, and this can be configured in the ra.xml (also attached).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (AMQ-2670) ClassCast Exception in JBoss when using XA

Posted by "Edwin van der Elst (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-2670?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Edwin van der Elst updated AMQ-2670:
------------------------------------

    Attachment: ActiveMQXAManagedConnectionFactory.java
                ra.xml

> ClassCast Exception in JBoss when using XA 
> -------------------------------------------
>
>                 Key: AMQ-2670
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2670
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Connector
>    Affects Versions: 5.3.0
>         Environment: activemq-rar-5.3.0.rar deployed in jboss-5.1.0-GA
>            Reporter: Edwin van der Elst
>         Attachments: ActiveMQXAManagedConnectionFactory.java, ra.xml
>
>
> When deploying the rar under JBoss, the connectionfactory bound in de JNDI tree is always of type 'ActiveMQConnectionFactory'., while it should be ActiveMQXAConnectionFactory (which implements XAConnectionFactory).
> I attached a new class that creates the correct type of factory, and this can be configured in the ra.xml (also attached).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2670) ClassCast Exception in JBoss when using XA

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58561#action_58561 ] 

Gary Tully commented on AMQ-2670:
---------------------------------

Using JMS apis for out of band recovery will work, there is one relevant jboss fix .w.r.t restarted the broker service that may also help https://jira.jboss.org/jira/browse/JBMESSAGING-1608

Background: The RAR should not create or use an XA connection factory, XA interaction is managed by the RAR implementation in response to calls from the appserver in accordance with the JCA transaction contract.
The appserver should also negotiate with the RAR to facilitate recovery using the JCA spi and that is what will be addressed by https://jira.jboss.org/jira/browse/JBJCA-39.

In the mean time, using the JMS api to deal with recovery is a necessary and a reasonable workaround.

Recovery is configured in the transaction manager properties using a resource wrapper from jboss messaging. In jboss 5.0.1_GA, the relevant addition to the transaction manager properties file: *conf/jbossjta-properties.xml* is:
{code}    <properties depends="arjuna" name="jta">
        <!--
        Support subtransactions in the JTA layer?
        Default is NO.
      -->
        <property name="com.arjuna.ats.jta.supportSubtransactions" value="NO"/>
        <property name="com.arjuna.ats.jta.jtaTMImplementation" value="com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple"/>
        <!--
                        com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple
                        -->
        <property name="com.arjuna.ats.jta.jtaUTImplementation" value="com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple"/>
        <!--
                        com.arjuna.ats.internal.jta.transaction.jts.UserTransactionImple
                        -->
       <!-- recovery for ActiveMQ XA pending automated RAR recovery https://jira.jboss.org/jira/browse/JBJCA-39 -->
       <property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.ActiveMQ" value="org.jboss.jms.server.recovery.MessagingXAResourceRecovery;java:/ActiveMQRAR"/>

    </properties>{code} Note this is a modification to the *jta* configuration, _not_ the recovery manager.


The JNDI name referenced needs to be provided by the ActiveMQ RAR *-ds.xml" descriptor using a JMSProviderLoader. The addition is as follows:{code}   <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
          name="activemq:service=JMSProviderLoader,name=ActiveMQRAR">
      <attribute name="ProviderName">ActiveMQRAR</attribute>
      <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
      <attribute name="Properties">xa=true
       java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
       java.naming.provider.url=tcp://localhost:61616
</attribute>
      <attribute name="QueueFactoryRef">ConnectionFactory</attribute>
      <attribute name="TopicFactoryRef">ConnectionFactory</attribute>
      <attribute name="FactoryRef">ConnectionFactory</attribute>
   </mbean>{code}

This depends on https://issues.apache.org/activemq/browse/AMQ-2656 to allow the ActiveMQ initial context to return an XA connection factory. Note the property, xa=true in the "Properties" attribute which ensures that an XAConnectionFactory is created.

> ClassCast Exception in JBoss when using XA 
> -------------------------------------------
>
>                 Key: AMQ-2670
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2670
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Connector
>    Affects Versions: 5.3.0
>         Environment: activemq-rar-5.3.0.rar deployed in jboss-5.1.0-GA
>            Reporter: Edwin van der Elst
>            Assignee: Gary Tully
>             Fix For: 5.4.0
>
>         Attachments: ActiveMQXAManagedConnectionFactory.java, ra.xml
>
>
> When deploying the rar under JBoss, the connectionfactory bound in de JNDI tree is always of type 'ActiveMQConnectionFactory'., while it should be ActiveMQXAConnectionFactory (which implements XAConnectionFactory).
> I attached a new class that creates the correct type of factory, and this can be configured in the ra.xml (also attached).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2670) ClassCast Exception in JBoss when using XA

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58456#action_58456 ] 

Gary Tully commented on AMQ-2670:
---------------------------------

ok, I see how this will work but it is a bit of a hack, all be it, one that is of value.

I would expect some sort of generic RAR com.arjuna.ats.jta.recovery.XAResourceRecovery impl that is aware of a resource adapter in jndi and can make calls on javax.resource.spi.ResourceAdapter#getXAResources to do recovery.

It looks like no such thing exists in jboss or arjuna atm, Having an option to publish an XA connection factory in jndi looks like a reasonable workaround.

> ClassCast Exception in JBoss when using XA 
> -------------------------------------------
>
>                 Key: AMQ-2670
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2670
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Connector
>    Affects Versions: 5.3.0
>         Environment: activemq-rar-5.3.0.rar deployed in jboss-5.1.0-GA
>            Reporter: Edwin van der Elst
>         Attachments: ActiveMQXAManagedConnectionFactory.java, ra.xml
>
>
> When deploying the rar under JBoss, the connectionfactory bound in de JNDI tree is always of type 'ActiveMQConnectionFactory'., while it should be ActiveMQXAConnectionFactory (which implements XAConnectionFactory).
> I attached a new class that creates the correct type of factory, and this can be configured in the ra.xml (also attached).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (AMQ-2670) ClassCast Exception in JBoss when using XA

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-2670?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Tully resolved AMQ-2670.
-----------------------------

       Resolution: Fixed
    Fix Version/s: 5.4.0
         Assignee: Gary Tully

patch applied to trunk with thanks in r927520

> ClassCast Exception in JBoss when using XA 
> -------------------------------------------
>
>                 Key: AMQ-2670
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2670
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Connector
>    Affects Versions: 5.3.0
>         Environment: activemq-rar-5.3.0.rar deployed in jboss-5.1.0-GA
>            Reporter: Edwin van der Elst
>            Assignee: Gary Tully
>             Fix For: 5.4.0
>
>         Attachments: ActiveMQXAManagedConnectionFactory.java, ra.xml
>
>
> When deploying the rar under JBoss, the connectionfactory bound in de JNDI tree is always of type 'ActiveMQConnectionFactory'., while it should be ActiveMQXAConnectionFactory (which implements XAConnectionFactory).
> I attached a new class that creates the correct type of factory, and this can be configured in the ra.xml (also attached).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (AMQ-2670) ClassCast Exception in JBoss when using XA

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-2670?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Tully reopened AMQ-2670:
-----------------------------


this breaks regular XA, the RAR needs to handle the XAResource and an XAConnectionFactory should not be created.
We need another mechanism to integrate with the periodic recovery of jboss. Possibly implement their recovery interface or a wrapper to it.

> ClassCast Exception in JBoss when using XA 
> -------------------------------------------
>
>                 Key: AMQ-2670
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2670
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Connector
>    Affects Versions: 5.3.0
>         Environment: activemq-rar-5.3.0.rar deployed in jboss-5.1.0-GA
>            Reporter: Edwin van der Elst
>            Assignee: Gary Tully
>             Fix For: 5.4.0
>
>         Attachments: ActiveMQXAManagedConnectionFactory.java, ra.xml
>
>
> When deploying the rar under JBoss, the connectionfactory bound in de JNDI tree is always of type 'ActiveMQConnectionFactory'., while it should be ActiveMQXAConnectionFactory (which implements XAConnectionFactory).
> I attached a new class that creates the correct type of factory, and this can be configured in the ra.xml (also attached).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2670) ClassCast Exception in JBoss when using XA

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58519#action_58519 ] 

Gary Tully commented on AMQ-2670:
---------------------------------

Seems like the issue of of JCA XA recovery registration has come up in jboss land, and it is correctly seen as something that should be handled under the covers between JCA and the TransactionManager, but this has not been completed yet. See: https://jira.jboss.org/jira/browse/JBJCA-39

There may be some way to workaround this with JMS apis in the short term, but the real solution is to let the appserver work though registering the XA resource from JCA with the underlying transaction services of the container.


> ClassCast Exception in JBoss when using XA 
> -------------------------------------------
>
>                 Key: AMQ-2670
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2670
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Connector
>    Affects Versions: 5.3.0
>         Environment: activemq-rar-5.3.0.rar deployed in jboss-5.1.0-GA
>            Reporter: Edwin van der Elst
>            Assignee: Gary Tully
>             Fix For: 5.4.0
>
>         Attachments: ActiveMQXAManagedConnectionFactory.java, ra.xml
>
>
> When deploying the rar under JBoss, the connectionfactory bound in de JNDI tree is always of type 'ActiveMQConnectionFactory'., while it should be ActiveMQXAConnectionFactory (which implements XAConnectionFactory).
> I attached a new class that creates the correct type of factory, and this can be configured in the ra.xml (also attached).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2670) ClassCast Exception in JBoss when using XA

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58449#action_58449 ] 

Gary Tully commented on AMQ-2670:
---------------------------------

can you post an ejb or mdb descriptor that uses this. This looks like a use case where the RAR provides the connection factory but not the recovery contract, is that correct? With the RAR contract, the XAResource would normally be accessed via the javax.resource.spi.ResourceAdapter#getXAResources

With the new class, the RAR can be bypassed w.r.t to recovery, or just used as an easy way to deploy ActiveMQ to jboss. Am I missing something?

> ClassCast Exception in JBoss when using XA 
> -------------------------------------------
>
>                 Key: AMQ-2670
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2670
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Connector
>    Affects Versions: 5.3.0
>         Environment: activemq-rar-5.3.0.rar deployed in jboss-5.1.0-GA
>            Reporter: Edwin van der Elst
>         Attachments: ActiveMQXAManagedConnectionFactory.java, ra.xml
>
>
> When deploying the rar under JBoss, the connectionfactory bound in de JNDI tree is always of type 'ActiveMQConnectionFactory'., while it should be ActiveMQXAConnectionFactory (which implements XAConnectionFactory).
> I attached a new class that creates the correct type of factory, and this can be configured in the ra.xml (also attached).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2670) ClassCast Exception in JBoss when using XA

Posted by "Edwin van der Elst (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58448#action_58448 ] 

Edwin van der Elst commented on AMQ-2670:
-----------------------------------------

Note, for recovery to work (and for the original error to occur), a configuration in jbossts-properties.xml must be added, like this:
	<property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.ACTIVEMQ"
       value="org.jboss.jms.server.recovery.MessagingXAResourceRecovery;java:/ActiveMQJMSProvider"/>


> ClassCast Exception in JBoss when using XA 
> -------------------------------------------
>
>                 Key: AMQ-2670
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2670
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Connector
>    Affects Versions: 5.3.0
>         Environment: activemq-rar-5.3.0.rar deployed in jboss-5.1.0-GA
>            Reporter: Edwin van der Elst
>         Attachments: ActiveMQXAManagedConnectionFactory.java, ra.xml
>
>
> When deploying the rar under JBoss, the connectionfactory bound in de JNDI tree is always of type 'ActiveMQConnectionFactory'., while it should be ActiveMQXAConnectionFactory (which implements XAConnectionFactory).
> I attached a new class that creates the correct type of factory, and this can be configured in the ra.xml (also attached).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (AMQ-2670) ClassCast Exception in JBoss when using XA

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58563#action_58563 ] 

Gary Tully edited comment on AMQ-2670 at 3/30/10 2:23 PM:
----------------------------------------------------------

Add dependency link to https://issues.apache.org/activemq/browse/AMQ-2656 as this needs ActiveMQ initial context to return an XA capable connection factory for out of band recovery using JMS api

      was (Author: gtully):
    needs ActiveMQ initial context to return an XA capable connection factory for out of band recovery using JMS api
  
> ClassCast Exception in JBoss when using XA 
> -------------------------------------------
>
>                 Key: AMQ-2670
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2670
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Connector
>    Affects Versions: 5.3.0
>         Environment: activemq-rar-5.3.0.rar deployed in jboss-5.1.0-GA
>            Reporter: Edwin van der Elst
>            Assignee: Gary Tully
>             Fix For: 5.4.0
>
>         Attachments: ActiveMQXAManagedConnectionFactory.java, ra.xml
>
>
> When deploying the rar under JBoss, the connectionfactory bound in de JNDI tree is always of type 'ActiveMQConnectionFactory'., while it should be ActiveMQXAConnectionFactory (which implements XAConnectionFactory).
> I attached a new class that creates the correct type of factory, and this can be configured in the ra.xml (also attached).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (AMQ-2670) ClassCast Exception in JBoss when using XA

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-2670?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Tully resolved AMQ-2670.
-----------------------------

    Resolution: Fixed

r929145
removed the XA version of the managed connection factory and added some additional logging to the transaction broker so it is easy to verify when recovery is configured. To see it, add the following to the log4j config: {code}log4j.logger.org.apache.activemq.broker.TransactionBroker=DEBUG{code} and a message will be output on every call to recover outstanding XA prepared transactions.

> ClassCast Exception in JBoss when using XA 
> -------------------------------------------
>
>                 Key: AMQ-2670
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2670
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Connector
>    Affects Versions: 5.3.0
>         Environment: activemq-rar-5.3.0.rar deployed in jboss-5.1.0-GA
>            Reporter: Edwin van der Elst
>            Assignee: Gary Tully
>             Fix For: 5.4.0
>
>         Attachments: ActiveMQXAManagedConnectionFactory.java, ra.xml
>
>
> When deploying the rar under JBoss, the connectionfactory bound in de JNDI tree is always of type 'ActiveMQConnectionFactory'., while it should be ActiveMQXAConnectionFactory (which implements XAConnectionFactory).
> I attached a new class that creates the correct type of factory, and this can be configured in the ra.xml (also attached).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.