ClassCastException javax.naming.Reference cannot be cast to javax.jms.ConnectionFactory
swarsa Feb 15, 2017 3:55 PMWhen looking up a WebMethods connection factory in LDAP via the following connection definition, I get a classcastexception javax.naming.Reference cannot be cast to javax.jms.ConnectionFactory at com.sun.genericra.outbound.AbstractManagedConnectionFactory.initializeConnectionFactory(AbstractManagedConnectionFactory.java:187):
<connection-definitions>
<connection-definition class-name="com.sun.genericra.outbound.ManagedQueueConnectionFactory" jndi-name="java:/XXXConnectionFactory" pool-name="XXXConnectionFactory">
<config-property name="ProviderIntegrationMode">
jndi
</config-property>
<config-property name="ConnectionFactoryJndiName">
cn=ClusterXXXConnectionFactory,ou=xxxxxxx,ou=xxxxxxxxx,ou=xxxx,dc=xxxx,dc=xxx
</config-property>
<config-property name="UserName">
cn=xxx,ou=xxxxxx,ou=xxxxx,dc=xxxxxx,dc=xxxxx
</config-property>
<config-property name="JndiProperties">
java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory,java.naming.provider.url=ldap://xxxxxxxxxxxxx:nnn
</config-property>
<config-property name="Password">
xxxxxxx
</config-property>
<pool>
<initial-pool-size>0</initial-pool-size>
</pool>
</connection-definition>
</connection-definitions>
The great thing is I'm getting the exact same xml object that I can see under that LDAP address in an LDAP browser, so I know that the connection to LDAP is working.
The problem is that The code that is trying to cast the response (com.sun.genericra.outbound.AbstractManagedConnectionFactory.initializeConnectionFactory) looks like this:
private void initializeConnectionFactory() throws ResourceException {
if (this.connectionFactory == null) {
ObjectBuilder cfBuilder = null;
ObjectBuilderFactory obf = new ObjectBuilderFactory();
if (this.getProviderIntegrationMode().equalsIgnoreCase(Constants.JNDI_BASED)) {
cfBuilder = obf.createUsingJndiName(this.getConnectionFactoryJndiName(),
this.getJndiProperties());
} else {
cfBuilder = obf.createUsingClassName(getActualConnectionFactoryClassName());
cfBuilder.setProperties(this.getConnectionFactoryProperties());
}
String setMethod = this.getCommonSetterMethodName();
if (!StringUtils.isNull(setMethod)) {
cfBuilder.setCommonSetterMethodName(setMethod);
}
this.connectionFactory = (ConnectionFactory) cfBuilder.build();
}
}
Notice the lines in bold. The code is blowing up on that line, when it tries to cast the result of cfBuilder.build() to a javax.jms.ConnectionFactory. Here is the actual queue connection factory meta data that is stored on LDAP that the remote call is retrieving:
Reference Class Name: com.webmethods.jms.impl.WmQueueConnectionFactoryImpl
Type: com.webmethods.jms.impl.WmQueueConnectionFactoryImpl
Content:
<?xml version="1.0" encoding="UTF-8"?><queue-connection-factory version="3.0">
<properties>
<entry key="clusterName" value="XXXXXXXX"/>
<entry key="application" value="JMS"/>
<entry key="brokerListOrder" value="RANDOM"/>
<entry key="sslTruststoreType" value="XXXX"/>
<entry key="brokerCluster" value="XXXXXXXXXXXXXX"/>
<entry key="clusterPolicyName" value="ROUND_ROBIN"/>
<entry key="includeAllBrokers" value="true"/>
<entry key="clientGroup" value="JMSClient"/>
<entry key="clusterCreatedTime" value="1310162227362"/>
<entry key="brokerHost" value="XXXXXXXXXXXXXXXX"/>
<entry key="multisendcount" value="0"/>
<entry key="brokerName" value="XXXXXXXXXXXXXX"/>
<entry key="sslEncrypted" value="false"/>
<entry key="sslKeystoreType" value="XXXXXXX"/>
<entry key="clusterPolicyOverride" value="false"/>
<entry key="clusterRefreshInterval" value="86400000"/>
</properties>
</queue-connection-factory>
So, I'm just wondering, am I missing something in the connection definition or have I mis-configured something?
Thanks,
Steve