4 Replies Latest reply on Aug 19, 2011 8:14 AM by Laurent Vandwalle

    NPE sending an ObjectMessage

    Gabriele Contini Newbie

      Hi!

      I'm using jboss6 final (Hornetq 2.1.2?) I'm trying to send an ObjectMessage on a queue. The sender.send method completes correctly but the message is not sent, and in server logs i'm getting this message:

       

       

      {code}

      10:23:00,952 ERROR [ServerSessionPacketHandler] Caught unexpected exception: java.lang.NullPointerException

                at org.hornetq.core.server.impl.ServerSessionImpl.send(ServerSessionImpl.java:992) [:6.0.0.Final]

                at org.hornetq.core.protocol.core.ServerSessionPacketHandler.handlePacket(ServerSessionPacketHandler.java:461) [:6.0.0.Final]

                at org.hornetq.core.protocol.core.impl.ChannelImpl.handlePacket(ChannelImpl.java:471) [:6.0.0.Final]

                at org.hornetq.core.protocol.core.impl.RemotingConnectionImpl.doBufferReceived(RemotingConnectionImpl.java:451) [:6.0.0.Final]

                at org.hornetq.core.protocol.core.impl.RemotingConnectionImpl.bufferReceived(RemotingConnectionImpl.java:412) [:6.0.0.Final]

                at org.hornetq.core.remoting.server.impl.RemotingServiceImpl$DelegatingBufferHandler.bufferReceived(RemotingServiceImpl.java:459) [:6.0.0.Final]

                at org.hornetq.core.remoting.impl.invm.InVMConnection$1.run(InVMConnection.java:135) [:6.0.0.Final]

                at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100) [:6.0.0.Final]

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_23]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_23]

                at java.lang.Thread.run(Thread.java:662) [:1.6.0_23]

      {code}

       

      Looking at HornetQ source at line 992 of ServerSessionImpl i find:

       

          if (message.getAddress().equals(managementAddress))

       

      Here is a snippet from my jboss.xml

      {code:xml}

      <message-driven>

                <ejb-name>BloccoServiceQueue</ejb-name>

                <activation-config>

                          <activation-config-property>

                                    <activation-config-property-name>destinationType</activation-config-property-name>

                                    <activation-config-property-value>javax.jms.Queue</activation-config-property-value>

                          </activation-config-property>

                          <activation-config-property>

                                    <activation-config-property-name>destination</activation-config-property-name>

                                    <activation-config-property-value>queue/BloccoServiceQueue</activation-config-property-value>

                          </activation-config-property>

                </activation-config>

                <!-- destination-jndi-name>queue/BloccoServiceQueue</destination-jndi-name -->

                <mdb-user>guest</mdb-user>

                <mdb-passwd>guest</mdb-passwd>

                <create-destination>true</create-destination>

      </message-driven>

      {code:xml}

       

      Here is my MDB declaration:

      {code}

      @javax.ejb.MessageDriven(name = "BloccoServiceQueue", mappedName = "queue/BloccoServiceQueue")

      public class BloccoServiceQueueMDBBeanImpl implements javax.jms.MessageListener {

      {code}

       

      Here is my mdb client (inside an ejb)

      {code}

      @javax.annotation.Resource(mappedName = "java:/JmsXA")

      protected javax.jms.QueueConnectionFactory queueFactory;

      @javax.annotation.Resource(mappedName = "queue/BloccoServiceQueue")

      protected javax.jms.Destination bloccoServiceQueue;

      ....

      private void sendMsg() {

                try {

                          final Queue dest = (Queue) this.bloccoServiceQueue;

                          final QueueConnection connection = this.queueFactory.createQueueConnection();

                          final QueueSession qsess = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

                          final QueueSender sender = qsess.createSender(dest);

                          final ObjectMessage message = qsess.createObjectMessage("simplePayloadToTestClassloadingIssues");

                                    LOGGER.info("Publishing Message to a Queue: " + this.bloccoServiceQueue);

                                    sender.send(message);

                          sender.close();

                          qsess.close();

                          connection.close();

                } catch (final Exception e) {

                          LOGGER.error("JMS provider fails to set the object due to some internal error.", e);

                }

      }

      {code}

       

      * Until now i haven't been able to reproduce this error on a simple example.

      * I've been trying to send an ObjectMessage whose payload is a string to avoid classloader issues. In real i need to send a complex object (i'm not worried by performances right now).

      * If i send a TextMessage everything works fine.

       

      Other people seem to have a StackTrace like mine https://issues.jboss.org/browse/HORNETQ-489

      In can provide further information/configuration.

      Any ideas?

      Thanks in advance.

      Gabriele