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

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

    srinivasasanda

      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....

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

          OfCourse I too faced the same problem in that versions of HornetQ while using JMS Client.But,I was unable to resolve that time.Is there anyone to suggest me.

           

          • 2. Re: Failed to decode packet: java.lang.IllegalArgumentException: HQ119074: Invalid type: -1
            jbertram

            It's pretty simple really.  You are using the wrong port for your JNDI lookup (i.e. 5445).  Use the right port (i.e. 4447) and you won't get this particular error.

             

            For reference, you can use http://www.jboss.org/jdf/quickstarts/jboss-as-quickstart/helloworld-jms/ as a model for stand-alone JMS clients.

            • 3. Re: Failed to decode packet: java.lang.IllegalArgumentException: HQ119074: Invalid type: -1
              srinivasasanda

              Hi Justin Bertram,

               

              I am using HornetQ-Server2.2.14. and I had a standalone jms program to publishing the messages. 

               

              Configuring the queue in the jboss7 (Standalone-full.xml) and staring jboss 7 server  and sending to message using standalone jms program which i have successfull completed.

               

              I am using separate HornetQ server  which is running at 5445 port.

              Even i am able to send the message using  org.hornetq.api.

               

              but i am not able to send the message using java javax.jms-api.

               

              Thanks for reply but won't help me. if possible give me some solution for this.

              • 4. Re: Failed to decode packet: java.lang.IllegalArgumentException: HQ119074: Invalid type: -1
                jbertram

                I am using HornetQ-Server2.2.14. and I had a standalone jms program to publishing the messages.

                Sorry about that.  I looked at this bit of code in your client and assumed you were hitting AS7 since that's what these properties are for:

                 

                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;
                

                 

                If you are hitting standalone HornetQ, then you should use the right JNDI properties (including the right port).  For example:

                 

                Hashtable<Object, String> env = new Hashtable<Object, String>();
                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");
                InitialContext ctx = new InitialContext(env);
                return ctx;
                

                 

                These properties are used in just about every HornetQ JMS example shipped in the distribution (albeit via a properties file).

                • 5. Re: Failed to decode packet: java.lang.IllegalArgumentException: HQ119074: Invalid type: -1
                  srinivasasanda

                  Hi Justin Bertram,

                   

                  I had done as above configurations what u u have given. the same configuration also i kept in the jndi.properties in hornetq configurations also.

                  But now i am get  this error

                   

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

                  System.out.println(cf.toString());

                   

                  ConnectionFactory:

                  --------------------------

                  HornetQConnectionFactory [serverLocator=ServerLocatorImpl [initialConnectors=[TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=localhost], discoveryGroupConfiguration=null], clientID=null, dupsOKBatchSize=1048576, transactionBatchSize=1048576, readOnly=false]

                   

                  While creating connection

                  connection = cf.createConnection();  // I am getting error at this line.

                   

                  javax.jms.JMSException: Failed to create session factory

                      at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:588)

                      at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:108)

                      at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:103)

                      at SendMesage.main(SendMesage.java:41)

                  Caused by: java.lang.NullPointerException

                      at org.hornetq.core.client.impl.ServerLocatorImpl.assertOpen(ServerLocatorImpl.java:1869)

                      at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:748)

                      at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:584)

                      ... 3 more

                  • 6. Re: Failed to decode packet: java.lang.IllegalArgumentException: HQ119074: Invalid type: -1
                    jbertram

                    Can you clarify what version of the HornetQ client libraries you are using?  I'm asking because I don't see line 1869 in org.hornetq.core.client.impl.ServerLocatorImpl for HornetQ 2.2.14.  See https://github.com/hornetq/hornetq/blob/HornetQ_2_2_14_Final/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java.

                    • 7. Re: Failed to decode packet: java.lang.IllegalArgumentException: HQ119074: Invalid type: -1
                      srinivasasanda

                      Hi Justin Bertram,

                       

                      Fine Thankyou and Thankyou very much,

                      if i am right my understanding is we have done with jnp client

                       

                      Problem is I was testing with two versions. hornetq 2.2.14 and hornetq2.3.0 so jars mismatch. I corrected It.

                       

                      How can i change contextfactory and  remote connection provider url.

                       

                      "org.jnp.interfaces.NamingContextFactory" to "org.jboss.naming.remote.client.InitialContextFactory"

                       

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

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

                       

                      And change lookup from /ConnectionFactory to /RemoteConnectionFactory

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

                       

                      what are all configurations are required , i changed in jndi properties any other more are required

                      So that i can connect to remote hornetq server using jboss client.

                      • 8. Re: Failed to decode packet: java.lang.IllegalArgumentException: HQ119074: Invalid type: -1
                        jbertram

                        I don't understand your question.  I've already enumerated the code changes you needed to make to your client in order to connect to standalone HornetQ 2.2.14.