This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Sorry about the lengthy mail. But it will hardly take 5 min to go thru it as most of it is basic code. I am a newbie to RMI and am trying to bind a server object with the rmiregistry. I have written a very simple remote class which basically returns a string as follows. I am using JDK 1.3 on Windows 2000 Professional. 1. Remote Interface:
2. Implementation of the remote interface:
Note that I have used localhost as the rmi registry location. 3. java.policy I am using:
4. The above files are located in: D:\del-data\rmiexample I have compiled the src files and put them in appropriate directories under D:\del-data\rmiexample. Then I generated ComputeEngine_Skel.class and ComputeEngine_Stub.class and placed them with ComputeEngine.class in D:\del-data\rmiexample\engine directory. 5. I have set the classpath to D:\del-data\rmiexample and added the same as a virtual directory //localhost/rmiexample in my IBM HTTP Server. 6. I execute the following set of commands at my commad prompt: D:\del-data\rmiexample>set CLASSPATH= D:\del-data\rmiexample>start rmiregistry D:\del-data\rmiexample>set CLASSPATH=.;D:\del-data\rmiexample D:\del-data\rmiexample>java -Djava.rmi.server.codebase=file:/d:\del-data\rmiexample/ -Djava.rmi.sever.hostname=localhost -Djava.security.policy=java.poilcy engine.ComputeEngine I am getting the following error. Apparently, it is failing at line 25 in ComputeEngine.java which is "Naming.rebind(name, engine);" ComputeEngine exception: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve) java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:272) at java.security.AccessController.checkPermission(AccessController.java:399) at java.lang.SecurityManager.checkPermission(SecurityManager.java:545) at java.lang.SecurityManager.checkConnect(SecurityManager.java:1044) at java.net.Socket.<init>(Socket.java:262) at java.net.Socket.<init>(Socket.java:100) at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:25) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:120) at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:499) at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:190 ) at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174) at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:318) at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source) at java.rmi.Naming.rebind(Naming.java:160) at engine.ComputeEngine.main(ComputeEngine.java:25) Questions: 1. When I invoke the 'start rmiregistry', a separate command prompt is started and it doesn't do anything. I can't even type in it. To shut down the registry I am just killing the command prompt.Is that normal. 2. java.policy is stored in D:\del-data\rmiexample and is accessible both by classpath as well as web server. Is that ok or does it have to go in any other directory. The web server is up and running. Can anybody tell me what/where you think I am going wrong. Appreciate your help. Thanks in advance. AJ