RSS
 

Flex, Java Remoting, and JMS [null message body]

07 Aug

So I was pounding out some code this afternoon, ran into a small snag and thought I’d post. Neuro-physiologists tell us that we better remember what we write down so here goes.

Similar to my post a few months ago, I made a simple omission in my coding flurry.

I was working with a backend Java class that published messages to [ActiveMQ] JMS. I wrote up a simple VO class to publish via JMS.


package com.dl.sifagents.vo;

import java.io.Serializable;

public class ZISEventVO implements Serializable
{
public String eventType = "";
public String payloadPackage = "";
public String payloadElement = "";
public String xml = "";
}

On the Flex side, I wrote up an AS3 implementation


package com.dl.sifagents.vo
{
[RemoteClass(alias="com.dl.sifagents.vo.ZISEventVO")]
[Bindable]
public class ZISEventVO
{
public var eventType:String;
public var payloadPackage:String;
public var payloadElement:String;
public var xml:String;
}
}

I published the VO to JMS…


public void publishObjectToJMS(Serializable o)
{
try {
ObjectMessage message = _pubSession.createObjectMessage();
message.setObject(o);
_publisher.publish(message, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, 5 * 60 * 1000);
} catch (JMSException e1) {
e1.printStackTrace();
}
}

I received the JMS message in Flex (via BlazeDS) but the message body was null. I checked and doubled checked my Java VO implementation vs AS3 VO implementation and couldn’t find any naming conflicts or errors.

Then it hit me, in my haste I’d forgotten to upload the Java VO class to BlazeDS (i.e. to the WEB-INF/classes folder)!

That’s my piece of humble pie for the week :) Back to work.

 
3 Comments

Posted in BlazeDS, JMS, Java

 

Leave a Reply

 

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

 
  1. Doug McCall

    March 24, 2009 at 2:44 pm

    I was curious if you’ve ever experienced this: If I don’t include any of the java objects in the WEB-INF/classes folder, I can see that the messages from the ActiveMQ topics are at least attempting to make it through BlazeDS to the Flex client (I get the nice unable to convert JMS to Flex errors). If I copy the java object in to the WEB-INF/classes folder, however, BlazeDS no longer shows any recognition of receiving messages from the ActiveMQ topics. Unfortunately, the resources available for using JMS+ObjectMessages is practically non-existent beyond the BlazeDS configuration files :( . I was wondering if you’ve every experienced this or had any thoughts?

     
  2. Joshua

    March 25, 2009 at 10:52 pm

    Doug,
    I haven’t had a chance to work with the JMS/BlazeDS combo lately so I’m afraid I don’t have much insight off hand…

    I’d look at the logging options available and drill down from there.

    Josh

     
  3. Greg

    April 1, 2009 at 3:12 pm

    I’m getting the same error.
    What I am trying to do is to send an object from the Flex to a Java receiver.
    I have a couple of member variables all of type String and for each variable I have setter and getter.
    I compiled the java class (same name as the flex’s class) and put it in the “BlazeDS Flex java JMS bridge\tomcat\webapps\blazeds\WEB-INF\classes”

    This is what I’m doing in Flex:

    var msg:AsyncMessage = new AsyncMessage();
    var log:LogInfo = new LogInfo();
    log.setMessage(“Something Happened”);
    log.setMethodname(“Test Method Name”);
    msg.body = log;
    publisher.send(msg);

    I’m getting the msg through however on the java side when I try to retrieve it:
    flexLog = (LogInfo) objectMessage.getObject();
    System.out.println(“getMessage: ” + flexLog.getMessage()); System.out.println(“getMessage: ” + flexLog.getMethodname());

    (Just printing it for now) …ALL is NULL.
    What am I doing wrong?
    Any suggestion?
    Thanks