Introduction
There are/have-been heaps of remoting frameworks in java, but RMI being part of the JRE/JDK and therefore having no external dependencies is my personal preference for remoting with java. Its main drawback: the wire protocol is not web-friendly and therefore difficult to go through firewalls (although it is possible). But if used behind the firewall, it makes for an excellent way to do distributed computing using only the JDK (OMG! only the JDK?! no Spring? or JMS?!). It does have several killer features that are found in very few (if any) remoting frameworks: callbacks and remote classloading. In this tutorial, you will see remote classloading. Ever since JRE 5.0, you don’t need to compile stubs (meaning you don’t need an extra compile-time step to get RMI working). I am guessing someone decided to do away with those and use the jdk dynamic proxies.
I wrote this tutorial after going through the most execelent RMI Tutorial by SUN/Oracle that you can find here. This tutorial has some aspects that complicate things:
- (a soft) requirement a webserver to download some code (wtf?! I just want to get RMI working. why do i need a webserver?)
- Defining and using security policy files that point to explicit paths (I just want to get RMI working)
- compiling stuff into 3 jars (with no build files provided this makes stuff very tedious) and having a big-ass command to run on the command line.
I will still recommend that you read the concepts presented in RMI tutorial before attempting this one since I will only present the same code, with some instructions on how to get it running within eclipse.
And finally, to simplify things, we will use only eclipse to get this tutorial working. All eclipse projects (including sources) are attached at the end of this tutorial. I will also say that not all the code is written by me. Some is taken directly from Sun/Oracle’s RMI tutorial. Lets get started!
Eclipse Project Setups
The example application has 3 components:
- Some interfaces
- A Server component that implements these interfaces
- A Client components that uses these interfaces

And so we will create 3 eclipse projects: rmi-base, rmi-server and rmi-client. In the rmi-base we will put all the interfaces and any classes that both the client and server might need. We will then set the project dependencies such that rmi-server and rmi-client projects depend on rmi-base. Be sure that the project dependencies are setup correctly. In eclipse you can do this via right-click on a project -> Properties -> Java Build Path -> Projects tab. For the rmi-server and rmi-client projects, in this Projects tab, we have to Add the rmi-base project.


The rmi-base Project
This project will contain our 2 interfaces for this RMI app: Compute and Task. The sample application defines a Compute interface that takes Task types, computes them and returns a result. A server component will implement the Compute interface and a client component will implement and send to the server a Task implementation.

The remote classloading
Here is where the remote classloading comes in. The server and client components will be running in different jvms. So even thought the server only knows the compute interface, it will acquire the implementation (defined in the client) from the client, run it and return the result. This can be very useful because most remoting frameworks transport data. RMI can transport data and logic.
The code for these 2 interfaces is noting spectacular and is shown below:
package saqib.rasul;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Compute extends Remote {
public static final String SERVICE_NAME = "ComputeEngine";
T executeTask(Task t) throws RemoteException;
}
package saqib.rasul; public interface Task{ T execute(); }
Apart from these 2 interfaces we have 2 classes used by both client and server. One is the PolicyFileLocator whose task it is to give the path to the policy file. Our policy file, which by the way, is not secure at all in that it allows everything. The code of the PolicyFileLocator just finds this policy file (whether on the file sytem or in a jar), copies it to a temp-file and returns the path to this temp file. Unlike the last 2 interfaces, this class is much more spectacular.
package saqib.rasul;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
/**
* class to locate our most "secure" policy file
*
* @author srasul
*
*/
public class PolicyFileLocator {
public static final String POLICY_FILE_NAME = "/allow_all.policy";
public static String getLocationOfPolicyFile() {
try {
File tempFile = File.createTempFile("rmi-base", ".policy");
InputStream is = PolicyFileLocator.class.getResourceAsStream(POLICY_FILE_NAME);
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
int read = 0;
while((read = is.read()) != -1) {
writer.write(read);
}
writer.close();
tempFile.deleteOnExit();
return tempFile.getAbsolutePath();
}
catch(IOException e) {
throw new RuntimeException(e);
}
}
}
To go with this we have our policy file which allows all.
grant {
permission java.security.AllPermission;
};
To be able to do RMI we need to do 3 things beforhand:
- set the java.rmi.server.codebase system property (more about this later)
- set the java.security.policy system property to the path to a policy file
- set a new SecurityManager
Since we need to do these three things for the server and client component, I decided to make a common class that does this: RmiStarter.
The java.rmi.server.codebase property
For the server component, this defines the location for classes originating from this server can be found. For the client, this defines the location where the client can find classes that originating from the client can be found. Since the server needs to expose these interfaces to the RMI registry, for the server we define the location of the 2 interfaces. For the client, it needs to expose/send-over an implementation of Task, so we need to define for it the location of the PI class. Using the class object we can find the location of where a class is living. And this location is the value for the java.rmi.server.codebase property.
If this property is not defined, or defined wrong then you get nasty ClassNotFound exceptions when trying to use RMI:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: saqib.rasul.Compute at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250) at sun.rmi.transport.Transport$1.run(Transport.java:159) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:155) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:359) at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source) at saqib.rasul.server.TheRmiServer.doCustomRmiHandling(TheRmiServer.java:23) at saqib.rasul.RmiStarter.(RmiStarter.java:27) at saqib.rasul.server.TheRmiServer. (TheRmiServer.java:13) at saqib.rasul.server.TheRmiServer.main(TheRmiServer.java:32) Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: saqib.rasul.Compute at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source) at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250) at sun.rmi.transport.Transport$1.run(Transport.java:159) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:155) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.ClassNotFoundException: saqib.rasul.Compute at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:711) at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:655) at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:592) at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:628) at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294) at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238) at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) ... 12 more
A clue here is the final exception. The Server is looking for the Compute class and can’t find it. So therefore the server’s java.rmi.server.codebase property should point to the location where it can find this class. For the rmi-server project, eclipse takes care of the classpath and so using the Compute.class.getProtectionDomain().getCodeSource().getLocation() we can find out where this class lives. We can then feed the location of this class (could be directory or a jar file) as the value for the java.rmi.server.codebase property.
Here is the code for the RmiStarter class:
package saqib.rasul;
/**
* class to do some common things for client & server to get RMI working
*
* @author srasul
*
*/
public abstract class RmiStarter {
/**
*
* @param clazzToAddToServerCodebase a class that should be in the java.rmi.server.codebase property.
*/
public RmiStarter(Class> clazzToAddToServerCodebase) {
System.setProperty("java.rmi.server.codebase", clazzToAddToServerCodebase
.getProtectionDomain().getCodeSource().getLocation().toString());
System.setProperty("java.security.policy", PolicyFileLocator.getLocationOfPolicyFile());
if(System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}
doCustomRmiHandling();
}
/**
* extend this class and do RMI handling here
*/
public abstract void doCustomRmiHandling();
}
And with that we are over the hill. Its all downhill from here!
Writing the Server Component in the rmi-server Project

The server component consists of the implementation of the Compute interface. The code for this is:
package saqib.rasul.server;
import java.rmi.RemoteException;
import saqib.rasul.Compute;
import saqib.rasul.Task;
public class ComputeEngine
implements Compute {
@Override
public T executeTask(Task t)
throws RemoteException {
System.out.println("got compute task: " + t);
return t.execute();
}
}
And the code to start up the server component:
package saqib.rasul.server;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import saqib.rasul.Compute;
import saqib.rasul.RmiStarter;
/**
* start the server component. this exposes the an implementation of the Compute interface as a service over RMI
*
* @author srasul
*
*/
public class ComputeEngineStarter
extends RmiStarter {
public ComputeEngineStarter() {
super(Compute.class);
}
@Override
public void doCustomRmiHandling() {
try {
Compute engine = new ComputeEngine();
Compute engineStub = (Compute)UnicastRemoteObject.exportObject(engine, 0);
Registry registry = LocateRegistry.getRegistry();
registry.rebind(Compute.SERVICE_NAME, engineStub);
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new ComputeEngineStarter();
}
}
And thats it for the server component. If we were to run the ComptueEngineStarter class by its main method it would expose an RMI service with the name “ComputeEngine”. I find that running 1 class is much simpler than writing out a big-ass command on the command line to run a class, define classpaths and define system properties.
Writing the Client Component in the rmi-client Project
The client contains an implementation of Task called PI. A snippet of code of this class is given below. This class calculates PI to a given number of decimal places.

package saqib.rasul.client;
import java.io.Serializable;
import java.math.BigDecimal;
import saqib.rasul.Task;
public class PI
implements Task, Serializable {
/**
*
*/
private static final long serialVersionUID = 3942967283733335029L;
/** constants used in pi computation */
private static final BigDecimal FOUR = BigDecimal.valueOf(4);
/** rounding mode to use during pi computation */
private static final int roundingMode = BigDecimal.ROUND_HALF_EVEN;
/** digits of precision after the decimal point */
private final int digits;
/**
* Construct a task to calculate pi to the specified precision.
*/
public PI(int digits) {
this.digits = digits;
}
/**
* Calculate pi.
*/
public BigDecimal execute() {
return computePi(digits);
}
// .... the rest is omitted for saving pixels
// ....
And a starter class that sends this to the PI task to the ComputeEngine service.
package saqib.rasul.client;
import java.math.BigDecimal;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import saqib.rasul.Compute;
import saqib.rasul.RmiStarter;
/**
* get the RMI Compute service and send a task to compute PI to N digits
*
* @author srasul
*
*/
public class StartComputeTaskPI
extends RmiStarter {
public StartComputeTaskPI() {
super(PI.class);
}
@Override
public void doCustomRmiHandling() {
try {
Registry registry = LocateRegistry.getRegistry();
Compute compute = (Compute)registry.lookup(Compute.SERVICE_NAME);
PI task = new PI(50);
BigDecimal pi = compute.executeTask(task);
System.out.println("computed pi: " + pi);
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new StartComputeTaskPI();
}
}
Running it
First make sure you have the rmiregistry running by executing rmiregistry on the command line. See the original RMI tutorial for this
Then in eclipse, first run the ComputeEngineStarter class and then the StartComputeTaskPI class. This will run those 2 classes in separate jvms and they will communicator over RMI.

If you wanted to make jars out of the projects, that would work as well. Then you can run the classes on the command line as done in the original RMI tutorial. Except you dont need to define any system properties. You just run the 2 classes in different jvms:

The End & The Downloads
Thats it for now. I hope you found the tutorial usefull and helpful. You can use the code in your projects. I have placed it under an Apache 2 License.
You can download a zip containing all 3 eclipse projects here.
#1 by Roger Norling on June 24th, 2010
Quote
Nice example. However, I have a problem running it. I get the following exception:
Exception in thread “main” java.lang.NullPointerException
at rmitest.PolicyFileLocator.getLocationOfPolicyFile(PolicyFileLocator.java:16)
at rmitest.RmiStarter.(RmiStarter.java:9)
at rmitest.ComputeEngineStarter.(ComputeEngineStarter.java:10)
at rmitest.ComputeEngineStarter.main(ComputeEngineStarter.java:28)
The offending line is:
InputStream is = PolicyFileLocator.class.getResourceAsStream(PolicyFileName);
I didn’t use your already set up projects since I figured being able to set it up myself would be better practice. The policy file should be it the correct place as far as I can tell. Any ideas why it is not working?
#2 by Roger Norling on June 24th, 2010
Quote
Sorry, let me be precise.. That was not the offending line, but rather the originating cause. The ‘is’ variable is set to null, as if the resource wasn’t there.
#3 by Roger Norling on June 24th, 2010
Quote
Oh, found the problem. The policy file should be directly under src, not under the package. It was slightly hard to see from the images above.
However, another question.. This example only work locally on a host, right. How can a deployment with multiple hosts be realized?
#4 by srasul on June 26th, 2010
Quote
Type your comment here
Hi Roger,
thanks for the feedback.
to work with multiple hosts you need to run the rmi register on a host. Then using the
java.rmi.registry.LocateRegistryclass get the registry running on this host and use this to expose new services and get proxies to services exposed.#5 by Roger Norling on June 26th, 2010
Quote
Thanks for the response.
Yes, the rmi registry need to run on the server’s host and the client need to be extended by specifying a host address in its getRegistry() call.
However, what I’m unsure of is the java.rmi.server.codebase property and the propagation of the class code. In the inter-host senario e.g. “file:/C:/EclipseWorkspace/rmi-base/bin/” works fine, but how does this translate to an intra-host senario, where server and client are situated on different machines?
Sun’s example use a class to implement a simple http server. I that needed, or would you imagen another solution? Would you please elaborate on this?
Btw, while I remember it, I think the code in your example is quite beatiful and well designed.
#6 by srasul on June 27th, 2010
Quote
Thanks again for the positive feedback. It will be great if you can use this code for some real-world use
The
java.rmi.server.codebaseis used (as far as my understanding of this variable goes) to specify code that will be used for remote-classloading. If your use of RMI used this feature, then you need to put these classes in a location where another host can get them (via http for example). This is because in RMI you can make a method call where one of the arguments is an implementation of an interface that the server does not know about. The server knows the interface (in this case the Task interface), but when you call the Compute services with an implementation of this interface, the server cannot know this implementation. And so the server cannot know what to ‘compute’. And this is where thejava.rmi.server.codebasecomes in. Using this variable you specify where the server can find any classes that it gets as method-args that it does not know about. I hope this clarifies the use of this system property.If, on the other hand, you do not use this feature, then the
java.rmi.server.codebaseshould point to a local location containing the shared interfaces.Btw, in the example from Sun (and my eclipse-tutorial) we do use the remote-classloading feature.
#7 by Roger Norling on June 28th, 2010
Quote
I understand fairly well how the java.rmi.server.codebase is used and why it is needed. My understanding is that I need to use that http server class in order to cross the host boundaries when server and client is run separately.
I will try to merge your utility class with the code from sun and get back to you with the result of my tinkering.
#8 by Kristof on July 20th, 2010
Quote
Great tutorial. The part about referencing to the ‘Compute’ class using Compute.class.getProtectionDomain().getCodeSource().getLocation().toString() solved an annoying fault in my application. Thanks!
#9 by Xinhua Zhu on March 31st, 2011
Quote
Hi, it works very well in java project.
But when I move it into an Eclipse RCP project, some strange exception happens, something like:
java.lang.NoClassDefFoundError: saqib/rasul/RmiStarter
What is the reason? Thanks
#10 by Parikshit Kansara on April 20th, 2011
Quote
hi,I am working on Traveling Tournament problem project.I have already implemented this project in java. running on single system.I want implement this project in distributed environment and how i can implement this using RMI??
#11 by Parikshit Kansara on April 20th, 2011
Quote
hi,I am working on Traveling Tournament problem project.I have already implemented this project in java. running on single system.I want to implement this project in distributed environment and how can i implement this using RMI??
#12 by Christopher on May 24th, 2011
Quote
Really nice work! My RMI Server runs well and now i can see pi
Really thank you!
#13 by Mesut on June 23rd, 2011
Quote
Nice work! It explains a lot.
Thank you.
#14 by Carrion on August 2nd, 2011
Quote
Thank you so much!! You saved my life! I was struggling for 1 week and you explained it so well… everything is there.
Thanks again
#15 by Kris on August 28th, 2011
Quote
Great tutorial works like a charm! Is *almost* exactly what I was looking for. I need to talk to a ‘child’ JVM on the same machine. RMI seems like the perfect solution.
The only thing that bugs me a little is the need start an RMI registry process somehow
My main objection to it is the fact that I need to find a way to make sure it is started without user intervention (don’t want to bug the user with this).
But as it turns out you don’t need the registry. It is possible to simply have the server write out the stub to a File using java serialization and then have the client read it in from the file.
This works perfectly (I just tried it).
#16 by Kris on August 28th, 2011
Quote
Hey, I just put up something based on your sample code. I modified it only slightly so it doesn’t use the RMI registry.
http://code.nomad-labs.com/2010/03/26/an-improved-rmi-tutorial-with-eclipse/
#17 by Kris on August 28th, 2011
Quote
Oops, wrong link.. sorry. Too bad I can’t edit my previous comment to fix it.
http://krisdevolder.blogspot.com/2011/08/using-rmi-without-registry.html
#18 by Jitendra Modi on September 25th, 2011
Quote
Hi,
I follow given example. Create all three projects, classes and interfaces .
In (Task.java) interface and Compute.java class you are using T. I dont found any Class T.
waiting for your reply….
#19 by Suresh Chauhan on September 28th, 2011
Quote
Thank you so much it is very useful…………………..
#20 by Leo on November 6th, 2011
Quote
I got the following problem when running the starter:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: access to class loader denied
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:419)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at saqib.rasul.server.ComputeEngineStarter.doCustomRmiHandling(ComputeEngineStarter.java:31)
at saqib.rasul.RmiStarter.(RmiStarter.java:27)
at saqib.rasul.server.ComputeEngineStarter.(ComputeEngineStarter.java:21)
at saqib.rasul.server.ComputeEngineStarter.main(ComputeEngineStarter.java:40)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: access to class loader denied
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:409)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: access to class loader denied
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:605)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:646)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:311)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:257)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1549)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1511)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
… 13 more
Caused by: java.security.AccessControlException: access denied (“java.io.FilePermission” “\C:\workspace\rmi-base\bin\-” “read”)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
at java.security.AccessController.checkPermission(AccessController.java:555)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at sun.rmi.server.LoaderHandler$Loader.checkPermissions(LoaderHandler.java:1176)
at sun.rmi.server.LoaderHandler$Loader.access$000(LoaderHandler.java:1130)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:571)
… 21 more
any advise?
thanks
#21 by kino on November 16th, 2011
Quote
great job,really helped !!!
#22 by Manny on November 25th, 2011
Quote
I get the same error posted by kino…. Can you explain why access to rmi-server bin folder is happening?
#23 by Manny on November 25th, 2011
Quote
I get the same error posted by kino…. Can you explain why access to rmi-server bin folder is denied?
#24 by xavb on November 28th, 2011
Quote
I got an AccessControlException, exactly the same got by Kino. What does it mean?
I got the same error with another RMI project which I’m trying to run.
#25 by Leslie Jeffries on December 3rd, 2011
Quote
I really like the elegance of your solution, however I’m still frustrated since I can’t get it to work completely. The policy file finder is really nice.
To let you know, my client and server work perfectly fine if the code for both is in the same directory. If I move the client code outside the folder where the server code is (as would be the case in Eclipse), I have all the finding the code problems.
Anyway, when I try to make the call to export the stub in my app similar to this:
Compute engineStub = (Compute)UnicastRemoteObject.exportObject(engine, 0);
I get the following error
java.rmi.server.ExportException: object already exported
If I comment out that call I am back to this problem:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: saqib.rasul.Compute
Any idea what I’m doing wrong.
#26 by OrangeDog on December 6th, 2011
Quote
To srasul:thanx for your examples, it`s really helps to understend RMI;
To Leo: I had similar problem, try to fix JRE_HOME/lib/security/java.policy, I know, that is ugly but it must working
Trackback: Informasi Online Organisasi Masyarakat Jawa Keluyuran di Sumatera
Trackback: parc rosewood register
#27 by Kaan Yusuf Olta on January 15th, 2012
Quote
… So widespread that people notice inside nearly every public spot similar to gardens, theme parks, yards etc. Its price, colour, quality etc differs in line with the form of wood found in making it. Rosewood…Parcrosewood
#28 by ALican ALi on January 15th, 2012
Quote
… Such things as the metal essential oil lamp fixture, carefully created woodwork, specially that regarding the rosewood… The most effective las vegas normal water areas and private pools ; tourism tendencies throughout Sicily; the actual imagine DeniaParc Rosewood Condo