Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
glassfishrobot opened this issue Jun 25, 2013 · 6 comments

Comments

@glassfishrobot
Copy link

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



Environment

Glassfish 3.1.2, Tibco EMS 6.1

Affected Versions

[2.1b]

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
Reported by ahe

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
Issue-Links:
depends on
JMS_SPEC-71

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
ahe said:
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()));

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
liang.x.zhao said:
JMS_SPEC-71 will clarify if XAConnectionFactory should extend ConnectionFactory.

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA GENERICJMSRA-55

@glassfishrobot
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant