title: Simple web app looking for JMS messages on a queue in JBoss 5.1
body: <p>I've created a simple spring webapp which fires off a thread and queries a jms Queue for messages. The web app is running in JBoss 5.1. I'm using JBoss Developer Studio to create and run the app within the application server. The application server too, is being run within JBoss Developer Studio.</p>
  
  <p>The thread is running correctly and is attempting to query the Queue every 5 seconds. However, when attempting to create a connection to the queue, I am getting an exception.</p>
  
  <pre><code>17:48:47,152 ERROR [JBossConnectionFactory] Failed to download and/or install client side AOP stack
  org.jboss.jms.exception.MessagingJMSException: Failed to invoke
      at org.jboss.jms.client.delegate.DelegateSupport.handleThrowable(DelegateSupport.java:271)
      at org.jboss.jms.client.delegate.DelegateSupport.doInvoke(DelegateSupport.java:205)
      at org.jboss.jms.client.delegate.DelegateSupport.doInvoke(DelegateSupport.java:160)
      at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.org$jboss$jms$client$delegate$ClientConnectionFactoryDelegate$getClientAOPStack$aop(ClientConnectionFactoryDelegate.java:251)
      at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.getClientAOPStack(ClientConnectionFactoryDelegate.java)
      at org.jboss.jms.client.ClientAOPStackLoader.load(ClientAOPStackLoader.java:75)
      at org.jboss.jms.client.JBossConnectionFactory.createConnectionInternal(JBossConnectionFactory.java:192)
      at org.jboss.jms.client.JBossConnectionFactory.createQueueConnection(JBossConnectionFactory.java:101)
      at org.jboss.jms.client.JBossConnectionFactory.createQueueConnection(JBossConnectionFactory.java:95)
      at com.thales.jms.service.JBossJmsService.reconnectPointToPoint(JBossJmsService.java:87)
      at com.thales.jms.service.JBossJmsService.receive(JBossJmsService.java:53)
      at com.thales.jms.service.JmsReceiverThread.run(JmsReceiverThread.java:19)
      at java.lang.Thread.run(Unknown Source)
  Caused by: java.lang.ClassCastException: org.jboss.jms.wireformat.ConnectionFactoryGetClientAOPStackRequest cannot be cast to org.jboss.jms.wireformat.RequestSupport
      at org.jboss.jms.server.remoting.JMSServerInvocationHandler.invoke(JMSServerInvocationHandler.java:150)
      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:930)
      at org.jboss.remoting.transport.local.LocalClientInvoker.invoke(LocalClientInvoker.java:106)
      at org.jboss.remoting.Client.invoke(Client.java:2034)
      at org.jboss.remoting.Client.invoke(Client.java:877)
      at org.jboss.remoting.Client.invoke(Client.java:865)
      at org.jboss.jms.client.delegate.DelegateSupport.doInvoke(DelegateSupport.java:189)
      ... 11 more
  17:48:47,152 ERROR [STDERR] java.lang.RuntimeException: Failed to download and/or install client side AOP stack
  17:48:47,152 ERROR [STDERR]     at org.jboss.jms.client.JBossConnectionFactory.createConnectionInternal(JBossConnectionFactory.java:199)
  17:48:47,152 ERROR [STDERR]     at org.jboss.jms.client.JBossConnectionFactory.createQueueConnection(JBossConnectionFactory.java:101)
  17:48:47,152 ERROR [STDERR]     at org.jboss.jms.client.JBossConnectionFactory.createQueueConnection(JBossConnectionFactory.java:95)
  17:48:47,152 ERROR [STDERR]     at com.thales.jms.service.JBossJmsService.reconnectPointToPoint(JBossJmsService.java:87)
  17:48:47,152 ERROR [STDERR]     at com.thales.jms.service.JBossJmsService.receive(JBossJmsService.java:53)
  17:48:47,152 ERROR [STDERR]     at com.thales.jms.service.JmsReceiverThread.run(JmsReceiverThread.java:19)
  17:48:47,152 ERROR [STDERR]     at java.lang.Thread.run(Unknown Source)
  17:48:47,152 ERROR [STDERR] Caused by: org.jboss.jms.exception.MessagingJMSException: Failed to invoke
  17:48:47,152 ERROR [STDERR]     at org.jboss.jms.client.delegate.DelegateSupport.handleThrowable(DelegateSupport.java:271)
  17:48:47,152 ERROR [STDERR]     at org.jboss.jms.client.delegate.DelegateSupport.doInvoke(DelegateSupport.java:205)
  17:48:47,152 ERROR [STDERR]     at org.jboss.jms.client.delegate.DelegateSupport.doInvoke(DelegateSupport.java:160)
  17:48:47,152 ERROR [STDERR]     at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.org$jboss$jms$client$delegate$ClientConnectionFactoryDelegate$getClientAOPStack$aop(ClientConnectionFactoryDelegate.java:251)
  17:48:47,152 ERROR [STDERR]     at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.getClientAOPStack(ClientConnectionFactoryDelegate.java)
  17:48:47,152 ERROR [STDERR]     at org.jboss.jms.client.ClientAOPStackLoader.load(ClientAOPStackLoader.java:75)
  17:48:47,152 ERROR [STDERR]     at org.jboss.jms.client.JBossConnectionFactory.createConnectionInternal(JBossConnectionFactory.java:192)
  17:48:47,152 ERROR [STDERR]     ... 6 more
  17:48:47,152 ERROR [STDERR] Caused by: java.lang.ClassCastException: org.jboss.jms.wireformat.ConnectionFactoryGetClientAOPStackRequest cannot be cast to org.jboss.jms.wireformat.RequestSupport
  17:48:47,152 ERROR [STDERR]     at org.jboss.jms.server.remoting.JMSServerInvocationHandler.invoke(JMSServerInvocationHandler.java:150)
  17:48:47,152 ERROR [STDERR]     at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:930)
  17:48:47,152 ERROR [STDERR]     at org.jboss.remoting.transport.local.LocalClientInvoker.invoke(LocalClientInvoker.java:106)
  17:48:47,152 ERROR [STDERR]     at org.jboss.remoting.Client.invoke(Client.java:2034)
  17:48:47,152 ERROR [STDERR]     at org.jboss.remoting.Client.invoke(Client.java:877)
  17:48:47,152 ERROR [STDERR]     at org.jboss.remoting.Client.invoke(Client.java:865)
  17:48:47,152 ERROR [STDERR]     at org.jboss.jms.client.delegate.DelegateSupport.doInvoke(DelegateSupport.java:189)
  17:48:47,153 ERROR [STDERR]     ... 11 more
  </code></pre>
  
  <p>The webapp is built with dependencies to two jboss libraries. These have been extracted from the JBoss 5.1 server itself. The libraries are:</p>
  
  <pre><code>jboss-javaee.jar
  jboss-messaging-client.jar
  </code></pre>
  
  <p>The code to connect to the queue is as follows:</p>
  
  <pre><code>Hashtable env = new Hashtable();
  env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
  env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
  env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
  
  
  Context ic = new InitialContext(env);
  QueueConnectionFactory connectionFactory = (QueueConnectionFactory) ic.lookup("ConnectionFactory");
  Queue queue = (Queue) ic.lookup("queue/DLQ");
  connection = connectionFactory.createQueueConnection();
  session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
  receiver = session.createReceiver(queue);
  </code></pre>
  
  <p>The exception occurs when attempting to create the queue connection (connectionFactory.createQueueConnection();). I've been googling around all afternoon and have had no look in finding anything to help resolve my problem.</p>
  
  <p>Does anyone now why the exception is occurring and how to solve it? I have a feeling it's an issue with the jboss jars I'm building the web app with. If anyone can help it would be greatly appreciated.</p>
  
  <p>Thanks and sorry for the long post!</p>