Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Serialization Problem when using HashMap
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ian Bentley  
View profile  
 More options Jan 24 2011, 6:09 pm
From: Ian Bentley <ian.bent...@gmail.com>
Date: Mon, 24 Jan 2011 18:09:16 -0500
Local: Mon, Jan 24 2011 6:09 pm
Subject: [jruby-user] Serialization Problem when using HashMap

I'm using JRuby in a Rails application, which is supported by a Java
backend.  One of the Java Interface functions requires a hashmap be passed
from the JRuby to the Ruby code, and I'm running into an unexpected
RuntimeException in this case.

The Hashmap construction is very straightforward:

def java_map
    hash_map = ::Java::JavaUtil::HashMap.new
    hash_map[:original_document_uri] = "".to_s
end

This construction causes no errors in JRuby, and I can nicely access the map
as expected.

The trouble comes when I attempt to pass this map into Java:

NativeException (java.lang.RuntimeException:
org.jcodings.specific.ASCIIEncoding):
  org/apache/activemq/command/ActiveMQObjectMessage.java:111:in
`storeContent'
  org/apache/activemq/command/ActiveMQObjectMessage.java:162:in `setObject'
  org/apache/activemq/ActiveMQSession.java:380:in `createObjectMessage'
  org/logicblaze/lingo/jms/marshall/DefaultMarshaller.java:60:in
`createRequestMessage'
  org/logicblaze/lingo/jms/JmsClientInterceptor.java:131:in `invoke'
  net/zerofootprint/jms/JmsProxyFactoryBean.java:58:in `invoke'
  org/springframework/aop/framework/ReflectiveMethodInvocation.java:172:in
`proceed'
  org/springframework/aop/framework/JdkDynamicAopProxy.java:202:in `invoke'
  $Proxy15:-1:in ...(I've removed my application specific details here, as
they seem unimportant)

That is the stacktrace that I get on my rails log, and in my java log I get:

java.lang.RuntimeException: org.jcodings.specific.ASCIIEncoding
          ... (similar trace to above)
Caused by: java.io.NotSerializableException:
org.jcodings.specific.ASCIIEncoding
 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
 at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400 )
 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
 at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400 )
 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
 at java.util.HashMap.writeObject(HashMap.java:1000)
        ... (far too long for inclusion)

As you can see, I am using ActiveMQ as my broker, and have the java running
in a Tomcat instance, while the JRuby is running inside Trinidad.

I'm not sure if the HashMap here is a red herring, but it seems that
whatever I put into the hashmap causes this exception.

Finally, I tried using an empty hashmap, and that seemed to work ok.

I hope someone can lend me a bright Idea.

--
Ian Bentley


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paweł Wielgus  
View profile  
 More options Jan 25 2011, 5:15 am
From: Paweł Wielgus <poulw...@gmail.com>
Date: Tue, 25 Jan 2011 11:15:05 +0100
Local: Tues, Jan 25 2011 5:15 am
Subject: Re: [jruby-user] Serialization Problem when using HashMap
Hi Ian,
something You put into the hashmap is using org.jcodings.specific.ASCIIEncoding
so while serializing your map You get:
Caused by: java.io.NotSerializableException: org.jcodings.specific.ASCIIEncoding
and that's why empty map works.

Best greetings,
Paweł Wielgus.

2011/1/25 Ian Bentley <ian.bent...@gmail.com>:

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Bentley  
View profile  
 More options Jan 25 2011, 9:12 am
From: Ian Bentley <ian.bent...@gmail.com>
Date: Tue, 25 Jan 2011 09:12:20 -0500
Local: Tues, Jan 25 2011 9:12 am
Subject: Re: [jruby-user] Serialization Problem when using HashMap

Pawel,

Thanks for getting back.  That was my belief, but I couldn't understand why

    hash_map[:original_document_uri] = "".to_s

would be causing that error.  It turns out that it's the symbol on the lhs
which causes the problem.

Thanks,
Ian

2011/1/25 Paweł Wielgus <poulw...@gmail.com>

--
Ian Bentley

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »