genericjmsra
  1. genericjmsra
  2. GENERICJMSRA-55

genericjmsra gets ClassCastException because it tries to cast always javax.jms.ConnectionFactory

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1b
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None
    • Environment:

      Glassfish 3.1.2, Tibco EMS 6.1

      Description

      Creating connections to Tibcos javax.jms.XAConnectionFactory implementation fails because genericjmsra casts all ConnectionFactory objects to javax.jms.ConnectionFactory. But javax.jms.XAConnectionFactory does not extend javax.jms.ConnectionFactory, see https://java.net/jira/browse/JMS_SPEC-71.

      The Tibco class com.tibco.tibjms.naming.TibjmsFederatedXAConnectionFactory also implements only javax.jms.XAConnectionFactory and so a ClassCastExcpetion happens.

      Exception Stacktrace:
      com.sun.appserv.connectors.internal.api.PoolingException: com.tibco.tibjms.naming.TibjmsFederatedXAConnectionFactory cannot be cast to javax.jms.ConnectionFactory
      at com.sun.enterprise.resource.pool.datastructure.RWLockDataStructure.addResource(RWLockDataStructure.java:103)
      at com.sun.enterprise.resource.pool.ConnectionPool.addResource(ConnectionPool.java:282)
      at com.sun.enterprise.resource.pool.ConnectionPool.createResourceAndAddToPool(ConnectionPool.java:1512)
      at com.sun.enterprise.resource.pool.ConnectionPool.createResources(ConnectionPool.java:944)
      at com.sun.enterprise.resource.pool.ConnectionPool.initPool(ConnectionPool.java:230)
      at com.sun.enterprise.resource.pool.ConnectionPool.internalGetResource(ConnectionPool.java:511)
      at com.sun.enterprise.resource.pool.ConnectionPool.getResource(ConnectionPool.java:381)
      at com.sun.enterprise.resource.pool.PoolManagerImpl.getResourceFromPool(PoolManagerImpl.java:245)
      at com.sun.enterprise.resource.pool.PoolManagerImpl.getResource(PoolManagerImpl.java:170)
      at com.sun.enterprise.connectors.ConnectionManagerImpl.getResource(ConnectionManagerImpl.java:332)
      at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:301)
      ... 95 more
      Caused by: com.sun.appserv.connectors.internal.api.PoolingException: com.tibco.tibjms.naming.TibjmsFederatedXAConnectionFactory cannot be cast to javax.jms.ConnectionFactory
      at com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:924)
      at com.sun.enterprise.resource.pool.ConnectionPool.createResource(ConnectionPool.java:1189)
      at com.sun.enterprise.resource.pool.datastructure.RWLockDataStructure.addResource(RWLockDataStructure.java:98)
      ... 105 more
      Caused by: java.lang.ClassCastException: com.tibco.tibjms.naming.TibjmsFederatedXAConnectionFactory cannot be cast to javax.jms.ConnectionFactory
      at com.sun.genericra.outbound.AbstractManagedConnectionFactory.initializeConnectionFactory(AbstractManagedConnectionFactory.java:182)
      at com.sun.genericra.outbound.AbstractManagedConnectionFactory.createManagedConnection(AbstractManagedConnectionFactory.java:118)
      at com.sun.enterprise.resource.allocator.ConnectorAllocator.createResource(ConnectorAllocator.java:160)
      at com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:907)
      ... 107 more

      Connection Pool definition from glassfish-resources.xml
      <connector-connection-pool name="jms/XAConnectionPool" resource-adapter-name="genericra" connection-definition-name="javax.jms.ConnectionFactory" transaction-support="XATransaction">
      <property name="ConnectionFactoryJndiName" value="XAGenereic"/>
      <property name="SupportsXA" value="true"></property>
      </connector-connection-pool>

        Issue Links

          Activity

          Hide
          David Zhao added a comment -

          JMS_SPEC-71 will clarify if XAConnectionFactory should extend ConnectionFactory.

          Show
          David Zhao added a comment - JMS_SPEC-71 will clarify if XAConnectionFactory should extend ConnectionFactory.
          Hide
          ahe added a comment -

          Patch to avoid this cast:
          Index: AbstractManagedConnectionFactory.java
          ===================================================================
          — AbstractManagedConnectionFactory.java (Revision 234)
          +++ AbstractManagedConnectionFactory.java (Arbeitskopie)
          @@ -81,6 +81,7 @@
          private boolean useProxyMessages = false; //disabled by default
          private PrintWriter logWriter;
          private ConnectionFactory connectionFactory = null;
          + private XAConnectionFactory xAConnectionFactory = null;
          protected int destinationMode = Constants.UNIFIED_SESSION;

          public AbstractManagedConnectionFactory() {
          @@ -136,7 +137,7 @@
          javax.jms.Connection physicalCon = null;

          if (this.getSupportsXA())

          { - physicalCon = createXAConnection(pc, this.connectionFactory); + physicalCon = createXAConnection(pc, this.xAConnectionFactory); }

          else

          { physicalCon = createConnection(pc, this.connectionFactory); }

          @@ -145,7 +146,7 @@
          }

          protected abstract javax.jms.XAConnection createXAConnection(

          • PasswordCredential pc, ConnectionFactory cf) throws JMSException;
            + PasswordCredential pc, XAConnectionFactory cf) throws JMSException;

          protected abstract javax.jms.Connection createConnection(
          PasswordCredential pc, ConnectionFactory cf) throws JMSException;
          @@ -161,7 +162,7 @@
          protected abstract String getActualConnectionFactoryClassName();

          private void initializeConnectionFactory() throws ResourceException {

          • if (this.connectionFactory == null) {
            + if (this.connectionFactory == null && this.xAConnectionFactory == null) { ObjectBuilder cfBuilder = null; ObjectBuilderFactory obf = new ObjectBuilderFactory(); @@ -179,7 +180,12 @@ cfBuilder.setCommonSetterMethodName(setMethod); }
          • this.connectionFactory = (ConnectionFactory) cfBuilder.build();
            + if (this.getSupportsXA()) { + this.xAConnectionFactory = (XAConnectionFactory) cfBuilder.build(); + }

            else

            { + this.connectionFactory = (ConnectionFactory) cfBuilder.build(); + }

            +
            }
            }

          Index: ManagedJMSConnectionFactory.java
          ===================================================================
          — ManagedJMSConnectionFactory.java (Revision 234)
          +++ ManagedJMSConnectionFactory.java (Arbeitskopie)
          @@ -39,7 +39,7 @@
          }

          protected javax.jms.XAConnection createXAConnection(PasswordCredential pc,

          • javax.jms.ConnectionFactory cf) throws JMSException {
            + javax.jms.XAConnectionFactory cf) throws JMSException {
            if (pc != null && (!pc.getUserName().equals(""))) { return ((XAConnectionFactory) cf).createXAConnection(pc.getUserName(), new String(pc.getPassword())); Index: ManagedQueueConnectionFactory.java =================================================================== --- ManagedQueueConnectionFactory.java (Revision 234) +++ ManagedQueueConnectionFactory.java (Arbeitskopie) @@ -42,7 +42,7 @@ }

          protected XAConnection createXAConnection(PasswordCredential pc,

          • javax.jms.ConnectionFactory cf) throws JMSException {
            + javax.jms.XAConnectionFactory cf) throws JMSException {
            if (pc != null && (!pc.getUserName().equals(""))) { return ((XAQueueConnectionFactory) cf).createXAQueueConnection(pc.getUserName(), new String(pc.getPassword())); Index: ManagedTopicConnectionFactory.java =================================================================== --- ManagedTopicConnectionFactory.java (Revision 234) +++ ManagedTopicConnectionFactory.java (Arbeitskopie) @@ -42,7 +42,7 @@ }

          protected XAConnection createXAConnection(PasswordCredential pc,

          • javax.jms.ConnectionFactory cf) throws JMSException {
            + javax.jms.XAConnectionFactory cf) throws JMSException {
            if (pc != null && (!pc.getUserName().equals(""))) {
            return ((XATopicConnectionFactory) cf).createXATopicConnection(pc.getUserName(),
            new String(pc.getPassword()));
          Show
          ahe added a comment - Patch to avoid this cast: Index: AbstractManagedConnectionFactory.java =================================================================== — AbstractManagedConnectionFactory.java (Revision 234) +++ AbstractManagedConnectionFactory.java (Arbeitskopie) @@ -81,6 +81,7 @@ private boolean useProxyMessages = false; //disabled by default private PrintWriter logWriter; private ConnectionFactory connectionFactory = null; + private XAConnectionFactory xAConnectionFactory = null; protected int destinationMode = Constants.UNIFIED_SESSION; public AbstractManagedConnectionFactory() { @@ -136,7 +137,7 @@ javax.jms.Connection physicalCon = null; if (this.getSupportsXA()) { - physicalCon = createXAConnection(pc, this.connectionFactory); + physicalCon = createXAConnection(pc, this.xAConnectionFactory); } else { physicalCon = createConnection(pc, this.connectionFactory); } @@ -145,7 +146,7 @@ } protected abstract javax.jms.XAConnection createXAConnection( PasswordCredential pc, ConnectionFactory cf) throws JMSException; + PasswordCredential pc, XAConnectionFactory cf) throws JMSException; protected abstract javax.jms.Connection createConnection( PasswordCredential pc, ConnectionFactory cf) throws JMSException; @@ -161,7 +162,7 @@ protected abstract String getActualConnectionFactoryClassName(); private void initializeConnectionFactory() throws ResourceException { if (this.connectionFactory == null) { + if (this.connectionFactory == null && this.xAConnectionFactory == null) { ObjectBuilder cfBuilder = null; ObjectBuilderFactory obf = new ObjectBuilderFactory(); @@ -179,7 +180,12 @@ cfBuilder.setCommonSetterMethodName(setMethod); } this.connectionFactory = (ConnectionFactory) cfBuilder.build(); + if (this.getSupportsXA()) { + this.xAConnectionFactory = (XAConnectionFactory) cfBuilder.build(); + } else { + this.connectionFactory = (ConnectionFactory) cfBuilder.build(); + } + } } Index: ManagedJMSConnectionFactory.java =================================================================== — ManagedJMSConnectionFactory.java (Revision 234) +++ ManagedJMSConnectionFactory.java (Arbeitskopie) @@ -39,7 +39,7 @@ } protected javax.jms.XAConnection createXAConnection(PasswordCredential pc, javax.jms.ConnectionFactory cf) throws JMSException { + javax.jms.XAConnectionFactory cf) throws JMSException { if (pc != null && (!pc.getUserName().equals(""))) { return ((XAConnectionFactory) cf).createXAConnection(pc.getUserName(), new String(pc.getPassword())); Index: ManagedQueueConnectionFactory.java =================================================================== --- ManagedQueueConnectionFactory.java (Revision 234) +++ ManagedQueueConnectionFactory.java (Arbeitskopie) @@ -42,7 +42,7 @@ } protected XAConnection createXAConnection(PasswordCredential pc, javax.jms.ConnectionFactory cf) throws JMSException { + javax.jms.XAConnectionFactory cf) throws JMSException { if (pc != null && (!pc.getUserName().equals(""))) { return ((XAQueueConnectionFactory) cf).createXAQueueConnection(pc.getUserName(), new String(pc.getPassword())); Index: ManagedTopicConnectionFactory.java =================================================================== --- ManagedTopicConnectionFactory.java (Revision 234) +++ ManagedTopicConnectionFactory.java (Arbeitskopie) @@ -42,7 +42,7 @@ } protected XAConnection createXAConnection(PasswordCredential pc, javax.jms.ConnectionFactory cf) throws JMSException { + javax.jms.XAConnectionFactory cf) throws JMSException { if (pc != null && (!pc.getUserName().equals(""))) { return ((XATopicConnectionFactory) cf).createXATopicConnection(pc.getUserName(), new String(pc.getPassword()));

            People

            • Assignee:
              Unassigned
              Reporter:
              ahe
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: