Re: Unexpected return type from space.read()

"John McClain - Sun Microsystems, Inc." <[email protected]>
Newsgroups gmane.comp.java.sun.javaspaces
Message-ID <[email protected]>
Zsolt Kúti wrote:
> Hello,
>
> In the meantime tracked outrigger sources down to this:
>
> final Object rslt =
>                 space.read(repFor(tmpl), txn, serverTimeout,
> queryCookie); if (rslt == null) {
>                 // should never get null from a non-ifExists query
>                 throw new AssertionError("space.read() returned null");
>             } else if (rslt instanceof EntryRep) {
>                 // Got an answer, return it
>                 return entryFrom((EntryRep)rslt);
>             } else if (rslt instanceof OutriggerServer.QueryCookie) {
>                 /* Will still want to go on if there is time, but pass
>                  * the new cookie
>                  */
>                 queryCookie = (OutriggerServer.QueryCookie)rslt;
>             } else {
>                 throw new AssertionError(
>                     "Unexpected return type from space.read()");
>             }
>
> Although my IDE shows for rslt (on reading space):
> EntryRep[kuti.service.DealEntry]

Good, this helps (since I didn't have the foresight to include something
about rslt's type in the error message....seems like an obvious thing to
want to know in retrospect.....)

> the conditional fails regardless:
> } else if (rslt instanceof EntryRep) {
>
> resulting in AssertError (I realized why exception handling part works
> so)
>
> I'm puzzled...

My guess is there is some sort of classloading problem (which are often
puzzling....). In java two classes can be equal if and only if they have
the same name and they were loaded by the same classloader. My guess is
for some reason the EntryRep class that was loaded for the object
returned by space.read is being loaded by a different class loader than
the the classloader that loaded outrigger's proxy.

It would be helpful to know how you started outrigger (in particular the
  config file used with start.jar and the java command line) and how you
started up outrigger's client (I guess this is the service you wrote).

> Zsolt
>
>
> On Tue, 27 Jun 2006 04:16:46 -0600
> Zsolt Kúti <[email protected]> wrote:
>
>
>>Hello,
>>
>>I am a newbie at Jini/JS and now experimenting with them (as of 2.1).
>>Successfully wrote a Jini service, that can be seen in Browser (phuh,
>>took some time resolve some codebase issue). This service writes into
>>a space (the one started by Jini starter kit), the entry written can
>>be seen among the Javaspace05 instance's entries. So far...
>>Now, as I try to read it back I get the following:
>>
>>java.rmi.ServerError: Error in server thread; nested exception is:
>> java.lang.AssertionError: Unexpected return type from space.read()
>> at
>>net.jini.jeri.BasicInvocationDispatcher.dispatch(BasicInvocationDispatcher.java:647)
>> at
>>com.sun.jini.jeri.internal.runtime.ObjectTable$6.run(ObjectTable.java:597)
>>at
>>net.jini.export.ServerContext.doWithServerContext(ServerContext.java:103)
>>at
>>com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispatch0(ObjectTable.java:595)
>>at
>>com.sun.jini.jeri.internal.runtime.ObjectTable$Target.access$700(ObjectTable.java:212)
>>at
>>com.sun.jini.jeri.internal.runtime.ObjectTable$5.run(ObjectTable.java:568)
>>at java.security.AccessController.doPrivileged(Native Method) at
>>com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispatch(ObjectTable.java:565)
>>at
>>com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispatch(ObjectTable.java:540)
>>at
>>com.sun.jini.jeri.internal.runtime.ObjectTable$RD.dispatch(ObjectTable.java:778)
>>at
>>net.jini.jeri.connection.ServerConnectionManager$Dispatcher.dispatch(ServerConnectionManager.java:148)
>>at com.sun.jini.jeri.internal.mux.MuxServer$2.run(MuxServer.java:244)
>>at java.security.AccessController.doPrivileged(Native Method) at
>>com.sun.jini.jeri.internal.mux.MuxServer$1.run(MuxServer.java:241) at
>>com.sun.jini.thread.ThreadPool$Worker.run(ThreadPool.java:136) at
>>java.lang.Thread.run(Thread.java:595) at
>>com.sun.jini.jeri.internal.runtime.Util.__________EXCEPTION_RECEIVED_FROM_SERVER__________(Util.java:108)
>>at
>>com.sun.jini.jeri.internal.runtime.Util.exceptionReceivedFromServer(Util.java:101)
>>at
>>net.jini.jeri.BasicInvocationHandler.unmarshalThrow(BasicInvocationHandler.java:1303)
>>at
>>net.jini.jeri.BasicInvocationHandler.invokeRemoteMethodOnce(BasicInvocationHandler.java:832)
>>at
>>net.jini.jeri.BasicInvocationHandler.invokeRemoteMethod(BasicInvocationHandler.java:659)
>>at
>>net.jini.jeri.BasicInvocationHandler.invoke(BasicInvocationHandler.java:528)
>>at $Proxy1.takeOut(Unknown Source) at
>>kuti.client.CreditApplicationClient.discovered(CreditApplicationClient.java:76)
>>at net.jini.discovery.LookupDiscovery$1.run(LookupDiscovery.java:977)
>>
>>
>>The code fragment doing this has nothing special:
>>        DealEntry d = new DealEntry(n);
>>        try {
>>            Entry en = space.read(d, null, 10000L);
>>        }
>>        catch(Exception e) {...}
>>
>>Further strange thing is that despite catch presence it doesn't show
>>up at server side, but on client side does.
>>
>>I've no idea what I do wrong and  could'nt find any hint on the web.
>>
>>Thanks for your help!
>>
>
>
> ===========================================================================
> To unsubscribe, send email to [email protected] and include in the body
> of the message "signoff JAVASPACES-USERS".  For general help, send email to
> [email protected] and include in the body of the message "help".
>
> To view past JAVASPACES-USERS postings, please see:
> http://archives.java.sun.com/archives/javaspaces-users.html


--
BTW, if you want to reply to this message, please direct your reply
to the list, thanks

John McClain                                    [email protected]
Sun Microsystems, Inc.
Burlington, MA

no files, just services

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff JAVASPACES-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

To view past JAVASPACES-USERS postings, please see:
http://archives.java.sun.com/archives/javaspaces-users.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.