-
1. Re: rmi registry
tom.elrod Jul 21, 2006 12:57 PM (in response to choozie)The RMIServerInvoker will call following upon being created:
LocateRegistry.createRegistry(port)
The port will be 3455 by default.
Are you calling LocateRegistry.getRegistry( 3455 ) from a remote machine? -
2. Re: rmi registry
choozie Jul 24, 2006 4:58 AM (in response to choozie)I figured out my mistake, but I've run into another one. My code is the following:
if (System.getSecurityManager() == null){
System.setSecurityManager(new RMISecurityManager());
}
Properties env = new Properties();
env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
env.setProperty("java.naming.provider.url", "localhost:3455");
env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
try {
InitialContext context = new InitialContext(env);
} catch (NamingException e) {
e.printStackTrace();
}
try{
InvokerLocator myLocator = new InvokerLocator("rmi://localhost:3455");
RMIServerInvoker rmiserver = new RMIServerInvoker(myLocator);
}catch(Exception e){
e.printStackTrace();
}
No errors so far. But then I try to bind to the registry, with
Naming.rebind( serverUrl, server );
where serverUrl = rmi://localhost:3455/
and server is a UnicastRemoteObject.
This gives
RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: <server-class>_Stub
I checked the class-folder, and the stub is there. If I create a local rmi-registry and bind to that (skipping all the above code expect the naming.rebind), everything works fine. But I would like the use the jboss rmi registry. What am I doing wrong? -
3. Re: rmi registry
choozie Jul 24, 2006 7:43 AM (in response to choozie)I foundt out that I actually do get an error before that. Calling
RMIServerInvoker rmiserver = new RMIServerInvoker(myLocator);
gives
ERROR [org.jboss.remoting.transport.rmi.RMIServerInvoker - 246] Error unbinding RMIServerInvoker from RMI registry.
java.rmi.NotBoundException: remoting/RMIServerInvoker/3455
at sun.rmi.registry.RegistryImpl.unbind(RegistryImpl.java:140)
at org.jboss.remoting.transport.rmi.RMIServerInvoker.destroy(RMIServerInvoker.java:242)
at org.jboss.remoting.transport.rmi.RMIServerInvoker.finalize(RMIServerInvoker.java:260)
at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)
I have no idea why that is... -
4. Re: rmi registry
falazar Jul 25, 2006 5:19 PM (in response to choozie)How goes the RMI programming?
I need to test a small RMI call for the jbpm myself.
James -
5. Re: rmi registry
falazar Jul 25, 2006 5:23 PM (in response to choozie)Sorry, this appears to be the wrong forum.
(Unless anyone can send me the answer...)
James -
6. Re: rmi registry
choozie Jul 26, 2006 2:21 AM (in response to choozie)I'm still facing the same errors. If someone has managed to use the rmi registry that RMIServerInvoker creates I would be very glad to hear how!
-
7. Re: rmi registry
tom.elrod Aug 8, 2006 1:34 PM (in response to choozie)Server code:
public class RMIRegistryTestServer { private Connector connector = null; private String locatorUri = "rmi://localhost:4555"; public void setUp() throws Exception { connector = new Connector(locatorUri); connector.create(); connector.start(); } public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { RMIRegistryTestServer server = new RMIRegistryTestServer(); try { server.setUp(); Thread.sleep(6000000); server.tearDown(); } catch (Exception e) { e.printStackTrace(); } } }
Client code:public class RMIRegistryTestClient { public void testRegistry() throws Exception { Registry registry = LocateRegistry.getRegistry("localhost", 3455); if (registry != null) { String[] entries = registry.list(); if (entries != null) { for (int x = 0; x < entries.length; x++) { System.out.println("entry " + x + ": " + entries[x]); } } else { System.out.println("Failed to get entries."); } } else { System.out.println("Failed to get regsitry."); } String[] listing = Naming.list("//localhost:3455"); if(listing != null) { for(int x = 0; x < listing.length; x++) { System.out.println("listing " + x + ": " + listing[x]); } } else { System.out.println("Failed to get listing."); } } public static void main(String[] args) { RMIRegistryTestClient client = new RMIRegistryTestClient(); try { client.testRegistry(); } catch (Exception e) { e.printStackTrace(); } } }