-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Sending Mapped Objects via JMS in ObjectMessages
PostPosted: Thu Sep 08, 2005 5:15 pm 
Newbie

Joined: Thu Sep 08, 2005 5:07 pm
Posts: 3
Hello,

I've looked high and low, and I can't find anyone talking about this problem. I've got an application that needs to send objects mapped by Hibernate attached within ObjectMessages. I don't have any problems with simple objects, but it doesn't work for objects that have collections.
I get a java.io.IoException error on the hibernet Set object. I'm assuming it has something to do with Hibernate's collection interfaces.

Has anyone been able to serialize/deserialize mapped objects with collections via JMS?

Thanks,
James


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 5:23 pm 
Beginner
Beginner

Joined: Tue Apr 05, 2005 4:27 pm
Posts: 40
Location: canada
yeah i send mapped objects over jms to a client. what is the actual error you're getting and when (on sending or on retrieval)? hibernate replaces java collections with its own collection implementation, so say you didn't have the hibernate jar on your client and you tried to send it a mapped object with a collection reference i would expect you'd get a class def not found error... if that's the problem you're having you need to make a choice between putting the hibernate jar on your client's classpath, or replacing the hibernate collections with java collections before you send them to the client.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 5:45 pm 
Newbie

Joined: Thu Sep 08, 2005 5:07 pm
Posts: 3
Hey, thanks for the quick reply...

I send the object in the following way at the server using Spring's JmsTemplate...

Code:
public void sendObjectsAsMessages(MyObject obj) {

           ...

           class MessageNotifier implements MessageCreator{

                private MyObject obj;

                public MessageNotifier(MyObject obj) {
                    this.obj = obj;
                }

                public Message createMessage(Session session)
                        throws JMSException {
                    ObjectMessage message = session.createObjectMessage();
                    message.setObject(ticket);
                    return message;
                }
            }

            MessageNotifier msgCrtr = new MessageNotifier(obj);
           
            jmsTemplate.send(myDestination, msgCrtr);

}



Again, this all works great with simple objects. With objects that contained collections, I was hanging on the following code:

Code:
public void onMessage(Message msg) {

        try {
            ObjectMessage objMsg = (ObjectMessage) msg;
            MyObject obj = (MyObject) objMsg.getObject();
                       
            ... My Implimentation Details...

        } catch (Exception e) {
            e.printStackTrace();
        }

}


The actual error was a ClassCastException, but this was because the object returned on getObject() was a JmsException. When I was debugging, I stepped in and saw that the JmsException had an embedded java.io.IoException on net.sf.hibernate.Set.

However, for some reason, now when I send the ObjectMessage, it isn't even getting to the Queue. So the onMessage() of my listener isn't even getting triggered.

Now, just a note. If I create a new MyObject that isn't retrieved by Hibernate, the object gets serialized and deserialized with no problems. <shrug>

Thanks,
James


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 10:47 am 
Beginner
Beginner

Joined: Tue Apr 05, 2005 4:27 pm
Posts: 40
Location: canada
hm... sorry i don't know if i can be of much more help on this one... i guess the best i can suggest is to debug through the sending of the message and try to figure out what's happening with the original error...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 1:42 pm 
Newbie

Joined: Thu Sep 08, 2005 5:07 pm
Posts: 3
As discovered in another thread, the problems I were having was because of inconsistencies between the Hibernate classes that were serialized and the Hibernate classes that were being deserialized.
I am running JBoss, and the version of Hibernate in JBoss was different than the one in my application. SOOOO... I removed the Hibernate deployer from JBoss (I don't use it anyway), and all is well.

Thanks Gavin!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.