4 Replies Latest reply on Feb 27, 2012 1:17 PM by Justin Bertram

    java.lang.ClassCastException for ConnectorFactory in HornetQ

    Rayan Hacker Newbie

      I am using JBoss AS 7.1 final version with MDB-3 to configer it with IBM MQ, but getting the below issue

       

      ERROR [org.hornetq.ra.inflow.HornetQActivation] (default-short-running-threads-threads - 1) Unable to reconnect org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@67c78f98 destination=MyRemoteQueue destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15): java.lang.ClassCastException: com.ibm.mq.jms.context.WMQInitialContextFactory cannot be cast to org.hornetq.spi.core.remoting.ConnectorFactory
                at org.hornetq.core.client.impl.ClientSessionFactoryImpl$2.run(ClientSessionFactoryImpl.java:1366) [hornetq-core-2.2.11.Final.jar:]
                at org.hornetq.core.client.impl.ClientSessionFactoryImpl$2.run(ClientSessionFactoryImpl.java:1363) [hornetq-core-2.2.11.Final.jar:]
                at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.6.0_26]
                at org.hornetq.core.client.impl.ClientSessionFactoryImpl.instantiateConnectorFactory(ClientSessionFactoryImpl.java:1362) [hornetq-core-2.2.11.Final.jar:]
                at org.hornetq.core.client.impl.ClientSessionFactoryImpl.<init>(ClientSessionFactoryImpl.java:186) [hornetq-core-2.2.11.Final.jar:]
                at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:732) [hornetq-core-2.2.11.Final.jar:]
                at org.hornetq.ra.inflow.HornetQActivation.setupSession(HornetQActivation.java:362) [hornetq-ra-2.2.11.Final.jar:]
                at org.hornetq.ra.inflow.HornetQActivation.setup(HornetQActivation.java:294) [hornetq-ra-2.2.11.Final.jar:]
                at org.hornetq.ra.inflow.HornetQActivation.handleFailure(HornetQActivation.java:566) [hornetq-ra-2.2.11.Final.jar:]
                at org.hornetq.ra.inflow.HornetQActivation$SetupActivation.run(HornetQActivation.java:609) [hornetq-ra-2.2.11.Final.jar:]
                at org.jboss.jca.core.workmanager.WorkWrapper.run(WorkWrapper.java:212)
                at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33)
                at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:801)
                at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45)
                at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:821)
                at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_26]
                at org.jboss.threads.JBossThread.run(JBossThread.java:122)
      

       

       

      Have a look at the below configuration.

       

      MDB

       

             @ActivationConfigProperty(propertyName ="connectorClassName", propertyValue = "com.ibm.mq.jms.context.WMQInitialContextFactory"),
             @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
             @ActivationConfigProperty(propertyName ="connectionURL", propertyValue = "10.20.30.40:1414/SYSTEM.DEF.SVRCONN"),
             @ActivationConfigProperty(propertyName="ConnectionFactoryName", propertyValue="MyMQConnectionFactory"),
             @ActivationConfigProperty(propertyName="destination", propertyValue="MyMQQueue")
      

       

      As it would require few jars from MQ side created a module for it

       

      <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.1" name="example.mq">
          <resources>
              <resource-root path="mqcontext.jar"/>
              <resource-root path="com.ibm.mq.commonservices.jar"/>
              <resource-root path="com.ibm.mq.headers.jar"/>
              <resource-root path="com.ibm.mq.jar"/>
              <resource-root path="com.ibm.mq.jmqi.jar"/>
              <resource-root path="com.ibm.mq.pcf.jar"/>
              <resource-root path="com.ibm.mqjms.jar"/>
              <resource-root path="dhbcore.jar"/>
          </resources>
        
          <dependencies>
              <module name="java.rt" />
          </dependencies>
      </module>
      

       

      Note: I had added the dependencies for "rt.jar", because I was getting an issue which got resloved by adding this

       

      Now I also had to add the dependencies in hornetq for my MQ module "example.mq" or else I was not able to load the classes of MQ and was getting the error

       

      ERROR [org.hornetq.ra.inflow.HornetQActivation] (default-short-running-threads-threads - 1) Unable to reconnect org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@60acc399 destination=MyRemoteQueue destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15): java.lang.IllegalArgumentException: Could not find class com.ibm.mq.jms.context.WMQInitialContextFactory
                at org.hornetq.utils.ClassloadingUtil.newInstanceFromClassLoader(ClassloadingUtil.java:40) [hornetq-core-2.2.11.Final.jar:]
                at org.hornetq.core.client.impl.ClientSessionFactoryImpl$2.run(ClientSessionFactoryImpl.java:1366) [hornetq-core-2.2.11.Final.jar:]
                at org.hornetq.core.client.impl.ClientSessionFactoryImpl$2.run(ClientSessionFactoryImpl.java:1363) [hornetq-core-2.2.11.Final.jar:]
                at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.6.0_26]
      

       

       

      <module xmlns="urn:jboss:module:1.1" name="org.hornetq">
      .
      .
      . 
          <dependencies>
      . 
      .
      . 
              <module name="example.mq"/>
          </dependencies>
      </module>
      

       

      Please let me know if I am on the right path or have missed out some configurations