5 Replies Latest reply on May 12, 2014 10:06 AM by jbertram

    ClassCastException with JMSQueueControl

    alansmanne

      Hi,

       

      I'm trying to list all messages from my HornetQ Queue, but I've got a very strange exception :

       

      MBeanServerConnection server = ManagementFactory.getPlatformMBeanServer();
      ...
      ObjectName queueObjectName = new ObjectName("jboss.as:subsystem=messaging,hornetq-server=default,jms-queue=testQueue");

      JMSQueueControl queueControl = (JMSQueueControl)MBeanServerInvocationHandler.newProxyInstance(server,queueObjectName,JMSQueueControl.class,false);    

       

      queueControl.listMessages(null);

       

      Throws

       

       

       

      2014-04-30 10:43:31,868 ERROR [stderr] java.lang.ClassCastException: [Ljavax.management.openmbean.CompositeData; cannot be cast to [Ljava.util.Map;

       

       

      2014-04-30 10:43:31,869 ERROR [stderr] at $Proxy101.listMessages(Unknown Source)

       

      This is thrown from a servlet inside the same Jboss than the one with the Queue...

       

      If this is not supported anymore, is is possible to access the message content from it's id?

       

      Regards,

        • 1. Re: ClassCastException with JMSQueueControl
          jbertram

          What version of JBoss AS are you using and what JVM version is running it?

          • 2. Re: ClassCastException with JMSQueueControl
            alansmanne

            JBoss AS 7.1.1.Final "Brontes" on a Java 1.6 JDK (I'm using the embedded HornetQ module in /jboss/../modules/org/hornet)

            • 3. Re: ClassCastException with JMSQueueControl
              jbertram

              I think the name of the MBean would be different in AS 7.1.1.  The name "jboss.as:subsystem=messaging,hornetq-server=default,jms-queue=testQueue" looks like the old style name from previous versions of JBoss AS.  If you connect to the JVM where JBoss AS is running with JConsole and look at the MBeans do you see any related to HornetQ?

              • 4. Re: ClassCastException with JMSQueueControl
                alansmanne

                With JConsole, I can see jboss.as:subsystem=messaging,hornetq-server=default,jms-queue=testQueue, so this seems right.

                 

                I've also tried

                ObjectName queueObjectName = ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queue.getQueueName());

                QueueControl queueControl = (QueueControl)MBeanServerInvocationHandler.newProxyInstance(server,queueObjectName,QueueControl.class,false);    

                And this returned

                2014-05-05 16:06:39,815 ERROR [stderr] javax.management.InstanceNotFoundException: org.hornetq:module=JMS,type=Queue,name="testQueue"

                 

                I've tried to call the methods from JConsole. There is no error (so it only works remotely, not locally?), but the values are "wrong" (message counter is always 0, listMessages(AsJSON) is always empty, etc.)

                • 5. Re: ClassCastException with JMSQueueControl
                  jbertram

                  I'm not sure what the problem could be.  Can you try on WildFly or provide a reproducible test-case?