ActiveMQ NullPointer exceptions when creating objectmessages.

Posted on March 24, 2009. Filed under: Java |

At the moment, I’m working with Flex, BlazeDS en ActiveMQ in a Spring application. I’m using Flex to display some of my database contents, and for direct communication, I use BlazeDS, and for updating the view, I use JMS (ActiveMQ) in combation with BlazeDS. It works by publishing information to topics, which can be easily done using the following code:

    private void sendJmsUpdate() {
        this.jmsTemplate.send(this.destination, new MessageCreator() {
            public Message createMessage(Session session) throws JMSException {
                return session.createObjectMessage(new ArrayList<TodoItem>(getList()));

The above code uses the Spring JmsTemplate to created messages and send them to the topic. However, when I tried this, I got this exception:

at org.apache.activemq.ActiveMQMessageTransformation.copyProperties(
at org.apache.activemq.ActiveMQMessageTransformation.transformMessage(
at org.apache.activemq.ActiveMQSession.send(
at org.apache.activemq.ActiveMQMessageProducer.send(
at org.apache.activemq.ActiveMQMessageProducerSupport.send(
at org.springframework.jms.core.JmsTemplate.doSend(
at org.springframework.jms.core.JmsTemplate.doSend(
at org.springframework.jms.core.JmsTemplate$3.doInJms(
at org.springframework.jms.core.JmsTemplate.execute(
at org.springframework.jms.core.JmsTemplate.send(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(

After a lot of Googling, I found nothing (well, a bug report somewhere, which was totally unrelated to what I had here). Why did I get this error?? I know my remoting was working (String were send), my objects were fine since I could get the list manually by doing a Refresh with the flex client itself (which used ≶mx:RemoteObject>) to call the Spring service…. And then it occured to me that the explanation was already here. I just overlooked it (hate it when that happens): the BlazeDS service apparently doesn’t require the objects (TodoItem) to be Serializable…. JMS ofcourse does! Argh! I forgot to implement Serializable here!

So, if you ever encounter this message, which is hardly descriptive at all, check your objects to see if they are all serializable. It saves a lot of debugging!


Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

One Response to “ActiveMQ NullPointer exceptions when creating objectmessages.”

RSS Feed for Don’t mind the language Comments RSS Feed

Could it be that it’s too costly to introspect passed objects, checking whether they are able to serialize or not? Either way they could catch the NPE and rethrow it with some suggestions like


Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: