13 Replies Latest reply on Sep 25, 2012 11:23 AM by deltafoxtrot

    HornetQMessage ClassCastException during MDB onMessage method (AS 7.1.1 / Remote HornetQ 2.2.14)

    deltafoxtrot Newbie

      Synopsis

      Casting Message object passed to MDB onMessage method to HornetQMessage throws a ClassCastException (java.lang.ClassCastException: org.hornetq.jms.client.HornetQMessage cannot be cast to org.hornetq.jms.client.HornetQMessage - full stack below).  Web application pom references hornetq-core-client and hornetq-jms-client dependencies with version 2.2.13.Final (have tried all variations up to 2.2.21.Final).  Can successfully receive messages from the remote 2.2.14 server - different versions of the underlying HornetQMessage implementation?  Any thoughts or suggestions would be much appreciated.

       

      Environment

      • JBoss AS 7.1.1 (Brontes)
      • Remote HornetQ 2.2.14

       

      JBoss Configuration (modified standalone.xml)

      • Added org.jboss.as.messaging extension
      • Added mdb configuration in EJB subsystem to point to a resource adapter named "remote-hornetq-ra" (configured in messaging subsystem)
      • Added messaging subsystem based on standalone-full.xml (see below for snippet)

       

      Messaging Subsystem Configuration

       

      <subsystem xmlns="urn:jboss:domain:messaging:1.1">
                <hornetq-server>
                          <persistence-enabled>true</persistence-enabled>
                          <journal-file-size>102400</journal-file-size>
                          <journal-min-files>2</journal-min-files>
                          <connectors>
                                    <connector name="remote-jmsxa">
                                              <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
                                              <param key="host" value="localhost"/>
                                              <param key="port" value="5445"/>
                                    </connector>
                                    <netty-connector name="netty" socket-binding="messaging"/>
                                    <netty-connector name="netty-throughput" socket-binding="messaging-throughput">
                                              <param key="batch-delay" value="50"/>
                                    </netty-connector>
                                    <in-vm-connector name="in-vm" server-id="0"/>
                          </connectors>
                          <acceptors>
                                    <netty-acceptor name="netty" socket-binding="messaging"/>
                                    <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">
                                              <param key="batch-delay" value="50"/>
                                              <param key="direct-deliver" value="false"/>
                                    </netty-acceptor>
                                    <in-vm-acceptor name="in-vm" server-id="0"/>
                          </acceptors>
                          <security-settings>
                                    <security-setting match="#">
                                              <permission type="send" roles="guest"/>
                                              <permission type="consume" roles="guest"/>
                                              <permission type="createNonDurableQueue" roles="guest"/>
                                              <permission type="deleteNonDurableQueue" roles="guest"/>
                                    </security-setting>
                          </security-settings>
                          <address-settings>
                                    <address-setting match="#">
                                              <dead-letter-address>jms.queue.DLQ</dead-letter-address>
                                              <expiry-address>jms.queue.ExpiryQueue</expiry-address>
                                              <redelivery-delay>0</redelivery-delay>
                                              <max-size-bytes>10485760</max-size-bytes>
                                              <address-full-policy>BLOCK</address-full-policy>
                                              <message-counter-history-day-limit>10</message-counter-history-day-limit>
                                    </address-setting>
                          </address-settings>
                          <jms-connection-factories>
                                    <connection-factory name="InVmConnectionFactory">
                                              <connectors>
                                                        <connector-ref connector-name="in-vm"/>
                                              </connectors>
                                              <entries>
                                                        <entry name="java:/ConnectionFactory"/>
                                              </entries>
                                    </connection-factory>
                                    <connection-factory name="RemoteConnectionFactory">
                                              <connectors>
                                                        <connector-ref connector-name="netty"/>
                                              </connectors>
                                              <entries>
                                                        <entry name="RemoteConnectionFactory"/>
                                                        <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                                              </entries>
                                    </connection-factory>
                                    <pooled-connection-factory name="hornetq-ra">
                                              <transaction mode="xa"/>
                                              <connectors>
                                                        <connector-ref connector-name="in-vm"/>
                                              </connectors>
                                              <entries>
                                                        <entry name="java:/JmsXA"/>
                                              </entries>
                                    </pooled-connection-factory>
                                    <pooled-connection-factory name="remote-hornetq-ra">
                                              <transaction mode="xa"/>
                                              <connectors>
                                                        <connector-ref connector-name="remote-jmsxa"/>
                                              </connectors>
                                              <entries>
                                                        <entry name="java:/RemoteJmsXA"/>
                                              </entries>
                                    </pooled-connection-factory>
                          </jms-connection-factories>
                          <jms-destinations>
                                    <jms-queue name="testQueue">
                                              <entry name="queue/test"/>
                                              <entry name="java:jboss/exported/jms/queue/test"/>
                                    </jms-queue>
                                    <jms-topic name="testTopic">
                                              <entry name="topic/test"/>
                                              <entry name="java:jboss/exported/jms/topic/test"/>
                                    </jms-topic>
                          </jms-destinations>
                </hornetq-server>
      </subsystem>
      
      

       

      MDB

       

      @MessageDriven(name = "LiveMessageMDB", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
      @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/appserver.data"),
      @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
      @TransactionManagement(value = TransactionManagementType.CONTAINER)
      @TransactionAttribute(value = TransactionAttributeType.REQUIRED)
      public class LiveMessageMDB implements MessageListener {
      
                @Override
                public void onMessage(Message message) {
                       try {
                            HornetQMessage hornetQMessage = (HornetQMessage) message;
                            System.out.println("successfully cast");
                       } catch (Throwable t) {
                            t.printStackTrace();
                      }
                }
      }
      

       

      Stacktrace


      13:16:26,699 ERROR [stderr] (Thread-32 (HornetQ-client-global-threads-1369568615)) 
      java.lang.ClassCastException: org.hornetq.jms.client.HornetQMessage cannot be cast to org.hornetq.jms.client.HornetQMessage
      at com.xyz.messaging.LiveMessageMDB.onMessage(LiveMessageMDB.java:47)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374)
      at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:127)
      at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:135)
      at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
      at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:101)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
      at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:202)
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:306)
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:43)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription$5$1.processInvocation(MessageDrivenComponentDescription.java:184)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
      at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
      at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
      at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)
      at javax.jms.MessageListener$$$view9.onMessage(Unknown Source)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.as.ejb3.inflow.MessageEndpointInvocationHandler.doInvoke(MessageEndpointInvocationHandler.java:140)
      at org.jboss.as.ejb3.inflow.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:73)
      at $Proxy51.onMessage(Unknown Source)
      at org.hornetq.ra.inflow.HornetQMessageHandler.onMessage(HornetQMessageHandler.java:278)
      at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:983)
      at org.hornetq.core.client.impl.ClientConsumerImpl.access$400(ClientConsumerImpl.java:48)
      at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1113)
      at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)