You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@river.apache.org by Patrick Wright <pd...@gmail.com> on 2009/10/11 13:31:29 UTC

Problem (null field) retrieving entry from JavaSpace

Hi

I have the usual suspects (servers) running: httpd, reggie, outrigger,
mahalo. I've verified this works using some older samples for
JavaSpaces (e.g. distributed Mandelbrot), and in the code I'm working
with, I can, e.g. write a Name in to my JavaSpace and read it back.

I have my own entry which extends Name and which I'm pushing into the
space. I'm seeing no errors in the various Jini/JS logs, but as I read
the entry back in a separate "listener" (client) instance of the
program, the "name" field is set correctly, but a second field is
null. This second field--call it "task"--is serializable; I'm actually
rewriting someone's first attempt at the code, which used basic Java
serialization (ObjectOutputStream, ObjectInputStream) to move that
individual value across the wire.

I would suspect a codebase/serialization issue, except that as I read
the JavaDocs for JavaSpace.read(), I would expect an
"UnusableEntryException - if any serialized field of the entry being
read cannot be deserialized for any reason". In any case, I made sure
that:
- the publisher and the client are running with the RMISecurityManager
with an anything-goes policy
- the various JARs used by the publisher and client are available in
the httpd codebase path

So--if an entry is being read with a null field where it was written
with a non-null field, where should I look?


Thanks
Patrick

Re: Problem (null field) retrieving entry from JavaSpace

Posted by Patrick Wright <pd...@gmail.com>.
Got it.

I left something out :). What I didn't say was that I'm writing the
publisher and client in Scala, and the custom Entry as well. I appears
that in Scala (and this is based on my limited understanding of the
topic), you can declare something that looks like a public field in
the language, but which is not actually generated as a public field in
the bytecode. It appears there is no way to do the latter, currently;
see Bill Venner's comments on
http://www.artima.com/forums/flat.jsp?forum=282&thread=243784.

By declaring the custom entry in Java, and using that class from
Scala, writing to and reading from the Space works fine.

Coolness: I'm experimenting with Ian Clarke's Swarm project
(http://code.google.com/p/swarm-dpl/). What I just got working is
writing and reading a Scala continuation via a JavaSpace instance.
What this means is that, from within a method, you can "exit" that
method at a certain point (line in the code), have all state local to
that method "frozen", then pass that method as a continuation up to
the space, read it out, continue to execute it from the next line,
then repeat ad nauseum. So using Ian's sample (see
ExplicitMoveTo.scala in the sources), what I just got working with a
JavaSpace is:

process a: enter method
process a: prompts "what is your name?", read reply, store to local var
process a: freeze continuation, push to space as custom entry

process b: poll for entries
process b: read custom entry
process b: resume continuation
process b: prompts "what is your age?", read reply, store to local var
process b: freeze continuation, push to space as custom entry

process a: read custom entry
process a: resume continuation
process a: prints out name, age, calculation

So we now have "downloadable methods" to complement "downloadable code".

(kudos go to the Scala team and to Ian!)

Regards
Patrick