8 Replies Latest reply on Nov 21, 2012 9:49 AM by Justin Bertram

    Failed to decode packet: java.lang.IllegalArgumentException: HQ119074: Invalid type: -1

    srinivasa sanda Newbie

      Hi ,

       

      I am trying to send message using jms, into hornetq server 2.2.14 and 2.3.0 ( I tried using both servers)

      Javaversion:     java version "1.6.0_29"

      JbossVersion: jboss7.1.1

      Hornetq Server Version : 2.2.14

      os : windows 7

       

      I created a standalone program to push the message

       

      public class SendMesage {

          public static void main(final String[] args) throws IOException,ParserConfigurationException, SAXException,    TransformerFactoryConfigurationError, TransformerException

          {

             

              Connection connection = null;

              InitialContext ic = getInitialContext();

       

              try {

                  ConnectionFactory cf = (ConnectionFactory) ic.lookup("jms/RemoteConnectionFactory");

       

                  Queue queue = (Queue) ic.lookup("jms/queue/snd_createPR_Request_gw");

       

                  connection = cf.createConnection("guest", "india");

                  Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);

                  MessageProducer sender = session.createProducer(queue);

                  File xmlFile = new File("xml/final_request.xml");

                  FileInputStream reader = new FileInputStream(xmlFile);

                  int length = (int) xmlFile.length();

                  byte[] bytes = new byte[length];

                  reader.read(bytes);

                  TextMessage message = session.createTextMessage(new String(bytes));

                  sender.send(message);

                  System.out.println("The message was successfully sent to the "+ queue.getQueueName() + " queue");

       

                  connection.start();

       

              }

              catch (NamingException e)

              {

                  e.printStackTrace();

              }

              catch (JMSException e)

              {

                  e.printStackTrace();

              }

              System.out.println("Queue  exists");

          }

       

          private static InitialContext getInitialContext()

          {

              try {

       

                  Hashtable<Object, String> env = new Hashtable<Object, String>();

                  env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

                  env.put(Context.PROVIDER_URL, "remote://localhost:5445");

                  InitialContext ctx = new InitialContext(env);

                  return ctx;

              } catch (Exception e) {

                  e.printStackTrace();

              }

              return null;

          }

       

      }

       

      I have reffered the jars  are-->

      hornetq-core-client.jar

      hornetq-core.jar

      hornetq-jms-client.jar

      hornetq-jms.jar

      hornetq-ra-2.2.13.Final.jar

      javax.jms-api-2.0-b04.jar

      jboss-client.jar

      netty.jar

       

      I had not changed any of the configuration in hornetq server. I added some queue names in hornetq-jms.xml

       

      In Standalone program i got Exception as

       

      Exception in thread "main" javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: Operation failed with status WAITING]

          at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)

          at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121)

          at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)

          at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

          at javax.naming.InitialContext.init(InitialContext.java:223)

          at javax.naming.InitialContext.<init>(InitialContext.java:197)

          at SendHelloWorldSMS.main(SendHelloWorldSMS.java:46)

      Caused by: java.lang.RuntimeException: Operation failed with status WAITING

          at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:89)

          at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:56)

          at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateCachedNamingStore(InitialContextFactory.java:166)

          at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:139)

          at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:104)

          ... 5 more

       

       

      and in Hornetq Server Console I got

       

      11:34:58,098 ERROR [org.hornetq.core.server] HQ114036: Failed to decode packet: java.lang.IllegalArgumentException: HQ119074: Invalid type: -1

              at org.hornetq.core.protocol.core.impl.PacketDecoder.decode(PacketDecoder.java:582) [hornetq-core-client.jar:]

              at org.hornetq.core.protocol.core.impl.RemotingConnectionImpl.bufferReceived(RemotingConnectionImpl.java:473) [hornetq-core-client.jar:]

              at org.hornetq.core.remoting.server.impl.RemotingServiceImpl$DelegatingBufferHandler.bufferReceived(RemotingServiceImpl.java:533) [hornetq-core-client.jar:]

              at org.hornetq.core.remoting.impl.netty.HornetQChannelHandler.messageReceived(HornetQChannelHandler.java:72) [hornetq-core-client.jar:]

              at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:95) [jboss-mc.jar:]

              at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) [jboss-mc.jar:]

              at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:792) [jboss-mc.jar:]

              at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:281) [jboss-mc.jar:]

              at org.hornetq.core.remoting.impl.netty.HornetQFrameDecoder2.decode(HornetQFrameDecoder2.java:169) [hornetq-core-client.jar:]

              at org.hornetq.core.remoting.impl.netty.HornetQFrameDecoder2.messageReceived(HornetQFrameDecoder2.java:134) [hornetq-core-client.jar:]

              at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75) [jboss-mc.jar:]

              at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) [jboss-mc.jar:]

              at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) [jboss-mc.jar:]

              at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) [jboss-mc.jar:]

              at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) [jboss-mc.jar:]

              at org.jboss.netty.channel.socket.oio.OioWorker.process(OioWorker.java:72) [jboss-mc.jar:]

              at org.jboss.netty.channel.socket.oio.AbstractOioWorker.run(AbstractOioWorker.java:73) [jboss-mc.jar:]

              at org.jboss.netty.channel.socket.oio.OioWorker.run(OioWorker.java:52) [jboss-mc.jar:]

              at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102) [jboss-mc.jar:]

              at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) [jboss-mc.jar:]

              at org.jboss.netty.util.VirtualExecutorService$ChildExecutorRunnable.run(VirtualExecutorService.java:176) [jboss-mc.jar:]

              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_29]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_29]

              at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_29]

       

       

      Please suggest me to resolve this exeception.. Please give some solution  to solve out this. I wil be Thankful to you....