java.lang.ClassCastException: com.tibco.tibjms.naming.TibjmsFederatedQueueConnectionFactory cannot be cast to javax.jms.XAConnectionFactory

210 views
Skip to first unread message

mchl...@gmail.com

unread,
Sep 6, 2017, 4:14:11 PM9/6/17
to Generic JMS JCA Resource Adapter for JBoss AS

When migrating an enterprise application from Weblogic Server to JBoss EAP 6.4, we encountered the following error:

connectionFactory=java:global/remoteJMS/QueueConnectionFactory): java.lang.ClassCastException: com.tibco.tibjms.naming.TibjmsFederatedQueueConnectionFactory cannot be cast to javax.jms.XAConnectionFactory

               at org.jboss.resource.adapter.jms.inflow.JmsActivation.setupConnection(JmsActivation.java:437)

 

 

We use Tibco EMS as JMS provider.

 

 

Below is the my-jms-jms.xml configuration file in Weblogic Server:

[[

<weblogic-jms ...>

  <foreign-server name="myForeignServer">

    <default-targeting-enabled>true</default-targeting-enabled>

    <foreign-destination name="My_MG">

      <local-jndi-name>My_MG</local-jndi-name>

      <remote-jndi-name>My_MG</remote-jndi-name>

    </foreign-destination>

    <foreign-connection-factory name="TopicConnectionFactory">

      <local-jndi-name>TopicConnectionFactory</local-jndi-name>

      <remote-jndi-name>TopicConnectionFactory</remote-jndi-name>

      <username>{myUsername}</username>

      <password-encrypted>{myPassword}</password-encrypted>

    </foreign-connection-factory>

    <foreign-connection-factory name="QueueConnectionFactory">

      <local-jndi-name>QueueConnectionFactory</local-jndi-name>

      <remote-jndi-name>QueueConnectionFactory</remote-jndi-name>

      <username>{myUsername}</username>

      <password-encrypted>{myPassword}</password-encrypted>

    </foreign-connection-factory>

    <initial-context-factory>com.tibco.tibjms.naming.TibjmsInitialContextFactory</initial-context-factory>

    <connection-url>tcp://server1:42032,tcp://server1:42033</connection-url>

    <jndi-properties-credential-encrypted>{myPassword}</jndi-properties-credential-encrypted>

    <jndi-property>

      <key>java.naming.provider.url</key>

      <value>tcp://server1:42032,tcp://server1:42033</value>

    </jndi-property>

    <jndi-property>

      <key>java.naming.factory.initial</key>

      <value>com.tibco.tibjms.naming.TibjmsInitialContextFactory</value>

    </jndi-property>

    <jndi-property>

      <key>java.naming.security.principal</key>

      <value>{myUsername}</value>

    </jndi-property>

  </foreign-server>

</weblogic-jms>

]]

 

 

Below is how it is configured in standalone-full.xml:

[[

        <subsystem xmlns="urn:jboss:domain:naming:1.4">

            <bindings>

                <external-context name="java:global/remoteJMS/" module="org.jboss.genericjms.provider" class="javax.naming.InitialContext">

                    <environment>

                        <property name="java.naming.factory.initial" value="com.tibco.tibjms.naming.TibjmsInitialContextFactory"/>

                        <property name="java.naming.provider.url" value="tcp://server1:42032,tcp://server1:42033"/>

                        <property name="java.naming.factory.url.pkgs" value="com.tibco.tibjms.naming"/>

                        <property name="java.naming.security.principal" value="{myUsername}"/>

                        <property name="java.naming.security.credentials" value="{myPassword}"/>

                        <property name="org.jboss.as.naming.lookup.by.string" value="true"/>

                    </environment>

                </external-context>

            </bindings>

            <remote-naming/>

        </subsystem>

  ....

        <subsystem xmlns="urn:jboss:domain:resource-adapters:1.1">

            <resource-adapters>

                <resource-adapter id="org.jboss.genericjms">

                    <module slot="main" id="org.jboss.genericjms"/>

                    <transaction-support>NoTransaction</transaction-support>

                    <connection-definitions>

                        <connection-definition class-name="org.jboss.resource.adapter.jms.JmsManagedConnectionFactory" jndi-name="java:/jms/XAQCF" pool-name="XAQCF">

                            <config-property name="JndiParameters">

         java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory;java.naming.provider.url=tcp://server1:42032,tcp://server1:42033;java.naming.factory.url.pkgs=com.tibco.tibjms.naming;java.naming.security.principal={myUsername};java.naming.security.credentials={myPassword}

                            </config-property>

                            <config-property name="ConnectionFactory">

                                XAQCF

                            </config-property>

                            <security>

                                <application/>

                            </security>

                        </connection-definition>

                    </connection-definitions>

                </resource-adapter>

            </resource-adapters>

        </subsystem>

]]

 

 

Below is the jboss-ejb3.xml for MDB:

[[

<jboss:ejb-jar ...>

  <enterprise-beans>

   <message-driven>

        <ejb-name>MyMDB</ejb-name>

            <activation-config>  

  <activation-config-property>

                    <activation-config-property-name>connectionFactory</activation-config-property-name>

                    <activation-config-property-value>java:global/remoteJMS/QueueConnectionFactory</activation-config-property-value>

                </activation-config-property>  

                <activation-config-property>

                    <activation-config-property-name>destination</activation-config-property-name>

                    <activation-config-property-value>java:global/remoteJMS/My_MG</activation-config-property-value>

                </activation-config-property>    

                <activation-config-property>

  <activation-config-property-name>destinationType</activation-config-property-name>

  <activation-config-property-value>javax.jms.Queue</activation-config-property-value>

  </activation-config-property>

  <activation-config-property>

  <activation-config-property-name>acknowledgeMode</activation-config-property-name>

  <activation-config-property-value>Auto-acknowledge</activation-config-property-value>

  </activation-config-property>

            </activation-config>

   </message-driven>

  </enterprise-beans>

</jboss:ejb-jar>

]]

 

 

Please help to see what may have caused this error? Thank you very much in advance.

Justin Bertram

unread,
Sep 6, 2017, 4:20:57 PM9/6/17
to Generic JMS JCA Resource Adapter for JBoss AS
Apparently the class com.tibco.tibjms.naming.TibjmsFederatedQueueConnectionFactory which is being looked up in JNDI when the MDB is activated cannot be cast to javax.jms.XAConnectionFactory.  The Generic JMS JCA RA is attempting to cast the connection factory implementation which it looked up in JNDI to javax.jms.XAConnectionFactory because delivery to the MDB is transacted.  You should change your MDB so that it doesn't use transactions (i.e. transaction attribute = NOT_SUPPORTED).

mchl...@gmail.com

unread,
Sep 6, 2017, 4:53:35 PM9/6/17
to Generic JMS JCA Resource Adapter for JBoss AS
Thanks for the quick response. We use EJB2.0. In the ejb-jar.xml, how to add transaction attribute = NOT_SUPPORTED? I added <transaction-attribute>NOT_SUPPORTED</transaction-attribute> but it shows as unexpected element.
[[
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
    <enterprise-beans>
        <message-driven>
            <ejb-name>MyMDB</ejb-name>
            <ejb-class>com....MyListener</ejb-class>
            <transaction-type>Container</transaction-type>
            <transaction-attribute>NOT_SUPPORTED</transaction-attribute>
]]

Justin Bertram

unread,
Sep 7, 2017, 8:52:50 AM9/7/17
to Generic JMS JCA Resource Adapter for JBoss AS
I'm not an expert on EJB configuration.  There are lots of resources online that deal with EJB.  I recommend you consult the official Oracle documentation.  At the end of the day the issue is with your EJB and not the resource adapter.
Reply all
Reply to author
Forward
0 new messages