Forum: JRuby JRuby and Java serialization

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
636c843240fc848f011aeff882c8c52d?d=identicon&s=25 marabout (Guest)
on 2009-03-02 14:20
(Received via mailing list)
Hi,

I am trying to produce a small Ruby DSL above a Java library that
requires some objects to be Serializable.

However, I am facing problems when a JRuby class extends a Java
Serializable class.

For example:

#----

require 'java'

class MyList < java.util.ArrayList
end

oos = java.io.ObjectOutputStream.new(java.lang.System.out)
oos.writeObject(MyList.new)

#----

Although ArrayList is Serializable, executing this little code fails
with :

  java.io.NotSerializableException:
org.jruby.javasupport.proxy.JavaProxyConstructor$2 (NativeException)
  ...

I am using JRuby 1.1.6 (on Mac OS X jdk 1.6), but I have the same
exception using JRuby 1.2 RC1.


Does anyone have a clue about this ? Did I miss something ?

Thanks.

--
Greg

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

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-03-05 18:45
(Received via mailing list)
marabout wrote:
> #----
>
> Although ArrayList is Serializable, executing this little code fails with :
>
>     java.io.NotSerializableException:
> org.jruby.javasupport.proxy.JavaProxyConstructor$2 (NativeException)
>     ...

Unfortunately this is not currently supported. In response to the Ruby
subclass of a Java class, we create a number of other structures used
for Ruby dispatching. And in general, this wouldn't work even if those
structures weren't present, since there's going to be no way to identify
on the *other* side what actual class to use when deserializing. I think
your best bet would be to either create your own wrapper around
ArrayList that you can use inside Ruby, or reopen ArrayList to add some
utility methods.

This may work in the future when Java Integration gets its next
overhaul, since that should start to bring Ruby and Java types a bit
closer together.

- Charlie

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

    http://xircles.codehaus.org/manage_email
F7e175b37a4c69709ef75c28792f2b32?d=identicon&s=25 Ikai Lan (Guest)
on 2009-03-10 05:45
(Received via mailing list)
Attachment: winmail.dat (3 KB)
Is there any way JRuby and Rails can leverage Jetty continuations for
Comet/long-polling type applications?  One implementation I can think of
involves using different context roots for the Rails portion and the
Comet portion, but we'd lose out on access to Rails models.

For anyone that is curious: Jetty Continuations allow threads to be
suspended so that a client browser can open an XHR request and leave it
open until data returns without consuming a thread in its idle state:

http://ajaxian.com/archives/java-web-server-jetty-...

Ikai
78c939ec0390fe89d78cdbf85e8e6856?d=identicon&s=25 Rich Manalang (Guest)
on 2009-10-23 20:50
(Received via mailing list)
Hi Ikai.  I know you posted this back in March, but thought I'd update
with
something I found recently.  I just discovered the Atmosphere Framework
which is a portable ajax push/comet framework written in Java.  One of
the
committers posted a tutorial on how to get this working on JRuby (
http://weblogs.java.net/blog/jfarcand/archive/2009...
).

I'm trying it now.  If it works... it looks like a promising solution
for
comet/long polling requirements on JRuby based apps.

Rich
F42705a7d10297059f298752e5ba4ed2?d=identicon&s=25 Mathijs Kwik (Guest)
on 2009-10-23 21:02
(Received via mailing list)
I found
http://www.igvita.com/2009/10/21/nginx-comet-low-l...
other day.
Works like a charm.
Since I put nginx as frontend webserver anyway(load balancing, static
file
handling), this solution is great.
It has built-in (highly configurable) buffering (queue), so it can
handle
clients that get disconnected for a few minutes, and store messages they
missed.
It's very easy to setup public listening channels, but it had a great
solution for private (per-user) updates too, without using some obscure
authentication mechanism.

Client requests some info that needs push-updates -> rails checks
permissions (by sessions) -> rails signals nginx to create a channel
(with a
one-time key url) -> rails responds to the client with the key-url ->
client
connects to nginx for long-poll.
Then every time you need to push something to a client (channel) you
just
post to the url.

Have fun with it.

Mathijs
This topic is locked and can not be replied to.