Example code for JavaSpace05??
Jim Goodwin <[email protected]>
| Newsgroups | gmane.comp.java.sun.javaspaces |
|---|---|
| Message-ID | <LISTSERV%[email protected]> |
Hello,
I'm brand-new to JavaSpaces, Jini, and RMI. I'm trying to use JavaSpaces in
the context of the Eclipse 3.1 PDE (Plugin Development Environment -- which
I am using because I am trying to use RCP, the Rich Client framework, which
requires PDE). I'm using the IncaX CE plugin for Eclipse too (version 4.3.0).
It's been a sweat. PDE has its own ideas about classloading and I was
getting the identical class loaded on two class loaders, so they were not
seen as identical, causing failures. I think I have that fixed, by setting
the current thread's context-class-loader to the one PDE uses, before
attempting any JavaSpaces operations. This causes JavaSpaces and RMI to use
the PDE class loader, which they seem to work fine with. Read/write work ok,
and I've used MatchSet successfully too, against an instance of JavaSpace05.
But I paid dearly for that knowledge, and would be interested in hearing
from anybody else who knows more about the gory details.
But now I cannot get notification working, either the old or the new '05
way. I really don't understand what I'm doing.
Question 1: Are there any code examples using the '05 notification spec?
Question 2: Am I supposed to be doing UnUnicast.exportObject() on my
listener? It's supposed to handle stub-generateion automagically, right?
This is failing with no class def found (for the stub class).
So:
Question 2A: Am I supposed to do any setup before calling Unicast, e.g.
starting some server process or setting a mode or initializing something?
I have the processes running (under Inca X) that were necessary for read and
write, but haven't done any other setup.
Question 2B: Does the automatic stub generation actually produce files on
the disk somewhere and then load them? So I could go see if that was really
happening? Or is it all in-process and on-the-fly?
Question 2C: Is there any log data I produced by the export operation or its
failure that I should look for? There's nothing in the Inca X Console. The
stackdump in the regular Eclipse/Java console is appended below.
Thanks in advance for any help
Jim Goodwin
My test program. Note this is a straight Java App in Eclipse, not a PDE app,
and I determined from a breakpoint that it's got the normal context class
loader.
package com.mak.test3;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import net.jini.core.event.*;
public class Test3 {
public static void main(String[] args) throws RemoteException {
RemoteEventListener dummy = new RemoteEventListener() {
public void notify(RemoteEvent arg0) throws UnknownEventException,
RemoteException {
System.out.println("An event!");
}
};
UnicastRemoteObject.exportObject(dummy);
System.out.print("Exported!");
}
}
The result:
Exception in thread "main" java.rmi.StubNotFoundException: Stub class not
found: com.mak.test3.Test3$1_Stub; nested exception is:
java.lang.ClassNotFoundException: com.mak.test3.Test3$1_Stub
at sun.rmi.server.Util.createStub(Unknown Source)
at sun.rmi.server.Util.createProxy(Unknown Source)
at sun.rmi.server.UnicastServerRef.exportObject(Unknown Source)
at java.rmi.server.UnicastRemoteObject.exportObject(Unknown Source)
at java.rmi.server.UnicastRemoteObject.exportObject(Unknown Source)
at com.mak.test3.Test3.main(Test3.java:16)
Caused by: java.lang.ClassNotFoundException: com.mak.test3.Test3$1_Stub
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
... 6 more
===========================================================================
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