You are on page 1of 135

Remote Method Invocation (RMI) FAQ From jGuru

Generated Sep 13, 2005 2:17:06 PM


Why must the CLASSPATH environment variable not include the path of the
remote object's stub classes on the server host?
Created: Nov 13, 1999
Author: Govind Seshadri (

If the CLASSPATH environment variable on the server host includes the path of the
remote object's stub classes, it will cause rmiregistry to ignore the
java.rmi.server.codebase property setting for the server.

rmiregistry must contain the location of the stub files for the remote server object in
an HTTP URL-encoded format, so that when this information is sent to the client, the
classes can then be downloaded via an HTTP server.

If rmiregistry does not send the location of the stub classes in HTTP-encoded format,
the client having no way to download them, will simply throw a

Comments and alternative answers

java.rmi.server.codebase, CLASSPATH
Author: Federica Ciotti (, Jun
3, 2004

How can I tell rmiregistry to contain the location of the stub class in the HTTP URL encoded format?

I try to do

> unsetenv CLASSPATH

> rmiregistry &

> setenv CLASSPATH...

> java -Djava.rmi.server.codebase=http://... server/Server

But in this way when I start rmiregistry the CLASSPATH is empty??

Do you need an HTTP server to use RMI?
Created: Nov 14, 1999
Author: Govind Seshadri (

Technically, you don't need an HTTP server to use RMI. You can always place the stub
classes for the remote objects, along with any user-defined classes, within the
client's CLASSPATH. But such a deployment is highly inflexible, and feasible only for
the more simple implementations.

In most real-life RMI deployment scenarios, the client retrieves all the classes
dynamically via the HTTP protocol, by interacting with an web server running on the
same host as the remote server objects.

You can also make use of a simple HTTP "class server" implementation provided free
by Sun, exclusively for use with RMI. The class-server can be downloaded at:

How do I run rmiregistry and RMI servers in the background under
Created: Nov 14, 1999
Author: Govind Seshadri (

You can start rmiregistry or RMI servers from a DOS window under Win32 using the
start command. But this does not run your servers truly in the background, as a little
DOS window for the java interpreter remains in the foreground for each server that
is started. If you are starting numerous remote servers under Win32, all the DOS
windows could prove rather problematic.

A solution is to use the javaw command that is supplied as part of the Windows
JDK/SDK. This fires up the Java interpreter as a seperate process and runs your RMI
server in the background. This effectively eliminates the clutter of DOS windows in
the foreground for each of your RMI servers.

Do note that there are some downsides to using javaw. For instance, it is no longer
that simple to terminate a running Java process - you now have to do it via the task
manager. Also, if you are in debugging mode, you will not be able to see any of the
diagnostic messages sent to the console, as it is now in the background.

Comments and alternative answers

Java Rmi
Author: Amit jain (, Apr 9,
There is no nees to use the start service of windows to start Rmiregistry just write the
below code before rebind methord for ur remote object like as below :- Registry
registry =LocateRegistry.createRegistry(1099); SaveImageInterface server=new
SaveImageServer(); registry.rebind("//localhost/remoteserver",server);
Naming.rebind("//localhost/remoteserver); this code will register the object on the
host which is running the servre and for making the server as background user javaw
[name of the server ]

Re: Java Rmi
Author: kumar padhu (,
Jun 3, 2003
can you run only the rmiregistry in a seperate server and keep it alive

Re[2]: Java Rmi
Author: sandeep pathuri
(, Jun 24, 2005

Can I run an RMI application that makes use of callbacks across firewalls?
Created: Nov 14, 1999
Author: Govind Seshadri (

No, you cannot use RMI applications that make use of callbacks across firewalls. The
RMI transport layer makes use of HTTP tunneling to get through firewalls. Since HTTP
is a stateless protocol, it does not offer a suitable transport layer for the callback
Comments and alternative answers

I do not think this is the right answer. If the st...
Author: Randolph Kahle (, Dec 1,
I do not think this is the right answer. If the stateless nature of the HTTP protocol is a
problem, then how can it work for non-callback connections? HTTP could be used for
callbacks if the client side was given the same capabilities as the server. I think the
answer should be that the RMI team did not elect to put in the functionality to support
this feature. -- Randy Kahle

Even if the RMI team had provided functionality fo...
Author: Govind Seshadri (, Dec 3,
Even if the RMI team had provided functionality for invoking callbacks across
firewalls, it would be impractical to use, all the same. For instance, then each of the
client machines behind a firewall would also have to run a HTTP server in order to do
the call forwarding using the java-rmi.cgi script.

That means that if the server is behind a firewall...
Author: Vishal Malhan (, Jun 11,
That means that if the server is behind a firewall we can do callbacks and not when
the clients are behind a firewall.

Re: That means that if the server is behind a firewall...
Author: Mark Riner (,

Author: Surendra Rathi (http://www. I have an experimental solution if you would like to try It uses socket factories to implement two- way RMI call communication between client and server. It. For that to happen. Dec 17. Author: Tim Taylor (http://www.. I'm facing the Same problem (CallBack Socket) and I'd like to check the solution your proposed...jguru.jsp?EID=238921). It uses socket factories to negotiate socket creation. 2003 Hello. Re[3]: You can try my free solution if you want to.jguru.. Let me know if you find it useful or find bugs in it. Sockets are always initiated from the client.jguru. Oct 27. You can try my free solution if you want to. Can you please make it available or just give instruction about how you made it? To make a callback.jguru.jsp?EID=587439). it creates a special socket connection to the server. asking the client to make a connection to the server. 2001 When your client starts up. This is sometimes not possible with a firewall in the way or when the client initially contacts the server through dial-up networking. Re: You can try my free solution if you want to.. . But can u post some documentation on how it works. The link does not seem to work.e. 2000 To make a callback. Oct 29. 2000 You can try my free solution if you want to. It. Author: Tim Taylor (http://www.jsp?EID=587439). Author: Tim Taylor (http://www. the server has to be able to establish a socket to the client address and port.. It. Author: Surendra Rathi (http://www.. 2001 can u post your free solution ?? Re[2]: You can try my free solution if you want to. all socket connections (call and callback both) are made from the client to the server. When the server needs to connect to the client. It.jguru. the server has to become a client. Dec 18.. Dec 17.. 2001 I saw the solution.jsp?EID=238921).com/guru/ it sends a request over the special socket. The server waits for the connection to come from the client and uses that socket for the callback.. I.jsp?EID=238921). the server has to become a client. Nov

. but if you need them and know that you don't need HTTP tunnelling. And so the updates dont reach.jsp?EID=238921). Author: Surendra Rathi (http://www. you don't need to do anything except install the client and server socket factories and establish the signalling socket as shown in the example. 2001 If you are using a VPN.4 either for JRMP or IIOP or both. Tim . I think callbacks should be avoided.. Dec 18. my hack can help.. I. Re[4]: You can try my free solution if you want to. The clients callback registered to the server has a local address which is not reachable by the server. I would have avoided the rmi callbacks if there was another way of pushing updates to the client instead of client polling endlessly. But can u see your solution working in my case below. 1) The server knows the VPN assigned ip address of the client and can give it to the remote client ? Is there any way i can make the client register its callback object with this 'vpn' address.e.. It. There was some speculation in the excellent book titled "java. What i dont understand is should i use it both at the client and the server side ? (eg the call to Just code your callbacks as normal..jguru. and they should just work. I surely dont understand the rmisocket factory all that much.setSocketFactory()). The problem i am facing now is when a firewall/gateway exists at the client side.jsp?EID=587439). After Dec 19.jguru. Can i just use it only on client so that it makes the callback register with the right address on the server.rmi" that the callback issue and HTTP tunnelling might be solved in Java 1. my solution should work transparently. It. thanks in advance suren Re[5]: You can try my free solution if you want to. the socket factories on the client and server side will negotiate the callback connections. Author: Tim Taylor (http://www. 2001 thanks for the response. Client connects over a vpn connection. 2) I have gone thru ur solution code (most of it).Generally.

java:183) at java. Author: Tim Taylor (http://www. Author: Paloma Ortega (http://www.jsp?EID=926756). Jul 4.BufferedInputStream.readInt(DataInputStream. It.jsp?EID=926756). You are getting the ConnectException on the server because it is trying to connect back to the client. Jun There is also a callback interface for the server to access the client once it has registered and there is no problem when the client is connected to a LAN (we are using SocketFactory)..rmi.jsp?EID=238921).SocketInputStream. The solution should work for you over GPRS if you can get a true socket connection to your server from the Connection reset by peer: JVM_recv in socket input stream read at 2002 I have been trying to access your solution but I can´t get to it. 2002 Hello. we get the exception at java. We have successfully used this solution in order to get through a firewall for callback requests. the server will instead send a request to the client and ask the client to create the socket back to the server.Re: You can try my free solution if you want to.X nested exception is: java. but if the client is connected through GPRS.jguru. Oct 15. It's back now.BufferedInputStream. It.. is it possible to use the solution for this? is there any other way we haven´t thought of? Thank at java.. . this exception is not we obtain an exception in the server side saying: Author: Paloma Ortega (http://www. P Re[2]: You can try my free solution if you want to.ConnectException: Connection refused to host:X.SocketInputStream.socketRead0(Native Method) at$ at com.. if the client application finishes.. 2002 Anonymous FTP wasn't working at my When using only RMI and no socket factories at all.ConnectException: Connection timed out: connect Is there anything we are missing? Thank you.css. We have been thinking about closing the sockets used for the communication. Re[3]: You can try my free solution if you want Is there any other way to download it? I have a server behind a firewall and a client accessing its interface methods through RMI. With my solution. Paloma Re: You can try my free solution if you want to.

It... I tried to access your solution.jguru.jsp?EID=1001 Created: Nov 14. can I solve the problem of the callback in RMI across firewall.jguru. Jan 2. Author: jia wei ( MyRemoteImpl resets the lease term to 5 minutes.Could send me the link ? Thanks Sudipta Re[3]: You can try my free solution if you want to. by default. Jan 15. Author: Jeff Shao (http://www. can. Thanks. the reference is considered to be invalid. However.jguru. Jeff If I convert my application from RMI to RMI-IIOP.jguru. Note that for optimal performance.jsp?EID=14) When a RMI client obtains a reference for the remote object. 2003 Tim. I am encountering RMI callback through firewall problem in my java application.rmi.jsp?EID=1042437).. Could you post or show me your solution? Thanks in advance.jsp?EID=290863). but it was not successful. 2001 If I convert my application from RMI to presuming there are no other clients holding a live reference to the reference is live for 10 minutes. . For example: java -Djava... 2003 I want download your rmi free The lease period is indicated in milliseconds.leaseValue. and the remote object may be subject to garbage collection. 2003 Hi Tim.dgc. Author: stefano orselli (http://www. assuming my firewall has been configured to allow IIOP traffic? How can I control the lease period associated with a client's reference for my remote object? Location: http://www. May 15.jguru. Can you share the link for your solution? I don't have a clue how other folks were able to see your solution. the lease term should not be set toa very small value. If there is no client activity before the lease term expires. It.rmi. Jenny Re[2]: You can try my free solution if you want 1999 Author: Govind Seshadri (http://www. May 23. An active RMI client automatically renews the lease when it is halfway expired. Author: sudipta tripathy (http://www. the lease term can be easily changed.jsp?EID=1085174). and is controlled by the system property java.

. . In the . Author: Avi Kak (http://www.jsp?EID=26410).jguru. Although the distributed garbage collection mechanism takes care of memory management issues.jguru. Apr 7.server. you can enable remote objects to get notified as soon as there are no valid references to it.logCalls property true). Comments and alternative answers After a remote server object is exported (and an 2000 It seems to me that merely implementing the Unreferenced interface is not enough for receiving notification of no more live references to a remote server object. explicit notification can help the remote server release valuable resources like network and database connections immediately. Any remote object that implements java. this renewal takes place regardless of the extent of client public void unreferenced() { //deallocate resources here } } Comments and alternative answers It seems to me that merely implementing the Unrefe.jsp?EID=26410). 2000 After a remote server object is exported (and an object reference to it created) by invoking its constructor.jsp?EID=1002 Created: Nov 14.jsp?EID=14) Yes. //allocate resources } ..jguru. Apr 8.rmi. Author: Avi Kak (http://www.dgc. This lease is renewed periodically and repeatedly after the expiration of half the value of rmi.and a very small lease term would cause the client to consume precious network resources in repeatedly renewing the .jguru. Can my remote object obtain notification when there are no live references to it? Location: http://www.leaseValue. it starts listening on a TCP connection. It is at this moment that its lease begins.server. 1999 Author: Govind Seshadri (http://www.. As can be seen from the logged server activity (which can be observed by setting the rmi. . The following code snippet demonstrates how: public class RemoteServerImpl extends UnicastRemoteObject implements MyRemoteInterface.. Unreferenced { public RemoteServerImpl() { super(). . .Unreferenced interface can get immediate notification via the unreferenced() method as soon as the server does not have any valid references to it.

getHostName().server. import java. } } ///////// server file: HelloServer. } catch( java. the Unreferenced.UnknownHostException un ) {} return "Hello from Avi Kak at " + hostname. the class HelloImpl implements the Unreferenced interface and provides an implementation for its unreferenced() method. try { hostname = InetAddress.rmi.rmi.unreferenced method is invoked (if the server implements the Unreferenced interface).*.net. public interface Hello extends Remote { public String sayHello() throws RemoteException. When the "reference" set becomes ">>>> No clients holding remote references <<<" ). .java //////// import java. public class HelloImpl extends UnicastRemoteObject implements Hello.*.java //////// import java. ///////// server file: Hello.out.rmi. import java.* //////// import java.*. } /////// server file: HelloImpl." But the following example shows that the meaning one would ordinarily give to these statements in the RMI specification document is not valid.getLocalHost().following "Hello" example. The RMI Specification document says: "As long as some client holds a remote reference to the remote object.*.server.rmi. import java. Unreferenced { public HelloImpl() throws RemoteException {} public String sayHello() { String hostname = null. Yet this method is never invoked even long after the client has stopped interacting with the server.*. } public void unreferenced() { System. the RMI runtime keeps a local reference to the remote object.

see the jGuru RMI FAQ entry 48518.jsp?EID=26410). Apr 29. helloserver ).com/guru/viewbio. There's got to be a better way Author: JJ Furman (http://www.*.rmi.jguru.. Is there any way to encourage it to go faster? JJ .jguru.lookup( "rmi://RVL4. This is far far too long for my application. the jGuru Distributed Garbage Collection Exercise shows that when there are no client references to a remote object that has implemented the Unreferenced" ). System. the server does indeed receive notification via the automatic invocation of the Unreferenced.createRegistry( 1099 ). For the reason for why the RMI system acts differently in the two /////// import java. a simple test is taking 10 minutes to detect a dropped client. Author: Avi Kak (http://www. } catch( Exception e ) {} } } ///////// client file: HelloClient.out. 2000 But at the same time.sayHello() ).rebind( "rmi://localhost/HelloServer". Naming. HelloImpl helloserver = new HelloImpl(). May 18.*. 2002 Although the Unreferenced mechanism seems to be working.jsp?EID=860138).. the jGuru Distributed Garbage.ecn.unreferenced() method. } catch( Exception e ) {} } } But at the same time.println( server. public class HelloClient { public static void main( String[] args ) { try { Hello server = ( Hello ) Naming.rmi.purdue.import java. public class HelloServer { public static void main( String[] args ) { try { LocateRegistry.registry.

jguru. and marks the object as clean.rmi.jguru.jguru. When a client obtains a remote reference.server.dgc.jsp?EID=1006 Created: Nov 1999 Author: Govind Seshadri (http://www.963 Author: Govind Seshadri ( the DGC decreases its reference count by 2002 You can try to add the system property: the remote object is free of any live client references.disableHttp=true What's the cleanest way to have a client terminate a RMI server that is no longer needed? Location: http://www.265 Author: Govind Seshadri (http://www. 1999 Modified: 2000-05-29 11:25:34.jguru. you can choose to disable this feature by setting the following property at the client: java.jguru. The article can be found in his "Web Cornucopia" DGC works by having the remote server keep track of all external client references to it at any given Is there a way I can disable my RMI client from using HTTP tunneling to get through firewalls? Location: .jsp?EID=14) Suresh Gopalan Raj has written a detailed article comparing the three technologies. Where can I find a detailed comparison between RMI.jsp?EID=1004 Created: Nov Created: Nov 14. 1999 Author: Govind Seshadri (http://www. DCOM and CORBA? Location: When the reference count reaches zero.jsp?EID=14) Yes. May Re: There's got to be a better way Author: Raul Guiu (http://www.jsp?EID=878594). Basically. Although HTTP tunneling is automatically used by the RMI transport layer to get across firewalls. 1999 Modified: 1999-11-18 22:16:04. When a client drops a reference.checkInterval=1000 How does the Distributed Garbage Collection algorithm work? Location: http://www. It is then placed on the weak reference list and subject to periodic garbage collection.jsp?EID=1013 Created: Nov 15. at: http://www.jguru. The DGC then marks the remote object as dirty and increases its reference count by one.jsp?EID=14) The RMI subsystem implements a reference counting-based distributed garbage collection (DGC) algorithm to provide automatic memory management facilities for remote server objects.jguru. it is addded to the remote object's referenced set.

jsp?EID=7). and can be overcome by deploying "signed applets" which can go beyond the Is there a servlet implementation of the java-rmi.jguru. 2004 The fact that two applets came from the same server is irrelevant. as otherwise an UnmarshallException is thrown. and then call System. 1999 Modified: 2001-07-07 20:58:56.jsp?EID=14) One approach is to define an "exit handler thread" as an inner class. Without signing your applet.jsp?EID=1033 .com/faq/view. It is one of the manifestations of the applet sandbox paradigm. It is very important that your server does not exit before the client's request has been fully processed.jguru.cgi script for enabling call forwarding when using RMI across firewalls? Location: http://www.jguru. 2004 there is any posibility to establish a communication between two applets comming from the same server but runnig in diferents clients machines(there is differents JVM and Browseers) without having a server that perform the rol of menssager dispathcher? Re: peer to peer applet communication Author: John Zukowski (http://www. Jan 12.171 Author: Govind Seshadri (http://www. waiting for an "exit" flag to be set by the client via an RMI call. there is no way for the applets to chat. and instantiate it within the remote object's constructor.jsp?EID=1031 Created: Nov the default behaviour for applets (including those that may be RMI clients) is to communicate with an RMI server that is hosted on the same platform from which the applet was served from. As soon as the flag is set.unexportObject() method to get rid of the exit handler can then wait for a couple of seconds such that the client call is completely processed. they won't have permission to talk to each other. unless you use a server to discover the other client address.exit() to terminate the server.The cleanest way to exit is to convert your remote object into an activatable remote object and then a client can invoke the Activatable. The exit handler can then loop in the background. Comments and alternative answers peer to peer applet communication Author: sebastian marcet (http://www. Even with signing. Jan 12. Things are a little more complicated if you do not have an activatable remote object. Is it true that my RMI applet can make socket connections only to the host from which the applet was downloaded from? Location: http://www.

sun.jsp?EID=14) The exception means that there is already an rmiregistry process running on the default port 1099 on that machine. it can bind.jsp?EID=1034 Created: Nov 15.jsp?EID=705911).com/guru/viewbio. as this restriction prevents a remote client from deleting or overwriting entries from a server's . 1999 Author: Govind Seshadri (http://www.jguru. This is mainly for security reasons. 2002 Is there are way to get around it ? What are the different RMI system configurations possible? Location: http://www.jguru.jsp?EID=1110 Created: Nov 17. Comments and alternative answers Is there are way to get around it ? Author: piyush sheth (http://www. or start it up on a different port .SocketException: Address already in use" whenever I try to run rmiregistry.jsp?EID=1035 Created: Nov No dynamic class loading is supported. 1999 Author: Govind Seshadri (http://www.jguru.jguru.363 Author: Govind Seshadri (http://www. You can either choose to kill it and restart rmiregistry.jsp?EID=14) 1999 Modified: 2000-05-29 11:32:07. rebind or unbind remote object references only with a registry running on the same host.html#servlet I get the exception "java.jsp?EID=14) Although an RMI application can perform a lookup on any host. Why? Location: http://www.Created: Nov You can download it from: http://java. Sun has a servlet implementation of the call forwarding script for performing HTTP RMI systems can be configured in diverse ways: • Closed: All classes used by clients and the server must be located on the JRE and referenced by the CLASSPATH environment Jan 16. as: rmiregistry 9999 Why is that my remote objects can bind themselves only with a rmiregistry running on the same host? Location: http://www.2/docs/guide/rmi/faq. say port 9999. 1999 Author: Govind Seshadri (http://www.

server. This URL points to a is used to specify a URL.codebase property? Location: http://www.server. that other JRE needs to load the class file for that object.rmi.jsp?EID=990941). Supporting classes are loaded by the property? Location: http://www.server.RMIClassLoader from an HTTP or FTP server on the network at a location specified by the server. all of the server code is loaded from an HTTP or FTP server located on the network.jguru. 1999 Author: Govind Seshadri (http://www. it looks for the embedded URL and contacts the server at that location for the file. Supporting classes are loaded by java. • Bootstrap server: In this alongside of the actual object.rmi. • Client dynamic: The primary classes are loaded by referencing the CLASSPATH environment variable of the JRE for the client. When would I use the java. If the remote JRE needs to load a class file for an object.jsp?EID=14) When the property java.jsp?EID=14) The property java. It is important to note that RMI does not send class files along with the serialized objects.rmi.rmi. all of the client code is loaded from an HTTP or FTP server across the network.codebase property. If a program running in a JRE sends an object to another JRE (as the return value from a method).jguru. or http: location which supplies classes for objects that are sent from this JRE. When RMI sends the object via serialization RMI embeds the URL specified by this parameter into the stream.useCodebaseOnly is set to true. Jan 29.rmi. The only code residing on the server machine is a small bootstrap loader.RMIClassLoader from an HTTP or FTP server on the network at a location specified by the client.rmi. • Bootstrap client: In this configuration. then the JRE will load classes only from either a location specified by the CLASSPATH environment variable or the URL specified in the java. What is the purpose of the java.jsp?EID=1115 Created: Nov 17. • Server dynamic: The primary classes are loaded by referencing the CLASSPATH environment variable of the JRE for the .jguru.server. • Server based: A client applet is loaded from the server's CODEBASE along with all supporting classes.jguru. This is similar to the way applets are loaded from the same HTTP server that supports the applet's web page.server. The only code residing on the client machine is a small bootstrap loader. Comments and alternative answers that's a very good solution Author: Marc Tauber (http://www. 1999 Author: Govind Seshadri (http://www.jsp?EID=1111 Created: Nov 17. This is an easy way of imposing additional security to the behaviour of RMIClassLoader.server.rmi.

jguru.2/docs/guide/rmi/relnotes. For instance.676 Author: Govind Seshadri (http://www.1. and could not be started 'on demand'. the RMI socket factory could use only one custom socket type per JVM.jsp?EID=1845 Created: Dec 4. all those limitations are removed." making it possible to build even more scalable distributed object networks.jguru.jsp?EID=14) Java RMI Jini RMI clients use the class Jini clients use the discovery process to locate Jini Naming.sun. With JDK 2000 Author: Govind Seshadri (http://www.jguru. you can now unexport a remote object.html How does Java RMI differ from Jini? Location: http://www. • There have been numerous other API changes as well. 1999 Modified: 2000-07-09 The Service hosting knowledge same rule applies to RMI servers The approach is more rigid since The approach is more tolerant to service providers faults client is dependant on a particular and maximizes client independence from a particular service provider service provider . RMI servers have to be up and running all the time. Also. consult the release notes at http://java. The most important changes are: • Under JDK 1. • Java 2 allows you to implement Custom Socket Types making it simpler to incorporate SSL encryption. as well as export a object on a specific port. 2003 cool! that works and is very easy to do! thanx a lot What's new in RMI under Java 2? Location: http://www.jsp?EID=14) Java 2 SDK adds significant enhancements to the RMI implementation found within JDK Discovery is done through multicast requested RMI Service requests to well-known addresses or ports The service storing information In Jini the service storing information about other about other service providers is service providers is called Jini Lookup Service the RMI registry The RMI client must know the The Jini clients search for the Jini service without any RMI registry host explicitly. and server-side skeletons are no longer necessary under Java 2.jguru. For an exhaustive list of changes. Java 2 adds Remote Object Activation framework to RMI. Now. You also had to use a different rmiregistry for each custom socket implemented by an RMI server.jsp?EID=5075 Created: Jan 15.1.1. the RMI transport protocol JRMP has been significantly streamlined. data compression and so forth at the transport It is now possible to instantiate server objects "on the fly.Lookup() for locating the Lookup services.

397 Author: John Mitchell (http://www. distributed events or can I assume that calls to it that originate within the local VM will enjoy the same "copy by value" rules for serializable .sun. The Jini proxy concept is more protocol independent since it does not rely on generated fixed-protocol stubs. send an email to listserv@java.jsp?EID=4) Yes. Please check them out before sending questions to the mailing list.rmi.jsp?EID=4) Yes.jguru.jguru. Is "pass by value" enforced for calls within the same VM to objects that implement java. 2005 SUN's RMI FAQ Is there a mailing list for RMI discussions? Location: http://www. Comments and alternative answers New url Author: Thomas Hartwig ( 2000 Modified: 2000-01-27 08:36:11.jsp?EID=9241 Created: Jan 27.jguru.jsp?EID=9243 Created: Jan which contains the message: subscribe RMI-USERS Note that the archives of the mailing list are here. if I'm writing an object that implements Apr 6. Sun's RMI-USERS mailing list.952 Author: John Mitchell (http://www.rmi. distributed events and leasing leasing Is there another RMI FAQ that I can look at? Location: http://www.Remote? In other words. To subscribe.jsp?EID=1108477).jguru.jguru. 2000 Modified: 2000-01-27 08:57:07. check out: Sun's RMI FAQ. The RMI proxy-stub approach is The proxy fulfills requests by itself or either uses an strictly adhered to RMI call or uses an internal proxy provider to fulfill a request No concept of built in support for Programming model provides for support for transactions.

There are two problems with your example..jsp?EID=10). Author: Ben Youngdahl (http://www. 2000 Modified: 2000-02-01 14:10:06. } } Here.078 Author: Tim Rohaly (http://www. Author: Tim Rohaly (http://www.. because we don't have a normal reference created by "new".jguru.jguru. If you obtain a reference by simply instantiating HelloImpl. we have a remote reference obtained by contacting the RMI registry. In this second case.sayHello() .lookup("rmi://localhost/helloserver").com/guru/ Say I have a remote interface: public interface Hello extends Remote { public String sayHello() throws RemoteException. then the "result" reference points to the same object as the local String object created within HelloImpl.jguru. which must be handled. First of. But.sayHello(). i.parameters? Location: http://www. Note that this is true whether or not the actual implementation object lives in the same VM. 2000 . hello. Method invocations on a local reference need handle only those exceptions declared by that method in the implementation class. for example: Hello hello = (Hello) Naming. effectively creating a copy.jsp?EID=10) Question originally posed by Ben Youngdahl (http://www.jguru..e.. 2000 Note that the call semantics also differ depending on how the reference was obtained. the return parameter of the sayHello() method is a serializable object (String). if we obtain a remote reference to the object.. then its semantics are that of a normal Java object. Method invocations on a remote reference can throw a RemoteException. if you do: Hello hello = new HelloImpl().com/guru/viewbio. String result = hello. Feb 1. } and an implementation like: public class HelloImpl extends UnicastRemoteObject implements Hello { public String sayHello() { return "Hello!". Feb 1.jsp?EID=10764). Comments and alternative answers Note that the call semantics also differ depending on. the result string is serialized and returned.a copy of the String object is not Created: Feb 1. The deciding factor is how the reference was then the semantics are different.sayHello().jguru.

html. like I say above. we will not need a stub for every instance? Eg. which is also not as interesting. See: http://archives. The two things you mention have no relevance to the. you focus on an immutable type.. String. which is not as interesting here as argument parameters. May 30. Also.jguru.jsp?EID=10). More work coming up: the client has to actually know beforehand which "name" that instance is bound to. Jun 10. You can learn more about the necessary differences between local and remote objects from "A Note on Distributed Computing" by Jim Waldo et al. the server application must already have instantiated such a servant instance. I disagree that this is consider the following: 1) X obtains a reference.jsp?EID=6973)... Does this mean that: In the first case (new &quot. First of There are fundamental differences between remote objects and local objects that you can't abstract away. bound it to an entry in This issue has also been discussed ad nauseam on the RMI-USERS mailing list. Thus. 2000 The two things you mention have no relevance to the problem: return parameters are treated the same as method arguments.jguru. In the second case (using remote references). Second of all. you focus on the return value. 2000 Does this mean that: In the first case (new "local" instance). Author: Ben Youngdahl (http://www. Author: Tim Rohaly (http://www. http://www.jsp?EID=49040). a server has a dispatcher that sends down a new servant instance to each True/False? Tim.sun.There are two problems with your example. Feb 4. it is dangerous if you don't treat them differently! This is why the compiler forces you to deal with RemoteException. it is always explicit in your code what the object's semantics are. Indeed. I think you should talk about why this is DANGEROUS that different things can happen depending on how the reference is obtained..jguru. Author: Jong Hann Wong ( and references to immutable objects are treated the same as references to mutable objects. ..

jguru. If Y is within the same VM as X. an object implementing Remote 2) X calls a method on Y passing in mutable. How do I send a ResultSet back to a client using RMI? Location: http://www. the only risk is if Y hangs on to a reference to M and plays around with it later. If M is immutable. 2000 Can anyone post some code for this? . 2000 Modified: 2000-02-16 01:11:05. Or.sql. 2000 Tim.jguru.0 public draft. so it cannot be sent over an RMI connection. M is not truly affected.512) of the EJB 2. you probably want to maintain control of them entirely on the server side or in a middle java. like for example COM/DCOM. and make that remote object available to your client.ResultSet is not serializable. so no harm done.jguru.jsp?EID=14711 Created: Feb 16. Comments and alternative answers Can anyone post some code for this? Author: sreedhar garimella (http://www. If M is returned by Y but not passed in by X. serializable object M 3) Y makes some evil changes to M The danger as I see it is that if Y is within a seperate VM. Doesn't it acknowledge this situation is dangerous? I do agree with you that it is dangerous to ignore whether an object is local or remote. wrap the ResultSet in a remote object. Jun it can't be changed by Y anyways. Because database connections are vital system resources. See Appendix A danger with the second method is that you are giving control over the life span of the ResultSet to the client--as long as the client holds a reference to the remote object your server must maintain the database connection. consider the following: 1) X obtains a reference to Y. M is affected.293 Author: Tim Rohaly (http://www. I guess that's my point here: don't assume that because an object extends Remote that it actually IS remote and will honor RMI pass- by-value. You will need to extract the data from the ResultSet and encapsulate it in a serializable object to send back to your client.7 (pp 511.

jsp?EID=20626 Created: Mar 6.jguru.jguru. 2002 You can also use the predefined Created: Feb Author: John Sinues (http://www. you'll be able to monitor server The rmiregistry program uses port 1099 by What's the scoop with HTTP-tunnelling? Does it really work? Reliably? Quickly? Easily? Location: http://www.rmi.jguru.761 Author: John Zukowski (http://www.sun.jsp?EID=17504 Created: Feb 23.746 Author: John Zukowski (http://www.REGISTRY_PORT.jguru.jsp?EID=19859 Created: Mar 2.html#FirewallIssues Where can I get the RMI classes for Internet Explorer? Location: http://www.rmi.jsp?EID=7) If you start the server with the I have a servlet that is doing an RMI call to a single remote object.How can I log my remote server calls? Location: http://www.jguru. Sep You can have it listen to a different port by specifying a different port from the command line: rmiregistry 1234 Comments and alternative answers Well known port for registry. 2000 Modified: 2000-09-14 07:42:58. what port does the RMI registry listen to? Location: http://www.server. Creating and tearing down a TCP/IP connection between the servlet engine and the .95 Author: Govind Seshadri (http://www.jsp?EID=14) Question originally posed by John Mitchell PREMIUM ( Server) By default. see my RMI tutorial at Sun's Java Developer Connection: and figure out where to put them or get a nice bundled package from IBM (http://www. 2000 Modified: 2000-02-23 system property set to true (java -Djava. that installs them in the right location. 2000 Modified: 2000-05-29 12:14:42.Registry.jsp?EID=4 For complete details. I'm observing a new TCP/IP connection for every single servlet request.rmi.557 Author: John Zukowski (http://www.jsp?EID=7) You can get these either directly from Microsoft (ftp://ftp. 2000 Modified: 2000-02-23 22:25:06. Since any invocation of the servlet is created in a new thread.

Some calls originating from the same client virtual machine will execute in the same thread. It seems that one could create an alternate implementation of java. The RMI object can be called by several threads Consider the following example. everything should be actually no. 2000 Modified: 2000-03-08 09:14:11. It is very easy to test: simply have a counter in the object which is ticked up one at the beginning of the method. In the scenario you describe. it would be simple to obtain a reference to the object in the init of the servlet and invoke methods on the objects in the service method. Servlets obtain a reference and invoke this method in their service methods. I have read through the RMI spec.server.jsp?EID=8332 A method dispatched by the RMI runtime to a remote object implementation (a server) may or may not execute in a separate thread. Since you will always deal with the same instance of the remote object at all points in time. Print it out and you'll know for sure what's happening. This will only hold to a certain point however since there is a finite number of server threads.jguru. A remote object MyObject is bound to the registry and it has a method called mymethod().jguru. This way you'll know how many threads are working on it concurrently.. and decrease it at the end. It is rather simple: RMI/JRMP maintains connections from the client to the server.jguru. 2000 . the RMI runtime makes no guarantees with respect to mapping remote object invocations to threads.159 Author: Sameer Tyagi (http://www. some will execute in different threads. As long as the object itself is thread safe. Comments and alternative answers For RMI callback from server to clients(say. Let us assume that 500 concurrent calls are made to this method from the servlet instance. Author: Maxim Senin (http://www. Nov 3..rmi.jsp?EID=4381) Question originally posed by Phil Earnhardt (http://www.jsp?EID=21992). Does this mean that the 500 calls will be queued up ? Created: Mar 6.RMIClientSocketFactory that could manage a pool of TCP/IP connections and assign them to threads on an as- needed basis. Calls originating from different client virtual machines will execute in different threads.remote object's JVM for every request seems to be a lot of overhead. Is this possible? Location: http://www. If a call is to be made and all connections is currently in use another one is created. Other than this last case of different client virtual machines. applets).

jguru. the RMI runtime makes no guarantees with respect to mapping remote object invocations to threads </quote> that means RMI Runtime may/may not create a separate thread for each remote request.jsp?EID=7 You can find all the details you need within the following Sun documents: The SUN SSL Info Creating custom socket factories The naming registry is implemented as a standard RMI service. The server would need to invoke a method like this before binding the object and starting the registry and similarly on the client beore looking up the object . Some calls originating from the same client virtual machine will execute in the same thread. rather it does'nt. the naming registry must use SSL to accept connections. Calls originating from different client virtual machines will execute in different threads. and then method invocations themselves!!! Singleton RMI object Author: Sudha Subramaniam (http://www. For RMI callback from server to clients(say.jguru. Apr My question is: Does this mean that the JVM creates seperate threads for each remote request? Thanks Sudha Re: Singleton RMI object Author: karthik Guru (http://www. so attempts to register and lookup services will involve network connections being established. With an SSL socket factory installed in a client these connections will be SSL-secured. The most straightforward way to achieve this is to have your server start its own naming registry. 2000 Modified: 2000-03-08 it was mentioned that an 'RMI object can have multiple threads accessing it concurrently".51 Author: Sameer Tyagi (http://www. For this reason you must install the SSL socket factory in your naming registry as well as your RMI server.jsp?EID=20911 Created: Mar 6. This registry will then benefit from the server's SSL support. 2002 quoting from RMI SPec: <quote> A method dispatched by the RMI runtime to a remote object implementation (a server) may or may not execute in a separate thread. applets) this would be disaster.jguru. 1st.jsp?EID=4381) Question originally posed by John Zukowski PREMIUM (http://www. Other than this last case of different client virtual machines.jsp?EID=849009). some will execute in different threads.jsp?EID=270396). 2001 In reply to one of the RMI question posted here.jguru. which in turn will try to open connection to it (100 clients = 100 attempts to open TCP/IP connections to clients who probably have dial-up). you will spawn separate thread for each callback to How do I communicate over a secure RMI link? Location: http://www. Sep As a result.jguru.

how do I get my objects to run in multiple VMs and not the VM of rmid.sameer. MarshalledObject data) ActivationDesc(ActivationGroupID groupID. } .jsp?EID=4381) The deal with spawning multiple VMs is the following bottom line. import java.println("Hello Server Constructor invoked" +counter). I have enclosed with this the complete example. import java. package com. Refer to page 56 of the RMI specs .com/faq/view.out. public class HelloServer extends Activatable implements Hello { private static int counter=0. public HelloServer(ActivationID id.exe ?? Location: http://www. 2000 Modified: 2000-03-10 13:08:36. "All objects with the same groupID are activated in the same Java VM". The batch files to run both client and server.createRegistry(). you can see that 2 VMs are spawned when the client is run.557 Author: Sameer Tyagi (http://www. String String className. To start multiple VMs.*.setSocketFactory (some vendor provided factory). import java.jsp?EID=22886 Created: Mar The client program 5. period.jguru.RMISocketFactory. Note : In other words the vendors provide a SSL implementation of the registry that needs to be started instead of the rmiregisty in case you are not programmatically statring the registry through a LocateRegistry. the object must have a differnt ActivationGroupID. System. The remote interface 2. 0 ).. String className.jguru.InetAddress. The remote interface implementation 3. 4. MarshalledObject data..*. For activation. Since the objects are lazily activated. The program to register the server. and you must use one of the 2 constructors ActivationDesc(ActivationGroupID groupID. MarshalledObject data) throws RemoteException { super( id. The example contains 1. boolean restart) I have written an example for you that registers 2 Activable objects with the registry. String location.rmi. The 2 objects have different ActivationGroupID's as you can see in the source.activation. counter++.

UnknownHostException who){} return "Hello World from " + hostname. } } package com. import java.rmi. the // current JVMs activation group is used // create more ActivationGroupIDs since objects with the same ActivationGroupID are activated in the same VM //ActivationDesc(ActivationGroupID groupID. Stringl ocation.put("java.po licy").rmi.sameer. import java.getSystem(). exampleGroup. } package com. ActivationGroupID agi = public interface Hello extends java. ActivationSystem localActivationSystem = public String sayHello(){ String hostname=null. //The activation group is what creates the activatible object in a JVM // Sets the activation group for the current JVM ActivationGroup. null). // Since the ActivationGroupID is not given in the constructor of desc.Properties. ActivationGroupDesc exampleGroup = new ActivationGroupDesc(policyFileLocation.getHostName(). policyFileLocation.registerGroup(exampleGroup). public class RegisterHelloServer { public static void main(String[] args) throws Exception { Properties policyFileLocation = new Properties().getLocalHost()."c:\\rmiac\\java.RemoteException.*.sameer. import java.activation. }catch (java. try{ hostname= InetAddress. MarshalledObject data.*. boolean restart) /* .rmi.Remote { String sayHello() throws java.rmi. String className.createGroup(agi. 0).util.policy".

sayHello()). } } package com. null. "file:/export/home/whitney/java/classes/". "file:/export/home/whitney/java/classes/". System.println(obj_2.out.out. null. "com.sameer.getMessage()). Naming.exit(0).println("HelloClient exception: " + e. If the ActivationGroupID does not exist a new one is created.register(desc_2).println("Gourp ID =" +desc.printStackTrace().HelloServer". // Spawn the second VM !! Hello obj_2 = (Hello) Naming. import java. Naming. */ ActivationDesc desc = new ActivationDesc(agi.println(obj.registerGroup(exampleGroup).println("Gourp ID =" +desc_2.HelloServer". stub).out. stub_2). System. "file:/export/home/whitney/java/classes/". ActivationDesc desc_2 = new ActivationDesc(agi_2.HelloServer". true). } catch (Exception e) { System. System. e.*.sameer. ActivationDesc desc = new ActivationDesc("com. "com.rmi.lookup("/HelloServer2"). true). null. public class HelloClient { private static String message = "".sayHello()). // create another one for a new VM ActivationGroupID agi_2 = localActivationSystem. This creates in the current VM and the current identifier for the ActivationGroupID. System.register(desc). Hello stub = (Hello)Activatable. true).getGroupID()). } } } .sameer.out.getGroupID()).rebind("HelloServer2".out.lookup("/HelloServer").sameer.rebind("HelloServer". public static void main(String args[]) { try { Hello obj = (Hello) Naming. System. Hello stub_2 = (Hello)Activatable.

grant {
// Allow everything for now

What protocol does RMI use to communicate between objects? Do
developers need to know the underlying protocol (eg. UDP, TCP/IP) while
developing RMI applications?
Created: Mar 12, 2000 Modified: 2000-03-12 23:55:45.054
Author: John Zukowski ( Question
originally posed by YekSoon Lok

On top of TCP/IP, RMI uses a wire level protocol called Java Remote Method Protocol
(JRMP). JRMP is a proprietary, stream-based protocol that is only partially specified
and now consists of two versions. The first version was released with the JDK 1.1
version of RMI and required the use of Skeleton classes on the server. The second
version was released with the Java 2 SDK. It has been optimized for performance
and it does not require skeleton classes. (It is important to note that some alternate
implementations, such as BEA Weblogic and NinjaRMI do not use JRMP, but instead
use their own wire level protocol. ObjectSpace's Voyager does recognize JRMP and
will interoperate with RMI at the wire level.)

Sun and IBM have jointly worked on the next version of RMI, called RMI-IIOP, which
will be available with Java 2 SDK Version 1.3. The interesting thing about RMI-IIOP is
that instead of using JRMP, it will use the Object Management Group (OMG) Internet
Inter-ORB Protocol, IIOP, to communicate between clients and servers.

In most cases, developers do not need to know about the underlying protocol.

With JDK 1.2, what policies do I have to setup to grant the necessary
permissions for RMI?
Created: Mar 15, 2000 Modified: 2000-03-15 07:34:14.029
Author: John Zukowski ( Question
originally posed by sajith prasad k

Sun's RMI tutorial shows the necessary policies at Basically, you have to
enable connecting from anywhere to the HTTP port and connecting or accepting a
connection to any port over 1K.

Is there some way to lookup what remote services are available?
Created: Mar 15, 2000 Modified: 2000-03-15 17:59:37.946
Author: John Zukowski ( Question
originally posed by John Zukowski PREMIUM

The Naming.list() method allows you to get a list of the objects in the registry,
returning a String[] of names that can be looked up.
Comments and alternative answers

Is there some way to lookup what remote services are available?
Author: Ricardo V (, Dec 3,
And, is there some way to avoid clients from looking up what remote services are
available? Thanks.

How do I setup a Servlet as an RMI client (and not get an RMI Security
exception in the process)?
Created: Mar 19, 2000 Modified: 2000-08-13 16:39:20.301
Author: Dieter Wimberger (
Question originally posed by John Collins

I think this depends a lot on the JDK you are using to run your Servlet Engine.

• Platform 2 (JDK 1.2, 1.3): take a look at the security policy. Refer to the
documentation for setting correct entries, plus
maybe File Access Permissions and in some cases ClassLoader permissions.
• Platform 1 (JDK 1.1.x): The only real way I found to circumvent my problems
was to implement my own RMI SecurityManager. Therefore simply extend the
java.rmi.RMISecurityManager class and implement your own policy overriding
specific permission check methods. Most likely those will be: checkConnect,
checkRead, checkWrite. But I suggest to examine the API doc of the
RMISecurityManger to find out more.

To set that SecurityManager you have to add following line to your Servlet init()

//set RMI Security Manager<br> System.setSecurityManager(new

Comments and alternative answers

Beware -- some vendors have broken implementations...
Author: Jeff Williams (, Oct 19, 2000
Beware -- some vendors have broken implementations of the security manager that will prevent this
type of access control from working. If you are running third-party code, you should be aware that it
might be able to seriously compromise your server.

You have to make sure that the servlet engine and JVM you are using...
1) use a security manager
2) the security manager does something meaningful

3) the security policy is meaningful

Try these flags in the command that starts java -Djava.

Here's some code I use in the doGet of a TestServlet to test security...

System.out.println( h2o + "Information..." + h2c );
System.out.println( " Security Manager: " +
System.getSecurityManager().getClass().getName() + p );
System.out.println( " ClassLoader: " +
this.getClass().getClassLoader() + p );

// weblogic.utils.classloaders.GenericClassLoader gcl =
// gcl.setDebug( true );

System.out.println( " CodeSource: " +
this.getClass().getProtectionDomain().getCodeSource().getLocation() + p );
System.out.println( " -- allowed -- " + p );
catch( Exception e ) { System.out.println( " -- rejected -- " +
e.getMessage() + p ); }
out.println( h2o + "Trying some dangerous J2EE calls..." + h2c );
String hack = request.getParameter( "hack" );
Cookie[] cookies = request.getCookies();
out.println( " -- allowed -- " + p );
int x = 1 + 2 + 3;
System.out.println( hack ); // use it
int y = 1 + 2 + 3;
System.out.println( cookies ); // use it
String m = "COOKIE: " + cookies[0]; // use it again
cookies = new Cookie[10]; // reset it
String n = "COOKIE: " + cookies[5]; // use it again
catch( Exception e ) { out.println( " -- rejected -- " + e.getMessage() +
p ); }

System.out.println( h2o + "Attempting file write to d:/Java..." + h2c
File f = new File( "d:/Java/blah.txt" );
FileWriter fw = new FileWriter( f );
fw.write( "test\n" );
System.out.println( " -- allowed -- " + p );

" + h2c ).getMessage() + p ).properties" ). .com" ). } catch( Exception e ) { System. File f = new File( "c:/weblogic/weblogic..allowed -." + h2c ).out.getMessage() + p ). System.allowed -.println( h2o + "Attempting to connect to yahoo." + h2c ).getMessage() + p ).println( h2o + "Attempting file write to d:/Java/TestServlet. } catch( Exception e ) { System. } try { System.println( " -.println( " -.out. } try { System." + p ). Socket s = new Socket( "yahoo.out. 8080 ). System.rejected" + p ).out. fw.rejected -.println( h2o + "Attempting to connect to hacker.out. File f = new File( "c:/Ntdetect.out. System. FileReader fr = new FileReader( f ). FileWriter fw = new FileWriter( f ).println( " -.out.println( " -... } try { System." + p ). System." + p ).com"." + e.. File f = new File( "d:/Java/TestServlet/blah.rejected -.allowed -.rejected -..getMessage() + p ). } catch( Exception e ) { System. fw.println( "". } try { System. } catch( Exception e ) { System." + e.println( h2o + "Attempting file read to c:/ Socket s = new Socket( "hacker.write( "test\n" ).out. } try { System." + h2c ).txt" ). int c = fr..out.allowed -. } catch( Exception e ) { System..out.out.println( " -..close().println( " -.rejected -. int c = fr." + e." + e.println( " -.println( h2o + "Attempting file read to c:/weblogic/weblogic.getMessage() + p )." + e.out." + h2c ) 8080 ).println( " -. FileReader fr = new FileReader( f ).

Socket c = s.. System.println( h2o + "Attempting native call.out..println( " -. } catch( Exception e ) { System.rejected -.out..." + h2c ). } catch( Exception e ) { System.println( " -.println( h2o + "Attempting to listen on port 37337.getMessage() + p ). System.getMessage() + p ).println( " -." + p ).out." + p ).getMessage() + p ).rejected -." + e." + h2c ). System..exit( 3 ).out.println( " -. Runtime. } catch( Exception e ) { System.allowed -." + e. System.out.accept()." + h2c ).rejected -. ServerSocket s = new ServerSocket( 7001 ).allowed -.getRuntime().out.rejected -.println( " -.getMessage() + p ).allowed -.out.out.out. } try { System." + p )." + p ). } try { System.out. System.out. System." + p ).out. } catch( Exception e ) { System.println( h2o + "Attempting to listen on port 7001.println( " -.out." + e." + e. } . } */ try { System. Socket c = s. native0( 1 ). } catch( Exception e ) { System." + e.println( h2o + "Attempting system exit.out.. System.println( " -.getMessage() + p )." + h2c ).println( " -.out.getMessage() + p ). ServerSocket s = new ServerSocket( 37337 ).println( " -..allowed -.allowed -.println( " -." + p ).rejected -. } catch( Exception e ) { System.accept()." + e.. } try { System." + h2c )..allowed -..println( " -.println( " -.rejected -.println( h2o + "Attempting exec.out.exec( "dir" ).out. } /* try { System.

In RMI.jsp?EID=33986 Created: Apr 9. (iii) waits for the result of the method invocation. (v) returns the value to the over ( restarting killed or inactive JVM processes ) Does a stub possess a server-side role also? Practically all the literature on RMI. ..println("</BODY></HTML>"). 2000 Modified: 2000-04-09 16:52:27. rebind. once I generate a stub class and copy it over to the client side. The caller invokes a method on the local stub which is responsible for carrying out the method call on the remote object. Author: Marek Paszcza ( Referring to its client-side role. System. Sep 28. a stub for a remote object implements the same set of remote interfaces that a remote object it does the following: (i) initiates a connection with the remote VM containing the remote object. (iv) unmarshals (reads) the return value or exception returned.jguru. can it now be safely deleted from the server side? Location: http://www.174 Author: Jason Vanguard ( For instance. 2000 In fact there seem to be no standard way to control it.out. think about specializing the Registry class and all RMI calls ( bind. If it is essential to you. } How do I control number of clients binding to the RMI server? Location: http://www. 2000 Modified: 2000-03-29 11:50:11. Comments and alternative answers In fact there seem to be no standard way to control. this is what the RMI Specification document has to say about stubs: A stub for a remote object acts as a client's local representative or proxy for the remote object. I have done that way a mini-application server with . including the RMI Specification document.jguru.jguru. ) and introduce the caller control mechanism.jsp?EID=27748) Question originally posed by Anatolii Corobceanu (http://www.jsp?EID=28546 Created: Mar (ii) marshals (writes and transmits) the parameters to the remote VM.293 Author: Avi Kak ( talks only about the role of a stub on the client side.jguru.load balancing ( among many JVM processes ) .jsp?EID=24161 The Sun RMI implementation does not offer a standardized method to control the number of clients biding to a remote object. .jsp?EID=124786). When a stub's method is invoked.

jsp?EID=26410).html Comments and alternative answers The document cited by Damian Fernandez Perez is ob. It is the stub objects that get transmitted over to the client side over the TCP link.jguru. This is immediately apparent if after copying over the stub to the client side you try to delete it from the server side.jsp?EID=38368 Created: Apr 20.jguru.jsp?EID=37229 Created: Apr 17. 2000 Modified: 2000-04-20 11:56:38. Apr 26.jsp?EID=10) Question originally posed by arshad mehmood (http://www.457 .com/faq/view.jsp?EID=37224 RMI uses serialization as its basic and only mechanism for sending objects across a network.. When a client invokes a method on a remote server Author: Damian Fernandez Perez ( How can I develop a chat system using RMI? Location: http://www.jguru. the method is actually invoked on the locally available version of the stub object corresponding to the remote server object. then the object itself is serialized and with RMI applications? Location: http://www. an even more useful source is Govind Seshadri's on-line tutorial at http://developer. What role does serialization have in RMI? Location: http://www. the stub class is needed to construct stub objects corresponding to the remote How can I load the stub and interface files dynamically at the client. then the object's stub is serialized and sent to the client. If the object implements java.jsp?EID=28785 You can find the answer to this question at: http://java.rmi. 2000 Modified: 2000-04-17 21:17:32. The Java runtime would then throw an exception with the error message: "Stub class not Author: Tim Rohaly ( The fact is that the stub of an implementation class has a server side role also.The Specification document says practically nothing about the role of a stub class on the server side.jsp?EID=1958) Question originally posed by Puneet Sachdeva (http://www.jguru.jguru. If an object implements Author: Avi Kak (" On the server side. Created: Apr 11. instead of copying manually. 2000 The document cited by Damian Fernandez Perez is obviously a "must read" for anyone starting out with dynamic loading of stubs and other supporting classes. 2000 Modified: 2000-04-11 20:19:16.

2000 Modified: 2000-04-22 18:16:21. 2000 Modified: 2000-04-21 13:33:51.jguru.jsp?EID=7 If an object implements java.rmi.html.jsp?EID=30243) Question originally posed by rajesh r (http://www.jsp?EID=4381) SUN provides a good trail in the Java tutorial that covers RMI at This can be done by Input/Output streams.jguru. Then you would develop a client program which connects to this Created: Apr 20.jguru. This is true whether or not the object also implements java. you would basically create a server which listens for connections on a port and accept these connections and get each clients names. but to give you an idea. to tell you exactly how to do it would take up too much or do the objects have to implement Serializable directly? Location: http://www. then RMI will attempt to serialize the object Where can I find a good tutorial / jumpstart to RMI ? Location: i. Note that Externalizable extends Serializable.jsp?EID=40176 Created: Apr 25.jguru. so anywhere you see the use of the generic term "serializable" you can assume it refers to objects that implement either of these interfaces.jsp?EID=36391 or java. If the object is not an instance of is the stub serialized and sent to the client or is the object? Location: http://www. or (the easier way) RMI. This will succeed only if the object is Comments and alternative answers . This includes objects that implement Externalizable as well as objects that implement Serializable.jsp?EID=10) RMI will allow you to pass any object that is serializable according to the serialization specification.jguru. its stub is serialized and sent to the client.jsp?EID=10) Question originally posed by John Zukowski PREMIUM (http://www. then it is treated as a remote object - that is.jguru. Can I pass Externalizable objects by value using Shaun Childers (http://www.87 Author: Sameer Tyagi (http://www. When one "client" types a message and presses 'Send' If a class implements both the Serializable and Remote interfaces.jguru.951 Author: Tim Rohaly (http://www.Externalizable. the message is routed through the server and out to all "client's" implements java.jsp?EID=38866 Created: Apr 21. 2000 Modified: 2000-05-18 15:02:00.rmi.375 Author: Tim Rohaly (http://www.

com/guru/viewbio. RMI over IIOP provides flexibility by allowing developers to pass any serializable Java object (Objects By Value) between application components.jsp?EID=10865 The LocateRegistry.. RMI over IIOP speeds distributed application development by allowing developers to work completely in the Java programming method takes a certain time to complete. Why? It works only when I start the registry as a stand-alone process from a different window.createRegistry() and spawn child processes (not thread!) from the main process. Like CORBA.jsp?EID=14031 Remote Method Invocation (RMI) over Internet Inter-Orb Protocol (IIOP) delivers Common Object Request Broker Architecture (CORBA) compliant distributed computing capabilities to the JavaTM 2 platform and to the Java Development Kit (JDKTM) 1. You can also try the jGuru tutorial at the JDC: ht. Author: John Zukowski (http://www.jguru. Your child processes may have to introduce a delay in order to allow the registry to be created and installed by the main process. If I programatically create an RMI Registry using LocateRegistry. Like Created: Apr 25.361 Author: Sameer Tyagi ( What is the benefit of using RMI over IIOP? Location: http://www. the child processes are not able to bind objects into the Registry created by the main process.jguru. Smalltalk.jguru.jguru.jsp?EID=4381) Question originally posed by zhu jiang (http://www. Dec 18. RMI over IIOP was developed by Sun and IBM. IIOP eases legacy application and platform integration by allowing application components written in C++. 2004 . RMI over IIOP is based on open standards defined with the participation of hundreds of vendors and users in the Object Management RMI over IIOP uses IIOP as its communication 2000 Modified: 2000-05-02 18:35:13. and other CORBA supported languages to communicate with components running on the Java platform.jsp?EID=1216996).jguru.jguru.. Comments and alternative answers calling rmi method problem if starting rmi server programmatically Author: yi li ( May 18.jguru. 2000 Modified: 2000-05-04 22:00:00. The joint work by Sun and IBM to implement Object Management Group (OMG) standards demonstrates the spirit of collaboration that continually moves the Java platform forward. 2000 You can also try the jGuru tutorial at the JDC: http://developer.jsp?EID=4381) Question originally posed by Ashok S ( When using RMI over IIOP to produce Java technology-based distributed applications. there is no separate Interface Definition Language (IDL) or mapping to learn. Like RMI over IIOP combines the best features of RMI with the best features of CORBA.jsp?EID=40202 Created: Apr 25. Like CORBA.057 Author: Sameer Tyagi (http://www.sun. Location: http://www.

UnicastRemoteObject class it is possible to make a call to the static method in the same class: exportObject(Remote). thanks.. 2000 Modified: 2000-06-21 15:46:21. Is there any reason to invoke RMISecurityManager on the server side of an RMI application? Location: http://www. look up was sucessful but the client is hanging when calling the rmi method. } Good luck! Comments and alternative answers You can also just use delegation -. yi Some Java books show RMI code in which the security manager is set to RMISecurityManager on the server side of an RMI application. there is no reason to use RMISecurityManager on the client side either. A simple example follows (exception handling omitted) : public class MyServlet extends HttpServlet implements MyRemoteInterface { public void init(ServletContext ctx) { i have a similar problem: if i start a rmi server programmatically using Rumtime.jsp?EID=41803 Created: Apr 28.rmi.jsp?EID=7 Instead of letting your service subclass the java.555 Author: Mikael Jakobsson (http://www. If a client does not need to dynamically load any classes from a server (or any other remote source). Thus you should let your class subclass GenericServlet/HttpServlet and implement a Remote interface.jguru.server. 2000 Modified: 2000-04-30 23:54:44. Do you have any tip for this? it's simple rmi programs and i don't use activation.make a normal .com/faq/view. .jsp?EID=41015 Created: Apr 26. How can my servlet class which subclasses GenericServlet/HttpServlet provide an RMI service? Location: http://www.jguru.jguru. In the init(ServletContext) method your instance can export itself.exec ("java myclass").. } // rest of code goes here..jsp?EID=26410) There really is no reason to set the security manager to RMISecurityManager if an RMI program has a purely server role on all its communication links. then my client program tries to look up and call the remote Question originally posed by John Zukowski PREMIUM (http://www.373 Author: Avi Kak (http://www.. RMISecurityManager (and user-defined security managers obtained by extending RMISecurityManager) are for subjecting the dynamically loaded classes by a client application to security control.exportObject(this).com/guru/viewbio.getRuntim.

.704 Author: Mikael Jakobsson ( a normal Remote Object by extending UnicastRemoteObject in the normal way. Author: Alex Chaffee (http://www. you create an instance of that remote object and register it with the name server. The server can now call methods of the clients remote interface via this reference! Is there any way I can send a remote object through RMI to the server that the server can then use to trigger a callback at the client? Location: 2000 I do not understand the above suggestion by Alex.jguru.jguru. implementing a Remote interface and beeing exported as a UnicastRemoteObject (either by subclassing UnicastRemoteObject or by using the static exportObject() method of that class).com/guru/viewbio. Author: erik leedom ( Sep 13.jguru. you can! . Then other objects can access it using normal RMI calls. Apr 30. but a remote reference is established.jsp?EID=26731 Yes.jsp?EID=41777) Question originally posed by Allan Wax (http://www. 2000 Modified: 2000-05-05 05:57:38. As a bonus. you could have your servlet intercept HTTP GET or POST calls to invoke methods on the remote object. and the object will not be serialized as other parameters. If you do this how is the RemoteObject that is containted within the servlet going to access the servlet's data and If this is done. 2000 You can also just use delegation then in your servlet's init method.jguru. .jsp?EID=41777) Question originally posed by John Zukowski PREMIUM (http://www.. a reference to the client can be sent to the server as a parameter of a server method. which is what it would have to do to provide the functionality that the original question requested? You would have to pass the UnicastRemoteObject instance a refrence to the servlet right? Which wouldn't be so bad but I would hazard is not quite as clean as the original response Can my remote client also serve as a remote object? Location: http://www.jguru.jguru.jsp?EID=7 2000 Modified: 2000-05-05 Created: Apr 28. Just make sure your remote client is implemented as an RMI service. I do not understand the above suggestion by Alex.jsp?EID=41807 Created: Apr 28.961 Author: Mikael Jakobsson (http://www.

The server must have a stub for the client in order to do the The server must... then the client can resolve it into correct instance? Re: Re: The ugly part about this is the stub. From the client: 1. 2001 Do you have any suggestions on how to work around this problem? Basically. like passing "this" pointer in C++ which represents the "AppData". I wanted outside developers to be able to connect via RMI to our application and register to listen for callbacks as well as making calls to the application. Jul 20.jguru. you'll also have to generate the stub and skeleton files for the client as well as the server using rmic.. The server must. the server will receive a remote reference in the registerClient() method. the server needs a remote object stub for the outside application. this may not always be possible. The client is also a remote object. Jul 20.jguru.jsp?EID=459034).com/guru/viewbio. Nov 17. Lookup the server using the Naming. Re: The ugly part about this is the stub.registerClient(theRemoteClientObject).jsp?EID=60369). but that requires the server administrator to keep up with foreign code. 2000 The ugly part about this is the the server does not have the stub. let's call it registerClient(ClientRemoteInterface) . The outside user then uses the wrapper class in his application as a proxy to get to the server. 2001 In my case I was creating APIs for our application. Now. Since the server is built by us and the outside application by someone else. And you may not want to give all clients the authority to place files on your server.lookup as usual 2. To do the callback. It is the wrapper . call the server method: server.jsp?EID=60369).. and later server can pass back to client. Author: Sharon Lu (http://www... You could require the outside developer to place his stub in the server's classpath.Let the server have a method. What I did was write a wrapper class that encapsulates the RMI functions on the client side. Since the client may be unknown when the server is built. Of course. This wrapper is distributed to the outside developer with the stub and interface to our application. that can be used for callbacks to the client. Author: Will Cardwell (http://www. The server must.jguru. with ClientRemoteInterface as its remote interface. how do you pass an instance across RMI. Author: Will Cardwell (http://www. Comments and alternative answers The ugly part about this is the stub. Created: Apr 28. a security manager is not needed at all.jguru. and the server making RMI callbacks to the client. We distributed an interface.html contains the following statement on page 6: "A security manager is required in any JVM that needs to download code. and RMI clients need to download RMI stubs (as well as custom classes or interfaces needed to communicate with the RMI server). The using application class registers as a listener for callbacks by calling the wrapper class. Re: Re: Re: The ugly part about this is the stub.jguru. The server must. Our server needs the stubs of any new clients that are created. Heh.doc. If the downloaded code on the client side consists of RMI stubs only.jguru. Jun 25. In most RMI applications. RMI Callbacks Author: Jim Teaff (http://www. This works nicely and also frees the outside developer from having to deal with the RMI code at all. 2000 Modified: 2000-04-30 23:40:30." The quoted statement from the cited document is misleading. which is always the same no matter who the outside developer is. 2001 A code example would be very useful! Must a security manager be installed on the client side even if the downloaded code consists of RMI stubs only? Location: http://www.2/docs/guide/rmi/ Sun's RMI "getting started" guide: http://java. The server only needs a stub for this wrapper class. We should have done that. Nov 13. Author: Randy Pond (http://www.sun. Distributing a class file to the clients that act as a callback proxy is the right solution.. There is a distinction to be made between a client's loading of RMI stubs from a server and a client's dynamic loading of other classes and interfaces. We have clients making RMI calls to the server.. 2001 We have a similar situation in our development.jsp?EID=487474).837 Author: Avi Kak ( that actually exports itself as a remote object for the only reason for installing a security manager on the client side is to enable dynamic loading of classes by a client (and to then subject these classes to certain security restrictions). The stubs are transported over the TCP link that comes into existence when an exported remote server object receives a socket number from a client that has invoked the . But this is now only a local object reference and not a remote.jsp?EID=438114).com/guru/viewbio.

It is the code that is transported over the latter link that is subject to the security restrictions of the installed security manager. import java. public class HelloImpl extends UnicastRemoteObject implements Hello { public HelloImpl() throws RemoteException {} public String sayHello( Object obj ) { String returnString = null. ///// server and client file: Hello. public interface Hello extends Remote { public String sayHello( Object obj ) throws ////// import //////// import java. public class Female implements Serializable { } //////// server file: HelloImpl.server. typically through the http service provided by a*.io.*. On the other ///// import java. dynamic loading of classes and interfaces by a client takes place over another .rmi.*. The sayHello() method of the remote object on the server returns two different kinds of greetings. import java. depending on whether the client invokes the sayHello() method with a Male argument or a Female argument. public class Male implements Serializable { } ///// server and client file: Female.*.java ////// import java. The following example illustrates the fact that no security manager need be installed in an RMI application anywhere if there is no dynamic loading of code by a client.Naming.rmi. } ///// server and client file: Male.*.*.lookup() method for obtaining a reference to the server object from the server registry.rmi.

public class HelloServer { public static void main( String[] args ) { try { LocateRegistry.UnknownHostException un ) {} try { m = (Male) obj. Female f = null.logCalls=true HelloServer ////// client file: HelloClient. Sir! Hello from Avi Kak at " + hostname. public class HelloClient { . else { try { f = (Female) obj. try { hostname = /////// import java. String hostname = null. import java. } } } ///////// server file: runserver.server.*.*.sh //////////// java -Djava.getHostName().getLocalHost(). Naming.*. Male m = null. helloserver ).registry. } catch( Exception e ) {} if ( m != null ) returnString = "Good Day.createRegistry( 1099 ). Madam! Hello from Avi Kak at " + hostname. import } catch( //////////// import java. } catch( Exception e ) {} if ( f != null ) returnString = "Good Day. } catch( Exception e ) { e.printStackTrace(). } return returnString.rmi.server.rmi.rebind( "rmi://localhost/HelloServer".rmi. HelloImpl helloserver = new HelloImpl().rmi. } } /////////// server file: HelloServer.*. platform.jsp?EID=35233 Yes. The server object in turn can call other remote objects on the same machine or on different machines.lang.purdue. In the BootstrapExample exercise of the superb RMI tutorial from jGuru at the Java Developer" ).lookup( "rmi://RVL4. 2000 Modified: 2000-09-10 • By invoking more than one server objects directly from the same client. System.jsp?EID=41443) Question originally posed by wee yap ng (http://www.println( server.bat /////////// java HelloClient If I need to fetch data from multiple distributed datastores into an HTML page. public static void main( String[] args ) { try { Hello server = ( Hello ) Naming. and later format the data into HTML before sending the response to the client.jsp?EID=42394 Created: Apr 29.jguru. the on-demand loading of classes by an RMI client refuses to run on the Java 2 SDK v1.sayHello( new Male() ) ).988 Author: Avi Kak (http://www. can RMI solve my problem? Location: http://www.jsp?EID=43169 Created: May 1.493 Author: Pramod Hirole (http://www. the bootstrap class loader on the client side produces the following error message RMIClientLoader. } catch( Exception e ) {} } } //////// client file: 2000 Modified: 2000-05-07 21:25:55.sayHello( new Female() ) ). You can use servlet as the client for the RMI server .ClassNotFoundException: access denied to class loader What gives? Location: http://www. You can achieve it by two ways: • By invoking one server object in the client application. While the lightweight HTTP class server and the RMI server work fine.jguru. RMI can be used for this purpose. System.println( server. class not found: java.

bat ////// java -Djava. some containing classes and others containing command line statements.ecn. That is. You'd also need to replace the string RMI5.d/policy -Djava.d/" { permission it is not a good option since it violates the spirit of the RMIClientBootstrapSecurityManager class. The policy file contains: ////// client file: policy ////// grant codebase "file:/RMI5.purdue. Another equally unsafe option is to not use the RMIClientBootstrapSecurityManager class at all in RMIClassLoader. where you'd need to replace the string RMI5.SocketPermission "rvl4.purdue. The idea behind the RMIClientBootstrapSecurityManager class is to have a minimally relaxed version of RMISecurityManager for the RMIClassLoader to bootstrap load the stubs and the other support classes and interfaces on the client side.purdue.codebase=http://rvl4.server.ecn. }.edu by the name of your computer that is providing the HTTP service for downloading the classes needed by your client program. A null override for checkPermission() throws the security control wide open.The code supplied with the tutorial is contained in a number of different files.ecn. You'd also need to replace rvl4. While you are modifying the code. you might as well comment out the following line on the server side: .edu".net.ecn.policy=/RMI5.d by the pathname to the directory containing the RMI code on the client side.bat file on the client side: ////// client file: runclient. "connect". Use the following for the runclient. An alternative solution consists of incorporating on the client side the following null override definition for the checkPermission() method in the RMIClientBootstrapSecurityManager class: public void checkPermission( Permission perm ) {} Although this RMIClientLoader where you must replace the string rvl4.purdue.d by the pathname of the client-side directory containing the policy file. to use just the RMISecurityManager with a wide-open security as before.

Can I contact multiple RMI Servers from a single RMI Client simultaneously ? Location: http://www. you could use a server socket that accepts connections with which you send directions for registering classes. well not exactly To achieve this.jsp?EID=43957 Created: May 3.jsp?EID=30243) Question originally posed by Sri Harsha (http://www.server.setSecurityManager( new RMIServerSecurityManager() ).jsp?EID=4826) Question originally posed by Meena Guna (http://www.forName()).lookup("rmi://"rmi://that.jsp?EID=22005 Sure. you need : --The classname you want to instantiate --The remote Object name under which the instance will be registered. String classname) method.467 Author: Denis Balazuc ( 2000 Modified: 2000-05-07").jguru. Setting a security manager on the server side serves no useful function in this example. Mostly you will need to dynamically load and instanciate a class (using Author: Shaun Childers (http://www.jguru. from the main() of the RMIServer class. //now call some methods with each server catch(Exception e) {} } } How do I dynamically register a remote object to the RMI registry? Location: http://www. 2000 Modified: 2000-05-07 22:00:01. Another idea would be to use another RemoteObject which only service would be to load/create and register other Remote Objects through a register(String"). System. To instruct your RMI server to register new objects. ThatServer server2 = (ThatServer)Naming. .com/guru/viewbio.jsp?EID=44983 Created: May 5. and then register it within the RMI registry.jsp?EID=20525 There is many ways you could do but within the same client: //imports here public class MyClient { public static void main(String[] args){ try { ThisServer server1 = (ThisServer)Naming.jguru.

com/guru/viewbio. as explained below.d/" { permission java. } } In the event one wants to use a wide open security policy on the client side of an RMI program. but with a big Created: May 8. TraceFacility.jsp?EID=46389 Created: May 8. msg). it is not uncommon for programmers to use the can-do-anything-it-wants policy on the client side. }.jsp?EID=26410) Question originally posed by John Zukowski PREMIUM (http://www. 2000 Modified: 2000-05-13 20:30:23.You could also have a property file which contain <object name>=<object classname> and that will be parsed when starting your RMI server. A simple class that communicates with a central server logging facility using a static method (somewhat like the Unix syslog protocol) can be included on both the client and remote side.jguru. A recommended alternative is to make this wide-open policy specific to the directory containing the RMI code on the client side: grant codebase "file:/RMI5. Along with this you may wish to define an unchecked subclass of RuntimeException TraceableException which your code can throw.jguru. and in the constructor for the exception contact the log server and log the error. where different pieces are running all over the place? Can I do remote debugging? Location: http://www. During the initial phases of RMI code development.Allpermissions.834 Author: Steven Newton ( . Is it always possible to do so? Location: http://www. as given by grant { permission java. How do I debug RMI programs.Allpermissions. But this is obviously unsafe.jguru.trace(this. 2000 Modified: 2000-05-13 Something like: public class TraceFacility { public static trace(Exception e.jsp?EID=7 One useful way to do this is to create a remote tracing facility.158 Author: Avi Kak (http://www. it is recommended that the policy be made specific to the directory containing RMI String message) { // send stacktrace and message to central log server here } } public class TraceableException extends RuntimeException { public TraceableException(String msg) { super(msg).com/faq/view.

ecn.codebase=http://rvl4.jguru.AllPermission.setSecurityManager( new RMISecurityManager()). If you must use a wide open policy for convenience and your RMI application is doing dynamic loading of classes. if for the sake of demonstration I wanted to use a wide-open policy for running the the bootstrap loading example of the jGuru RMI tutorial. }. where the first "grant" gives the can-do-anything-it-wants privileges to the client- side RMI code in the directory "RMI5. to System. So if your client is engaged in dynamic loading of classes. 2000 Modified: 2000-05-13 20:50:22.472 . the additional declaration would mention the source of the downloaded directory.bat ////// java file System. }.d/" { permission java. }. You can put this policy file into effect by using the following runclient.d" and "rvl4.bat: ////// client file: runclient. But a problem with this policy declaration is that the can-do-anything-it-wants applies only to the code in the RMI5.ecn. rmi.policy=/ RMIClientLoader where you'd need to make obvious substitutions for the strings " -Djava. I'd change the following statement from main() of the RMIClientLoader.setSecurityManager( new RMIClientBootstrapSecurityManager()). It does not apply to any classes the client might download from a remote".AllPermission. For example.d" and where the second "grant" gives the same privileges to the code downloaded from the HTTP service provided by rvl4.ecn.purdue. where the directory RMI5.purdue.d contains the client side RMI code. and then use the following policy file on the client side ////// client file: policy ////// grant codebase "file:/RMI5.jsp?EID=47532 Created: May the above directory-specific wide-open policy will not work because the downloaded code would still get sandboxed. grant codebase "" { permission java. you'd need to add another declaration to your client-side policy file. How can I check that the connection between the server and the client is valid at all times? Location: http://www.purdue. that's a different story. 2001 I know this solution will work. and my task for the day. Nov 13.. 2001 That is the solution that we implemented for our RMI solution. If you wanted a client to know at all times that a connection with the server was alive.jsp?EID=591219). getting it to reconnect. Comments and alternative answers That's what we did Author: Randy Pond (http://www.especially if you are in internet world.jsp?EID=26410) Question originally posed by Shahram Khorsand (http://www. The client side code can catch this exception and act as desired.jguru. the exception java. This ping() method could be invoked inside a separate thread on the client side. but what about internet environment ? What's with the Unreferenced interface? It would seem that a server should be able to use the unreferenced() method of this interface to obtain notification if a client crashes or otherwise becomes disconnected from the server.ConnectException will be thrown on the client side.894 Author: Avi Kak (http://www. 2000 Modified: 2000-05-13 21:00:20. and vice versa. This approach could also be used by a server to check that the client is up continuously provided the client also implements the Remote interface and is exported as a UnicastRemoteObject.jsp?EID=3357 Because of the difficulty of differentiating between a down connection and an inactive connection.jguru.jguru. Dec 20. RMI does not provide an automatic check on whether a connection between a server and a client is up continuously. you could define for the remote server a simple ping() like method that when invoked by the client would return something whose receipt on the client side would indicate that the server was still up.jguru.jsp?EID=487474). As before. But this solution obviously will not work if a client is busy doing something else when the server goes down. a ping() like method defined for such a client could be invoked by the server to ensure the connection to the client was up and We have clients making RMI calls to the server. But it does not seem to work that way? Why? Location: If this "ping" throws an RMI exception. This thread could wake up at regular intervals and check on the server. but I think it's quite expensive for network traffic.jsp?EID=26410) . allowing us to verify the It would not be a problem in intranet environment.jsp?EID=48518 Created: May 12. that indicates a connection is down. Is there any cheaper method ? Author: Agus Santosa Kanihatu (http://www. Our server sends pings to the client. and the server making RMI callbacks to the clients. If a server goes down (or the server-client link breaks down) while a client is interacting with the server.rmi.Author: Avi Kak (http://www.

jsp?EID=48933 Created: May 14. the server does indeed receive notification via the automatic invocation of the Unreferenced. 2000 Modified: 2000-06-21 16:29:19.The RMI Specification document says: The java. On the other side of the coin. But in reality that does not happen.jguru.jsp?EID=49828 Created: May 16.unreferenced() will not be invoked on a server object as long as it stays registered. How do servlets differ from RMI? What are the advantages and disadvantages of each technology? Location: http://www.unreferenced() method of this Section 3.1 of the RMI Specification document says: In the server would be notified of such disconnection by automatic invocation of the Unreferenced.2-only environments.. The registry acts like a client with regard to the server objects that are How come the server-side skeleton class is not required under JDK 1. A servlet can receive a request to . .unreferenced() method is invoked.rmi.Unreferenced interface allows a server object to receive notification that there are no clients holding references to it. the code in the "Feedback and Comments" section of jGuru RMI FAQ Entry 1002. A registry holds a lease on a registered server object in much the same manner as a regular client. generic code is used to carry out the duties performed by the skeletons in JDK1.jsp?EID=48184 Servlets extend the server-side functionality of a website.. When the "reference" set becomes empty. the method Unreferenced. Servlets communicate with other application(s) on that server (or any other server) and perform tasks above and beyond the "normal" static HTML document. Reading 2000 Modified: 2000-05-14 21:08:38. the Unreferenced. So even if all the genuine clients were to get disconnected from a server. So why does the RMI system work differently in the two cases? This apparent anomaly can be explained by the fact that there is a distinction between remote objects that are registered with the RMI registry and remote objects that are not registered.081 Author: Avi Kak ( The reference set in this quote refers to the set of client VM's. each holding a reference to the remote object.jguru. for example.2 an additional stub protocol was introduced that eliminates the need for skeletons in JDK1..unreferenced() method.035 Author: Shaun Childers (http://www. one can see easily from the jGuru Distributed Garbage Collection Exercise that when there are no client references to a remote object that has implemented the Unreferenced interface.jsp?EID=30243) Question originally posed by mehdi lababidi (http://www. Instead.jsp?EID=26410) Question originally posed by alok kumar (http://www.jguru.2? Location: http://www.. one could draw the conclusion that if all the clients got disconnected from a server that has implemented the Unreferenced interface.jguru.

2001 I used the LocateRegistry as shown in the example. you must bind the RMI server to an IP and port.jguru. 2000 Modified: 2000-06-08 Question originally posed by Ivan Lim (http://www. The RMI registry in that program is started by the invocation LocateRegistry. and the client who wishes to talk to the remote server must know this IP and port. you need only to know the web address and the pages displayed to you take care of calling the different servlets (or actions within a servlet) for class file. online grocery throws an exception Connection refused.jguru.51 Author: Avi Kak ( Created: May 16. see the code in the Feedback and Comments section of jGuru RMI FAQ Entry it still looks like it happened at that website. I use this in Sun ultra! Does there exist a minimal "Hello" kind of an example for getting started with the Remote Object Activation feature of RMI? Location: for example. With servlets. For more detailed information regarding servlets and RMI refer to following sun sites: http://www. But the subsequent call to Even if the servlet talks to many other applications all over the world to get this unless of course you used some kind of in-between lookup utility. It is way for an application to talk to another remote machine and execute different methods.createRegistry( int port ) method in the program that hosts your server object. May 16. then convert this data into a static HTML/WML page for the client to see.jguru. etc.jsp?EID=50322 Created: May 16. which you could do with (of all things) servlets. How do I create an RMI registry without using the rmiregistry program? Location: http://www. For a quick example.jguru.jguru. stock trading.997 Author: Avi Kak (http://www.a way to invoke methods on remote machines. 2000 Modified: 2000-05-18 07:50:02. RMI (Remote Method Invocation) is just that . But If I give the host name with the port as //host:portnum/somename It works.jsp?EID=26410) .get some information through EJB from one or more databases.createRegistry( 1099 ) in the HelloServer. Servlets (or JSP) are mainly used for any web-related activity such as online banking. Comments and alternative answers RMI Author: Chittaranjan Muthumalai (http://www. Using [(the last link is a tutorial by JGuru!)].html and http://developer.jsp?EID=49517 By using the all the while appearing as if the action was being performed on the local machine.

java ////// import java. But it does illustrate how to set up the activation framework for an activatable server object. Since I used a Solaris machine as a server and an NT machine as a client. public class HelloImpl extends Activatable implements Hello { public HelloImpl( ActivationID id. execute the bat file runclient. This program does basically the same thing as what is achieved by an RMI implementation of a typical "HelloServer" program. import java. for command line invocations I have a shell file on the server side and a bat file on the client side.*. Although these files are trivial in this example and are not really ////// import java. } ////// server file: HelloImpl.activation. } . The main difference here is that we no longer have a continuously running "Hello" server. For a detailed discussion of the classes and methods used in the code shown below. • Step 4: On the client side. execute the shell file activate.*.The minimal "Hello" programs have played an important role in helping people get started with the various programming languages and 0 ). ////// server and client file: Hello.rmi.*.rmi. the reader is referred to the RMI Specification document and to the remote object activation tutorials. Here is a "Hello" program for Remote Object Activation in Java. (Note that this simple example here does not illustrate how Java's remote object activation deals with data persistence. public interface Hello extends Remote { public String sayHello() throws RemoteException. the HelloImpl server object is activated only when it is needed by a client. • Step 3: On the server side. MarshalledObject data ) throws RemoteException { super( id. Instead. I have included them so that the reader can compare the simple invocations here with those found elsewhere in the remote object activation tutorials. run rmic on the HelloImpl class and copy the stub over to the client side.) Getting this code to run consists of executing the following steps: • Step 1: Compile all class files • Step 2: On the server side.bat.rmi.

Hello helloserver = (Hello) Activatable. import java.logCalls=true & rmiregistry & sleep 1 java ActivationSetup ////// client file: HelloClient. public class ActivationSetup { public static void main( String[] args ) throws Exception { ActivationGroupID agi = ActivationGroup.rmi. } } ////// server file: activate.rebind( "rmi://localhost/HelloServer".activation.rmi. helloserver ).registerGroup( new ActivationGroupDesc( null. } } ////// server file: ActivationSetup.*.bat /////// java HelloClient . null ) ).sh ////// rmid -C-Djava.getSystem(). public String sayHello() { return "Hello from Avi Kak".register( desc ).out.println( server.*. "HelloImpl".lookup( "rmi://RVL4. null ) ////// import java. public class HelloClient { public static void main( String[] args ) throws Exception { Hello server = ( Hello ) Naming. System. Naming. null. System. } } /////// client file: runclient.ecn.exit(0).sayHello() ) ////// import java.rmi.rmi.*.edu/HelloServer" ). ActivationDesc desc = new ActivationDesc( agi.

even though the invocations from the two clients are executed in separate 2000 Modified: 2000-05-20 03:11:41.jguru.setSoTimeout(240000).com/faq/ then the remote method must be synchronized in the interface. " What this means is that if you are maintaining state in the object between method calls or need syncronization. some will execute in different > threads. What should you do such that an RMI server program can accept multiple clients and actually parallelize their execution? Location: Created: May 17.} It also means that that this method will be executed with the lock acquired for the implementation object (not the stub or skeleton). the RMI runtime makes no guarantees with > respect to mapping remote object invocations to threads.How do I set a timeout for an RMI client such that it doesn't wait indefinitely in establishing a connection to an RMI server ? Location: http://www.jsp?EID=39645 Well first theres nothing you can do explicitly for this. or it should use synchronizing in its implementation with synchronize(object){code.292 Author: Sarit Bose (http://www. Multiple client calls to the same object are NOT queued up but concurrent method invocations on an RMI object are automatically executed in separate threads as necessary. -Alex] . Calls originating from different client virtual machines will > execute in different threads. where the socket is created by the factory (default/custom) you are using. According to the rmi specs > "A method dispatched by the RMI runtime to a > remote object implementation (a server) may or may not execute in a > separate thread.jguru. In this case.jsp?EID=55767 Created: May 24.jsp?EID=26174 You can use: 2000 Modified: 2000-05-26 16:26:38.jguru. This IS the way it works. Some calls originating from the same client virtual > machine will execute in the same thread.jsp?EID=44426) Question originally posed by Aleksander Grzebyta (http://www. Serial invocations from the same client are processed in the same thread as an optimization. Other than this last case of different > client virtual machines.jguru.772 Author: Sameer Tyagi (http://www.. the remote object must be thread-safe. the execution of the method will indeed be mutually exclusive because of the lock on the implementation object.jsp?EID=4381) Question originally posed by Massimiliano Bigatti (http://www. [In other words.

The safest thing is to just synchronize on sensitive code blocks. 2000 "Serial invocations from the same client are processed in the same thread as an optimization. • a client making 3 calls to the server every 5 secs • a client making 3 calls to the server every 1 min. Since remote method invocation on the same remote object may execute concurrently. " Is this true for only Suns VM or does it hold good for all VMs? for According to Section 3. a remote object implementation needs to make sure its implementation is thread-safe. it can not be thread-safe.jsp?EID=60541). Author: Rahul Matta (http://www. Author: jerry chin (http://www. and in each thread it can call remote methods. Author: Alex Chaffee (http://www. but at different intervals aof time. then the result returned to each thread is not determined too... Sun VM or not. In the above 2 cases. 2000 I think that if RMI calls from the same JVM are packed into one thread.jsp?EID=98195). Jul 7.2 on RMI specs (latest) page: http://java.even different client requests could be on same thread . In such a condition. Because client may have multiple threads in one JVM. 2000 This behavior is unspecified so it may change at any time.Comments and alternative answers I think that if RMI calls from the same JVM are packed.jsp?EID=2457). Read the spec ( the client makes method invocations on the server serially. Sep 24..jguru.jsp?EID=3).. "Serial invocations from the same client are .jguru. making your object Do *not* try to use ThreadLocal or anything else like that. If these calls change some status of server. the call sequence from different thread is not determined when they are put to one thread..sun. Author: Ashwin Desai (http://www.jguru.html "A method dispatched by the RMI runtime to a remote object implementation may or may not execute in a separate thread. Does the RMI runtime still use the same thread for both cases? This behavior is unspecified so it may change at Jul 9. the part quoted in the answer).g. Jun 7. 2000 According to Section 3.2/docs/guide/rmi/spec/rmiTOC." What I understand from this is .com/guru/viewbio. The RMI runtime makes no guarantees with respect to mapping remote object invocations to threads.2 on RMI specs (latest) pag.

html "A method dispatched by the RMI runtime to a remote object implementation (a server) may or may not execute in a separate thread. Although they would be necessary for more general programs involving dynamic loading of classes.. In fact this is more precise as it talks about different VM clients and same VM clients. correct me if I am wrong. the RMI runtime makes no guarantees with respect to mapping remote object invocations to threads.doc. How can multiple VM's be spawned from within the same activation setup program? Location: http://www. the essence of Sameer's example code can be illustrated without their Author: Avi Kak (http://www. -Rahul P. note that you still need a policy file for the VM's you'd be launching in the activation setup program on the server. Here is a minimalist version of that program.jsp?EID=60096 Created: Jun 7. Other than this last case of different client virtual machines. . serializing all the requests in effect . But. " This is what I like :) Since. Also.1/docs/guide/rmi/spec/rmiTOC. However. the RMISecurityManager is not set either in the server programs or in the client programs.jguru.S. The minimalist version shown below is instructive in the sense that it does not invoke security managers anywhere explicitly. along the same lines as the minimalist "Hello" program for remote object activation. Calls originating from different client virtual machines will execute in different threads. That 2000 Modified: 2001-03-21 22:07:19.jguru. If possible send a cc of reply to me at rahul@matta. The security policy for the activated VM is needed only for the reason that the sayHello() method tries to find the name of the local host. according to the old specs on: http://java.jsp?EID=26410) Sameer Tyagi has a wonderful example showing how multiple VM's can be spawned within the same activation setup program.. some will execute in different threads. there is no specifying of the security policy system property for launching either the activation daemon rmid on the server side or the program HelloClient on the client side.sun. it solves my purpose of multi-threads for different clients. Some calls originating from the same client virtual machine will execute in the same thread. Can some one verify or confirm what exactly happens in the latest RMI for clients on different VMs???? Thanks.

*.getHostName(). import ////// import java. import java.getLocalHost(). MarshalledObject data) throws RemoteException { super( id.rmi. } ////// server file: HelloServer. . try{ hostname= InetAddress.Remote { String sayHello() throws java. counter++.activation. import java.To make this code work on your machine.rmi. import java. you'd need to make appropriate substitutions for the name rvl4. public class RegisterHelloServer { public static void main(String[] args) throws Exception { Properties props = new Properties().* ////// import java. 0 ). } public String sayHello() { String hostname=null. public HelloServer(ActivationID id. public class HelloServer extends Activatable implements Hello { private static int counter=0.d of my RMI directory on the server }catch (java.purdue.rmi.InetAddress.UnknownHostException who){} return "Hello World from " + of my server machine and the name RMI13.activation.rmi. } } ////// server file: RegisterHelloServer.* ////// server and client file: Hello.*.java ////// public interface Hello extends java.

registerGroup( new ActivationGroupDesc( props.out. ActivationDesc desc = new ActivationDesc( agi.println(obj. ActivationDesc desc_2 = new ActivationDesc( stub).rmi.purdue. "/home/rvl4/a/kak/" ). Naming. "HelloServer".sayHello()).lookup( "rmi://RVL4. } ////// server shellscript: activate.registerGroup( new ActivationGroupDesc( props. null ) ). System.d/policy" ). Hello stub = (Hello)Activatable.AllPermission. props. Hello stub_2 = (Hello)Activatable.*.ecn.register(desc_2). public class HelloClient { public static void main(String args[]) { try { Hello obj = ( Hello ) Naming.exit(0).sh ////// #! /bin/sh rmiregistry& rmid& sleep 1 java RegisterHelloServer ////// client file: HelloClient.getSystem(). "HelloServer".rebind("HelloServer".rebind("HelloServer2". null. // Spawn the second VM !! . } } ////// server file: policy ////// grant codebase "file:/home/rvl4/a/kak/RMI13. null. null ) ).register(desc). ////// import java. true ).policy". true ).d/" { permission java. ActivationGroupID agi = null. null. // create another one for a new VM: ActivationGroupID agi_2 = ActivationGroup.put( "java.getSystem(). stub_2). Naming.

..println(obj_2. Assuming that an activatable object needs access to a system resource.. props.out. null ) ). For illustration.lookup( "rmi://RVL4. Hello obj_2 = ( Hello ) Naming. } catch (Exception e) { e. Jun ////// java HelloClient Comments and alternative answers vm of rmid and activable object! Author: Kalpeshkumar Soni (http://www. is it always necessary to do so? Location: http://www. . The alternative consists of directly informing the activation daemon about the security policy to use for the activatable" ). It is common for the setup programs for remote object activation to specify a security policy file explicitly to be used for the VM's that are activated by the rmid daemon when a request to that effect is received from a client. The first statement creates an empty properties list with no default values.d/policy" ) ActivationGroupID agi = new ActivationGroupDesc( props. System. "/home/rvl4/a/kak/RMI13. } } } ////// client bat file: runclient. 2000 Modified: 2000-06-07 11:40:46.sayHello()).put( "java.jsp?EID=26410) No.jsp?EID=916018).jguru. Before showing how that is done. The second statement adds to this list and tells the system about the location of the security policy file.getSystem() 2002 how can I ensure that the activated object uses a jvm which is different from that of rmid? what's with createGroup() and registerGroup() Practically all examples of the setup programs for remote object activation start out by specifying a security policy file to be used by the activation daemon when launching a new VM for an activatable object.jsp?EID=61540 Created: Jun 7.632 Author: Avi Kak (http://www.jguru. .printStackTrace(). all the on-line remote object activation tutorials have their activation setup programs begin with statements like Properties props = new Properties(). let's look at how a typical activation setup program begins. The third statement then creates an identifier for an activation".ecn.

For a server object to be activatable. one has no choice but to take recourse to the first approach. of type ActivationGroupDesc. But now the activation daemon must be invoked with the "-C" option as in the following example: rmid -C-Djava. it has to have associated with it the following: 1. this raises the question of whether it is always necessary to specify a security policy file for the spawned VM's in the activation setup Created: Jun using the augmented Properties object props for the first argument to the ActivationGroupDesc constructor. null ) ).policy=/home/rvl4/a/kak/RMI13. could one directly inform the activation daemon rmid about a security policy to use and then have the daemon apply that security to all the activatable objects? Yes.jguru.jsp?EID=26410) Although it could mean different things to different people. 2000 Modified: 2000-06-07 11:41:54. in my mind a reasonable definition of object deactivation is that 1) it should shut down the VM that was spawned by the activation system to activate the object. Assuming that the activatable objects need access to system resources.registerGroup( new ActivationGroupDesc( null. it is possible to inform the activation daemon directly about the security policy to use for all the activatable objects.291 Author: Avi Kak (http://www. where the first argument to the ActivationGroupDesc constructor is now set to null. While simplifying the code a little bit. To use this alternative approach. An activation group descriptor. and 2) a client's request for service from the object should automatically spawn the VM again if it was shut down by a previous deactivation request.d/policy The security policy thus specified is passed on to each VM spawned by the activation daemon. That it is possible to mean different things by object deactivation is a result of the complexity of the "machinery" that has to be brought into existence in order for an object to become activatable. this approach implies that all the spawned VM's will be governed by the same security policy. Instead. and replace the third statement with ActivationGroupID agi = ActivationGroup. Recall that the activation daemon will be able to launch a new VM for each separate activation group identifier in a setup program. in your activation setup program you could delete entirely the first two statements shown above.getSystem(). What exactly is meant by the deactivation of a server object that was activated previously? Location: http://www. that contains the information necessary to create or recreate an activation group to which the object belongs.jguru. If an application demands that the different VM's spawned by the activation daemon be governed by different security The RMI system will be able to spawn a new VM for each .

of type ActivationGroup. usually brought into existence as a side-effect of activating the first object corresponding to the registered activation group descriptor. you would deactivate all the activated objects in the activation group corresponding to that VM. Adrian Colley says: "An easier way is to first unexport the object in question. for each activation group descriptor that is registered with the activation system. But first let me cite two of the more important postings regarding object deactivation I found in the on-line community literature. the location of the class. This information consists of the group identifier of the activation group in which the object resides. My goal here is to clarify the confusion and to present sample code that works for deactivating an object that was activated previously. thus guaranteeing that you will get no future remote calls. and initialization data in the form of a marshalled object." .. A Remote stub returned by registering the object activation descriptor with the activation system.543 Author: Avi Kak (http://www. there are no on-line tutorials dealing with this issue.. 2. in at least the simpler cases. Of course. of type ActivationGroupID. by object deactivation one could conceivably mean different things depending on how exactly the server side is disabled with regard to incoming client requests..jsp?EID=76184 Created: Jun 15. there seems to be no reason to call unexportObject . 6. when you shut down a VM.jsp?EID=26410) The community literature is somewhat confusing about how a client should go about deactivating a remote server object and. activation group. Then deactivate. In a posting dealing with object deactivation in the Sun's RMI-USERS mailing list archive. ranging presumably from the shutdown of the entire activation system. So. A group identifier. An activation group. 4. to the deactivation of the entire group in which the object resides. consist of the security policy to be used for the spawned VM's.. that contains the information needed for activating an object. How does a client deactivate a server object immediately after a remote call to the object has been executed successfully? Location: http://www." But then in a subsequent posting dealing with object of type the object's class name. to the extent I know. An entry in the RMI registry for the above stub. This registration allows the object to be activated on demand.jguru. William Grosso says " .jguru. to the deactivation of just one object. in a background thread if necessary. The information contained in an activation group descriptor is similar to what is needed for launching a new VM by the application launcher tool java and will. The activation group is responsible for creating new instances of activatable objects in the group. 3. An activation descriptor.. 2000 Modified: 2000-06-15 13:16:10. 5. for each registered activation group descriptor..

purdue. and for ii) finding out the name of the local host in the sayHello() method. 3. I'll then present sample code that implements this definition.ecn. This can easily be checked by listing the processes on the server side. it adds nothing to the code. I'll first mention what I mean by object deactivation. For those starting out with object deactivation. The object whose deactivation is desired must first be unexported by invoking Activatable. you'd obviously have to change the strings "rvl4. you will not be shutting down the VM that was spawned by the activation system to activate the object.inactive().inactive() methods must be carried out in a separate thread on the server side. Since the invocation of Activatable. The policy file on the server side is needed for i) starting a deactivation thread in the deactivate() method. the following observations about the code that follows might prove useful: 1. William Grosso presents a deactivating thread in which he has intentionally commented out the unexportObject() statement since. What follows is a "minimalist" program to illustrate object deactivation.unexportObject() and the Activatable. respectively. When the runclient. 2. If. That the latter invocation shuts down the activated VM on the server side can be seen by listing the processes on the server side. If.UnmarshalException.inactive(). and ii) a client's request for service from the object should automatically spawn the VM again if it was shut down by a previous deactivation request.In the same posting. If these methods are invoked in the main thread. according to him. 2.unexportObject() followed by the invocation of Activatable.rmi.d/" to the name of your server machine and the name of your server-side directory.unexportObject() and then deactivated by invoking" and "/home/rvl4/a/kak/RMI16. To run this code on your system. The stub file generated on the server side by running the rmic compiler on the HelloServer class would need to be copied over to the client side.bat program on the client side is executed again. you only invoke Activatable. the HelloServer object on the server side is automatically activated again by spawning a new VM.inactive() effectively shuts down the VM that . The invocation of the Activatable. Evidently. 5. The client first invokes the sayHello() method on the remote object and then invokes the deactivate() method on the same object. as suggested by William Grosso. Since I used a Solaris machine as a server and an NT machine as a client. for command line invocations I have a shell file on the server side and a bat file on the client side. as presented in a recent jGuru posting. 4. object deactivation means that: i) it should shut down the VM that was spawned by the activation system to activate the object. then the following must hold true for an implementation of object deactivation: 1. William Grosso's observation runs counter to Adrian Colley's recommendation. In the rest of this note. the client side will throw the java.

getHostName().getLocalHost().start().net. try{ hostname= InetAddress.UnknownHostException who){} return "Hello World from " + hostname.rmi. import java. was spawned for activating the } ////// server file: ////// public interface Hello extends ////// import java.rmi.*.Remote { String sayHello() throws java.*.rmi.RemoteException. if you insert any Java code immediately after the lines marked (A) or (B). void deactivate() throws java.InetAddress. } public String sayHello() { String hostname=null. // (A) } } . how many of those inserted statements get executed depends on how the operating system handles the shutdown. Here is the code: ////// server and client file: Hello.rmi. MarshalledObject data) throws RemoteException { super( id. } public void deactivate() throws RemoteException { deactivator = new Deactivator( this. import java. }catch (java.rmi. deactivator. 0 ). public HelloServer(ActivationID id. public class HelloServer extends Activatable implements Hello { Deactivator deactivator = null. getID() ).activation. I found it interesting to insert print statements at these locations to see how many of them would get executed before the activated VM was actually shut down.

security.rmi. Deactivator( Remote rem. public class RegisterHelloServer { public static void main(String[] args) throws Exception { ActivationGroupID agi = ActivationGroup. Naming. } public void run() { try { Activatable.printStackTrace(). stub).class Deactivator extends Thread { ActivationID aid.getSystem().rmi.registerGroup( new ActivationGroupDesc( ////// import java. true ). server = rem.inactive( aid ). import java. null.rebind("HelloServer".register(desc). // (B) } catch( Exception e ) { e. } } } ////// server file: RegisterHelloServer.AllPermission. } } ////// server file: policy /////// grant codebase "file:/home/rvl4/a/kak/RMI16. .exit(0). null ). Hello stub = (Hello)Activatable. Remote server. null ) ).activation. ActivationID id ) { aid = id.unexportObject( server.*. }. Activatable.d/" { permission java. "HelloServer". System. ActivationDesc desc = new ActivationDesc( agi.*.

jsp?EID=77164 Created: Jun 17.lookup( "rmi://RVL4.491 Author: Suja Rao (http://www.deactivate().jguru.jguru. Comments and alternative answers .d/policy & sleep 1 java RegisterHelloServer ////// client file: HelloClient.////// server shell file: HTTP tunneling is a method that RMI uses to make calls through a local firewall. RMI? Location: ////// import java. ////// #! /bin/sh rmiregistry & rmid -C-Djava.println(obj.out.loader. try { obj = ( Hello ) Naming. } catch( Exception e ) { e. which disallow regular outbound TCP connections but permit HTTP through a proxy server. public class HelloClient { public static void main(String args[]) { Hello obj = null. To get across firewalls.jguru. RMI makes use of HTTP tunneling by encapsulating the RMI calls within an HTTP POST request. } } } ////// client bat file: runclient. System.rmi. The reply too is sent back as HTTP- encapsulated Question originally posed by Nagaraj Sivashanmugam (http://www.logLevel=verbose HelloClient What is HTTP tunneling viz.bat ////// java 2000 Modified: 2000-06-21 13:59:18.sayHello()).edu/HelloServer" ).*.printStackTrace().policy=/home/rvl4/a/kak/RMI16.

By object persistence here is meant saving to the disk the latest state of the server object.jsp?EID=26410) I believe that the educational essence of the otherwise very instructive Sun tutorial on how to use a MarshalledObject for data persistence can be demonstrated with a program that is somewhat easier to comprehend by a beginner than the one shown in the tutorial. Transferred money from Savings 6.336 Author: Avi Kak (http://www. it is not necessary to install the RMISecurityManager at the beginning of the setup program. Deposited money 4. the following remarks about the enclosed code should prove helpful: 1. has a Vector data member transactions in which is stored a set of strings each time a client invokes the server object's method callServer( Vector v ). When a client invokes the callServer( Vector v ) method of the server object. of type MyPersistentClass. 2002 How somebody could implement that ? Assuming he already has an HTTP server (that is probably needed). My own position is that since remote object activation is fairly convoluted as it is. As my code illustrates and contrary to what is recommended in the tutorial. 2. and 2) giving a null value to the "location" parameter of the ActivationDesc constructor. How is this done ? Author: Klearhos Klearhou ( since with a null value the location defaults to the current directory.jsp?EID=80957 Created: Jun 23. I have included below a "minimalist" version of the tutorial. it is also not necessary for a client to invoke the RMISecurityManager if no dynamic loading of classes is involved. If you are just beginning with the ideas of data persistence in remote object activation.jsp?EID=540399).com/guru/viewbio. 2000 Modified: 2000-06-23 07:16:10.jguru. Jul the setup program can be further simplified by 1) using the command line invocation of the activation daemon rmid to specify the security policy to be used for the VM's launched by the daemon. to the extent possible one should make an attempt to illustrate each of its central ideas in isolation from the other ideas. Check cleared 7. Point-of-sale charge at grocery store . If the goal is to construct an example that focuses solely on showing how data persistence can be carried out. Withdrew money 5. And. the Vector parameter v is set to the following list of strings: 3. which in this case boils down to saving the latest set of strings stored in the data member transactions. I would like to see a "minimalist" version of the official Sun Java tutorial on how to use a MarshalledObject for data persistence in remote object activation. Location: http://www. The activatable server object.

d/" to the name of your server machine and the name of your server-side directory.rmi. 13. Therefore. 10. 8. public interface RemoteInterface extends Remote { public Vector callServer( Vector v ) throws RemoteException. you'd obviously have to change the strings "rvl4. you should see the client print out N repetitions of the above five strings. } ////// server file: MyPersistentClass.ecn.ser file in which the latest state of the object is stored. The constructor will also be invoked if you shut down the entire activation system by killing all its processes and starting over (or if the server computer crashes and you start over). 14. 9. Here is the code: ////// server and client file: RemoteInterface.ser file if such a file exists at all (see statement marked (A) in the code). Therefore. The server object returns to the client the latest contents of the transactions vector and the client prints out all of the strings thus received from the server. it will restore the server object from the file persistentObjectStore. The file in which the state of the server object is stored is specified in the statement marked (C) in the Setup.ser. Since I used a Solaris machine as a server and an NT machine as a client. import java. each time a client invokes the server object method callServer().io. . long as you do not delete the file persistentObjectStore. for command line invocations I have a shell file on the server side and a bat file on the client program.rmi.*. each client call adds the above five strings to those already in transactions.util. these five strings are added to the contents of the data member vector transactions. A call from a client will invoke MyPersistentClass's constructor only if it was not already invoked by a previous call from a client. You can verify data persistence by entirely shutting down the activation system on the server side (by killing all its processes) and starting all over. If the next client call is the Nth call. import java. after N client calls to the server.Vector.*. To run this code on your system. 12. If the MyPersistentClass's constructor is invoked. The stub file generated on the server side by running the rmic compiler on the MyPersistentClass class would need to be copied over to the client ////// import ////// import java. On the server side. As shown in the statement marked (B).*.edu" and "/home/rvl4/a/kak/RMI18. you will see N repetitions of the above five strings -. the server object with its changed state is saved to the disk file persistentObjectStore. respectively.purdue.

0 ). this.activation. for ( int i = } public Vector getTransactions() { return transactions. FileInputStream fis = new FileInputStream( f ).size().util. MarshalledObject data ) throws RemoteException. i < limit.restoreState().*.elementAt( i ) ). else { transactions = new Vector( 1. transactions. ClassNotFoundException. private File holder. ois. ObjectOutputStream oos = null. public class MyPersistentClass extends Activatable implements RemoteInterface { private Vector transactions.Vector. } private void restoreState() throws IOException.IOException { super( id. i++ ) transactions.get(). public MyPersistentClass( ActivationID id.readObject(). ObjectInputStream ois = new ObjectInputStream( fis ).import java. } } public Vector callServer( Vector v ) throws RemoteException { int limit = v. transactions = ( Vector ) ois. 1 ). java. if ( holder. import java. // (B) return transactions. holder = (File) data. .addElement( "Initializing transaction vector" ). } private void saveState() { FileOutputStream fos = null.rmi.close().exists() ) // (A) this.saveState(). ClassNotFoundException { File f = holder.addElement( v.

try {
File f = holder;
fos = new FileOutputStream( f );
oos = new ObjectOutputStream( fos );
oos.writeObject( getTransactions() );
} catch( Exception e ) {
throw new RuntimeException( "Error saving the state of the
object" );

////// server file: //////

import java.rmi.*;
import java.rmi.activation.*;
import java.util.Properties;

public class Setup {

public static void main( String[] args ) throws Exception
ActivationGroupID agi = ActivationGroup.getSystem().registerGroup(
new ActivationGroupDesc( null,
null ) );
MarshalledObject data = new MarshalledObject(
new File( "persistentObjectStore.ser" ) ); // (C)
ActivationDesc desc = new ActivationDesc( agi, "MyPersistentClass",
null, data );
RemoteInterface yari = (RemoteInterface) Activatable.register( desc
Naming.rebind( "MyPersistentClass", yari );
System.exit( 0 );

////// server file: policy //////

grant codebase "file:/home/rvl4/a/kak/RMI18.d/" {

////// server shellscript: //////

#! /bin/sh
rmiregistry &
rmid &
sleep 1
java Setup

////// client file: //////

import java.rmi.*;
import java.util.Vector;

public class Client {

public static void main( String[] args )
try {
RemoteInterface ri = (RemoteInterface) Naming.lookup(
"rmi://" );

Vector result = new Vector( 1, 5 );
result.addElement( "Deposited money" );
result.addElement( "Withdrew money" );
result.addElement( "Transferred money from Savings" );
result.addElement( "Check cleared" );
result.addElement( "Point-of-sale charge at grocery store" );

result = (Vector) ri.callServer( result );
System.out.println( "Called the remote method" );
System.out.println( "Result: " );
for ( int i = 0; i < result.size(); i++ )
System.out.println( result.elementAt( i ) );
} catch( Exception e ) { e.printStackTrace(); }

////// client bat file: runclient.bat //////

java Client

Using ServerSocket.accept() method we can control the number of active
socket clients, i.e. set a maximum limit on concurrent active client service
threads, allow all currently active clients to terminate before gracefully
stopping the server etc. Is there a way to exercise similar degree of control

in an RMI server?
Created: Jun 24, 2000 Modified: 2000-06-24 13:43:04.795
Author: Shaun Childers (
Question originally posed by Mahesh Hegde

I don't think it's possible with the RMI classes provided with the JDK (if it is,
someone will correct me), but you could design your system to control this. (I'm sure
we could all come up with multiple ways for solving this design issue.) The first
solution off the top of my head would be the following:

* Create an RMI server manager object whose job it is to keep up with how many
concurrent connections are executing on the object. This could be done in such a
way: (Assume we have the RMIServerManager running and it's a Singleton (one
instance) class.)

public class RmiObjectImpl extends UnicastRemoteObject implements
RmiObject {
public void someMethod(Object[] o) throws RemoteException {
//before we execute this method check to see if it's OK
if (serverManager.proceed()) {
//let the server manager we have another client
//now perform the method functionality
//now be sure to let the server manager know this client is
done and leaving
throw new TooManyUsersException("Please wait.");


I know this is bare bones, but you get the idea, just build it into the design of your

Why do I always get an "Invalid port Range: 21" exception when running
RMI with a file:// codebase and the security manager properly configured
on WIN32?
Created: Jul 1, 2000 Modified: 2000-07-06 20:58:07.814
Author: John Zukowski ( Question
originally posed by Bernhard Anzeletti

The default configuration of the Java policy file does not permit usage of ports under
1024. These are considered privileged ports under UNIX. While you are using a

Can an EJB handle (RMI remote reference) be stored in an HttpSession? Location: http://www. so if the handle is not serializable I will have troubles when the HttpSession is restored.jsp?EID=17915 [Note: My HttpSessions are persistent (disk swap).0 Observations: I'm a little surprised about the test since I keep in mind that handles could only be used for locating local EJB's not remote ones (wrong?).com/docs51/classdocs/API_ejb/EJB_design.243 Author: David Garcia (http://www. you may could keep the HttpSession in memory. ] Test result: I have used the handle for locating local and remote EJB.html#1022000 How do I decide between Enterprise Java Beans (EJB). Comments and alternative answers You can refer to the url below for more info and a.jguru.jsp?EID=97963 Created: Jul Author: Kim-Yuan Kong (http://www. 2000 You can refer to the url below for more info and a clear picture on this topic although i think you know the answers. Aug 21. I have no problem about storing the handle inside the HttpSession and swapping the HttpSession.jguru. Comments and alternative answers This problem can be overcome by using file:/codebase.jsp?EID=36479) .jguru. Test conditions: BEA Weblogic 4.. No idea why though.weblogic.. Author: kishore_k_v k (http://www. 2000 Modified: 2002-10-09 12:20:24.0 and allow keep HttpSessions in memory).com/faq/ Remote Method Invocations (RMI). and CORBA? Location: http://www. 2000 This problem can be overcome by using file:/codebase (single slash) rather than file://codebase. Sep 11.jguru. However if some problem arise about the swap of the HttpSession. Windows NT 4.jguru.5.jguru.1 (uses EJB 1.jsp?EID=101761 Created: Jul 13.. 2000 Modified: 2000-07-09 Question originally posed by David Garcia (http://www. the Java limitation is for all operating Author: Prasad Thammineni (http://www.jsp?EID=202022).Windows OS which doesn't have that restriction.

jsp?EID=1009379).jguru. 02:41 am Re: Link is not working. Oct 8.972 Author: Siva Visveswaran (http://www. You have to check with your vendor.uu. Author: Muhammad Ahmed Khan (http://www. but it can still be found if any.jguru. • definitions of serializable objects that are returned to client due to network considerations (instead of object references). Depending on the vendor ( [Can someone please provide examples.jguru. Deciding whether to use RMI. Jan 19.jguru. 2002. Accessed on June 05.Question originally posed by Srikanth Rao (http://www. CORBA or Enterprise JavaBeans [Alex: the article isn't available at all.jsp?EID=46210) Question originally posed by keith hawkins ( 2002 the link to the article is dead Can you point to another source? Link is not Which.jsp?EID=83055 The answer is really not that generic as one may like to believe! Basically what a client needs to invoke the services of an EJB layer are: • locate the home interface (using a JNDI SPI) & invoke methods of the bean instances (over IIOP). of the automatically generated stub & skeleton class files does one need to include in a JAR file to be used when creating stand-alone clients? (I would like to create a client-side jar file which contains only the class files actually needed by the client. Author: Peter Alzheimer (http://www. Jun 4.jsp?EID=903210).jguru.jsp?EID=105016 Created: Jul 18. 2000 Modified: 2000-08-11 IONA builds JNDI over CORBA) the actual files will vary. for a specific EJB server if need be?] See also: .jsp?EID=80613 The following article desribes 2002 The link is dead for this question.) Location: http://www. 2002 Big thanks to Peter Alzheimer] Comments and alternative answers The article is not there Author: Roger White (http://www. EJB and compares

. kind of redundant. 2000 Dear friend For RMI clients (standalone) all you require is to copy your stub (generated using rmic) and the remote interface (wherein you define the remotely invokable methods) to your client Question originally posed by Fridtjof Ahlswede (http://www. I've not yet seen the new book.jguru. colleagues).com/guru/viewbio.jguru. This looks like: .jguru. How do I grant a program. library. Author: sharad chaudhary (http://www.jsp?EID=25708) Question originally posed by rajesh kkkkkkkkk (http://www. I did use the 1st edition code to base some of my Author: Dieter Wimberger (http://www... 2000 Modified: 2000-07-31 23:05:38. Sharad How can I use Observer/Observable via RMI? Location: http://www. or jar it along with the client implementation of your program. Jul 24. FYI. 1st Edition I am not sure if its possible to post the code. the permissions to read and write all of the System properties? Location: http://www.jguru. 1)stub 2)remote Interface 3)client implementation Hope this solves your so I'n not sure if it still contains the observer/observable code. George Reese. 2000 Modified: 2000-07-30 21:14:54. Jun You have to grant the permission via the policy file.jsp?EID=114192 Created: Jul 29. so I suggest you organize yourself this book or its sample sourcecode (i. • What classes does a client application need to access EJB? (hmm. after setting RMISecurityManager for the system. 2001 The book in question has a newer edition.153 ff. oops :-) Comments and alternative answers Dear friend For RMI clients (standalone) all you . Thus you require 3 things only.jsp?EID=114197 Created: Jul 29.094 Author: Dieter Wimberger (http://www.jguru.jsp?EID=18017). O'Reilly (ISBN 1- 56592-270-0) p.jsp?EID=30454 A solution on how to create a RemoteObserver can be found in Database Programming with JDBC and Java. Comments and alternative answers Book is now 2nd edition Author: David Ben-Yaacov (http://www.

String def) You can also override following methods: checkPropertiesAccess checkPropertyAccess Thus enrolling your own "access policy".util. When the client request comes in. " Design it into your from the Java 2 JDK documentation you are using. Is it possible to limit RMI server access to a list of hostnames/ips or to localhost only? Location: http://www. look up the incoming IP address and check your list of accepted IP's. 2000 Modified: 2000-07-31 20:18:49.jsp?EID=114492 Created: Jul 30.jsp?EID=108142 Sure.System public static Properties getProperties() public static void setProperties(Properties props) or: java.992 Author: Shaun Childers (http://www.jguru.write" for using java.System public static String getProperty(String key) public static String getProperty(String key. Be sure to check the /guide/security/permissions.PropertyPermission "{key}".com/faq/view. "read" for using How can I get to know the number of clients that are connected to a RMI server at any given time? Location: http://www. subtract one from . 2000 Modified: 2000-08-31 21:15:42.jsp?EID=30243) Question originally posed by karuppanan rameshkumar (http://www.jsp?EID=115219 Created: Jul 31.373 Author: Shaun Childers ( "*".jsp?EID=30243) Question originally posed by Deacon Marcus ( When the client request comes in. When a client leaves. A similar topic using discussing limiting the number of connections to an RMI server can be found here: just keep a tally of the number of clients you have in your just design it into your system.

jsp?EID=7 Synchronization in RMI is based entirely on the synchronization facilities of the Java language. So the result is that if you synchronized on a remote 2000 Modified: 2000-08-02 16:15:54. the synchronization takes place in the client JVM only.jsp?EID=94950) Question originally posed by dieter Created: Aug 1. However.jguru. or handled in some other fashion.jguru.jguru. 2000 Modified: 2000-08-02 16:06:14. The general strategy is to write your own subclass of java. While RMI provides a distributed garbage collection facility built on top of the local JVM garbage collection. the involved objects are serialized and transmitted over an socket-stream. compressed. if you declare a remote method as synchronized in the remote object implementation. These factories will be used by the remote object for RMI communication and thus using the input/output behaviour that was specified in the socket subclasses.136 Author: Thomas Auinger (http://www. Conversely. Doing this with RMI is simple enough.this number. In an rmi-call.jguru. the normal way might be adequate. modify the constructor of your remote object (the one that extends UnicastRemoteObject) to set a client and a server socket factory.jsp?EID=79317 What happens when I synchronize my remote methods? What does it synchronize on? Is there distributed synchronization? Location: http://www.Socket and java. thereby preventing access by proxy server users." Subclassing a Socket allows you to return your wanted stream when calling the Socket's getInputStream() and getOutputStream() methods: . Next. which has the effect of synchronizing all client and server access to the remote object. overriding the default socket factory disables RMI's ability to do HTTP if a modem link is used. there is some sort of 'hook'.net.jguru.jsp?EID=117185 Created: Aug 2. requiring only that you implement your own socket classes and an RMI socket factory that creates your special sockets. as Scott McPherson pointed out: "Many applications may require that data exchanged between client and server be holten (http://www. A similar topic using discussing limiting the number of connections to an RMI server can be found here: a compressed stream might be better. Can an rmi socket connection detect and adapt to different speeds? Location: the synchronization takes place in the server JVM.jguru.jsp?EID=113602) Question originally posed by John Zukowski PREMIUM ( Is there a 'hook' to use different kind of stream? If a fast network link is used. This approach has problems. there is no such similar facility provided for synchronization.jsp?EID=98771 Yes.124 Author: Doug Bell (http://www.

net.sun.jsp?EID=117768 Created: Aug 3. int port) { super(host. } public InputStream getInputStream() { return new XXXXInputStream( super. how to "detect the speed of an rmi socket connection". } public MySocket(String host. Definitely not by provided means.doc.getOutputStream() ). } } The following code shows how to subclass a ServerSocket. . public class MyServerSocket extends java. How can the RMI client do a lookup if it communicates with the outside world via a proxy server? Location: { public MyServerSocket(int port) { super(port).public class MySocket extends java.html.Socket { public MySocket() { super().getInputStream() ). } public OutputStream getOutputStream() { return new XXXXOutputStream( RMI supports both direct socket connections and connections through a proxy via HTTP tunneling. Furthermor. a client can connect to an RMI server outside the firewall. } public Socket accept() { Socket socket = new MySocket().jguru. port).2/docs/guide/rmi/rmisocketfactory.162 Author: Doug Bell (http://www.jsp?EID=113602) Question originally posed by Sarit Bose (http://www.jguru. 2000 Modified: 2000-08-03 08:21:44. return socket. I couldn't think of any way. Assuming the firewall has an HTTP implAccept(socket). The logic necessary to detect and select the transmission protocol is contained within the Socket produced by the default RMISocketFactory. you never know if the current connection is slow or if the net is simply blocked/slow at the } } More (and detailed) Information can be found at Creating a Custom RMI Socket Factory at http://java.

rmi.jsp?EID=113602) Question originally posed by Tim Rohaly PREMIUM (http://www.jsp?EID=121620 Created: Aug 8. There is one place where a remote object is actually replaced by a stub. So for instance. The common bond between the stub and the remote object is the remote interface that they both implement which allows a stub on a client machine to operate as if it was the remote object on the Therefore.e.602 Author: Doug Bell ( Where can I find the API documentation for Activation? Location: http://www. or returned as the result A remote reference is tied only to the remote server containing the referenced remote object.jguru. if a remote object returns itself (i.exceptionTrace=true" and "-Djava.jsp?EID=113602) Question originally posed by Michael Prescott (http://www. remote objects are not replaced by their stubs. How can I get better information at run-time about exceptions in RMI? Location: http://www.jguru.826 Author: Doug Bell ( You can add either of the following properties (assuming that you're using a Sun- based RMI JRE): "-Dsun. then the remote object is replaced by its stub. the connection between C and S2 is completely direct and S1 is no longer involved in the connection. 2000 Modified: 2000-08-03 2000 Modified: 2000-08-26 19:26:44.782 Author: John Mitchell (http://www.jguru.jsp?EID=134150 Created: Aug 24.There are some limitations and configuration issues. then instead of marshalling the remote object and passing it to the caller a stub for the remote object is returned. How and when is a Remote object replaced by its stub? Location: http://www.jguru. a remote method call. The remote object remains on the server and the stub is delivered to the client to act as a proxy for accessing the remote object.jsp?EID=4) .server. 2000 Modified: 2000-08-08 2000 Modified: 2000-08-09 21:03:27. A client (C) calls a method on a server (S1) that returns a remote reference to an object running on a second server (S2).322 Author: John Mitchell (http://www. If the client makes a call to this object. See the RMI spec for details. this) from a remote method. or is the connection between C and S2 completely direct? Location: http://www.jsp?EID=10 In general.jguru. does this still generate network traffic involving S1.logCalls=true".jguru. rmi.jguru.jguru.jguru. If a remote object that has been exported is passed as a parameter to.jsp?EID=120642 Created: Aug Created: Aug 3.

jguru.rmid. idlj. I've read that I need to set a specific rmid policy file but my tries just add in the error in question between the existing lines. native2ascii. serialver. javah.rmid. javadoc.jsp?EID=14) Question originally posed by amit dogra (http://www. Lather.jsp?EID=46548 You can make use of the Windows JDK utility javaw to fire-up the Java interpreter as a separate process and run rmiregistry and your server in the background. and unregbean on the Java 2 SDK Tools and Utilities page.ExecOptionPermission "/lib/mahalo.jsp?EID=59707 Create a wrapper script like this: grant { }.jguru. Rinse. javap. and restart it. Is there a way to run rmiregisty and my RMI servers in the background under Win32? Location: then run rmid -stop.jguru. java.32 Author: RaRa Rasputin (http://www.437 Author: Govind Seshadri (http://www.jsp?EID=14530) Question originally posed by Francesco Marchioni (http://www.You can find the activation API documentation from Sun's J2EE API documentation appletviewer. I get "com.sun. What could be wrong here? Location:". jdb. Created: Aug 30.ExecOptionPermission" when I try to use ActivationGroupID constructor with a policy file as property. rmic. keytool. you can start up rmiregistry in the background as: javaw rmiregistry .jsp?EID=4) You can find the official Sun documentation for all of the tools in the Java 2 SDK including javac. and run rmid as rmid -J-Djava. jarsigner. jar. rmid. rmiregistry. For example.jsp?EID=139088 Created: Aug 2000 Modified: 2000-09-11 20:27:39.rmid then say you get an error. Where can I find the official documentation of the Sun Java SDK tools? Location: http://www. 2000 Modified: 2000-09-02 08:36:19. tnameserv.rmi.rmi.jsp?EID=202975 Created: Sep 11.803 Author: John Mitchell (http://www. like: permission com. 2000 Modified: 2000-08-30 save that as policy.

The overhead here is do note that this will preclude you from seeing any of the diagnostic or error messages that would be printed to the console by default.myprogram not javaw dir or javaw ls If the RMI client & server are located on the same machine.jsp?EID=121306) Question originally posed by Serge Nekoval (http://www. stub and skeleton. Comments and alternative answers And what if client & server are in the same JV.However. 2001 That answer does not work. For example. javaw com.jsp?EID=141561).jsp?EID=141561 Even if you have RMI server and Client on your local machine. Thus.jguru. Author: Serge Nekoval (http://www. Sep . Jun 2000 Modified: 2000-09-14 15:55:02. RMI calls between the client and server running on the same machine will not be treated as a local invocation. This scenario is comparable to running the RMI client and server processes in a distributed mode (with each running on a separate machine). stub and skeleton or will it will be treated as a local invocation? Location: http://www.jguru. Comments and alternative answers Answer is incorrect Author: David Ben-Yaacov (http://www.e.jguru. with each running within a separate JVM instance).jsp?EID=18017).com/guru/ Author: swarraj kulkarni (http://www. what is the overhead of invoking remote method in this situation compared to a local method call? Will the call go through the entire TCP/IP stack. you will have to invoke them as different processes (i. where the communication takes place by going through the entire TCP/IP stack.. not the name of an executable and the performance will be relatively poor compared to socket-based communication.jsp?EID=205093 Created: Sep 13. javaw's parameters are the full class name. to work with them in RMI style.

jsp?EID=207008 Created: Sep Author: Govind Seshadri ( then later it could find itself attempting to use that object from that client.jguru. . A NoSuchObjectException will be thrown when a client that has a reference to a remote object and attempts to use it. 2000 Modified: 2000-09-21 20:44:55. could fool RMI into thinking that the client is not there. but it could be a little more complete. If a NoSuchObjectException occurs attempting to invoke a method on a remote object." Comments and alternative answers more details...jsp?EID=74971) Question originally posed by Thomas Auinger (http://www.activation..017 Author: RamaChandra Murthy (http://www. discovers that the object in question is no longer there on the server the call may be retransmitted and still preserve RMI's 'at most once' call semantics. 15. It would remove the server object. we would have to supply all the n-number of interfaces to rmic or invoke rmic on a composite interface created by extending the remote interfaces.server.jsp?EID=14) Question originally posed by Anoop Kumar A (http://www.jguru.jguru.and the answer has to do with RMI's remote garbage collection: RMI does not guarantee to remove a remote object when it can prove that there are no remote references to it . A tempporary network outage between client and server. Under what circumstances would I get a java. Otherwise.jguru.toStub and by the unexportObject methods of java. The question then is "how can this happen" .rmi. Author: Moises Lejter ( Created: Sep 14.UnicastRemoteObject and 2002 The answer given is accurate. for example.jsp?EID=775519).rmi. 2000 Modified: 2000-09-14 15:46:53.only when it thinks it likely that there aren't any. A NoSuchObjectException is also thrown by the method java. Feb 27.jguru.jsp?EID=94950 RMIC is invoked on the implementation class as this class may be implementing n- number of remote interfaces. 2000 And what if client & server are in the same JVM? Why is rmic invoked on the implementation class and not on the remote interface? Location: http://www.rmi.RemoteObject.jsp?EID=12385 Quoting from the RMI Javadocs: "A NoSuchObjectException is thrown if an attempt is made to invoke a method on an object that no longer exists in the remote virtual machine.NoSuchObjectException? Location:

jsp?EID=210288 Created: Sep 19. 2000 The link in the answer is helpful as long as you use a file containing the IOR.jguru. 2000 Modified: 2000-09-21 20:51:19.htm Comments and alternative answers The link in the answer is helpful as long as you use. With this you can test interoperability between the Java-RMI and C++/CORBA coming with the JDK1.jsp?EID=208904 Created: Sep 18. Dec 12. the client machine search the RMI-USERS archive at: client calls a method on the server and while the server is processing.jsp?EID=217582).com/faq/view.jguru.917 Author: swarraj kulkarni ( http://www.dur.jsp?EID=208893 Created: Sep 18.I want to be able to catch this on the server side) Location: http://www.dreambean. Java-RMI based Server and a Java-RMI based client. but how do I get a context to the name server (tnameserv.html Is there any way to catch the situation where the server side of the RMI program fails to return to the client (i. 2000 Modified: 2000-09-21 20:49:29. CORBA/C++ Client.876 Author: Davanum Srinivas (http://www.jsp?EID=2011) Question originally posed by Al Buk ( For more How can I create and register a custom RMI stub generated dynamically using the new JDK The following article has samples for a CORBA/C++ There is an excellent package from Rickard Öberg which uses dynamic proxy classes to eliminate the need for RMIC itself. 2000 Modified: 2000-09-21 21:00:07.jsp?EID=121306) Question originally posed by Jack Handy ( dynamic proxy classes? Location: can my CORBA client (written in C++) communicate with an RMI server using the RMI/IIOP mechanism? Location: http://www. Author: Robert Wilke ( The package can be downloaded from: http://www.277 Author: Davanum Srinivas (http://www.jguru.jsp?EID=2011) Question originally posed by Stephen Buck (

jsp?EID=214271 Created: Sep 23.996 Author: John Zukowski (http://www.635 Author: swarraj kulkarni (http://www. 2000 Modified: 2000-09-28 can be implemented by using the CallBack pass on the client ID (which has information corresponding to the client machine) as one more parameter to the method.jsp?EID=12385 A replicated RMI object is one that offers transparent failover or load balancing.jguru. You could look at other implementations of RMI like Voyager. What is a replicated RMI Object? Location: http://www. where the server holds the reference of the client object. How I can set the maximum number of requests that can be handled by a multithreaded RMI server(an object which extends UnicastRemoteObject)? Location: The server executes the method and before returning the result.jsp?EID=101243 There is nothing that stops an RMI server from making native method calls.jguru.jsp?EID=214268 Created: Sep 23. If you wish to limit the number of requests that your server will handle then you will have to implement this at the application Created: Oct 17. If the client is alive.jsp?EID=12385 My understanding is that the standard RMI does not permit any way for you to limit this. 2000 Modified: 2000-10-31 or will the stub take care of it? Location: http://www. For every call on the remote server using the object.jguru.jguru.jguru. can test that the client corresponding to passed client ID is alive (by using reverse call to the client for example). Some of these offer advanced features like thread pooling to enhance performance but such features need to be configure externally.jsp?EID=109357) Question originally posed by Anoop Kumar A ( 2000 Modified: 2000-09-28 20:43:15.jguru.jsp?EID=216377 Created: Sep 26.jsp?EID=121306) .jsp?EID=7) Question originally posed by piyush patel (http://www. When implementing methods of remote interface. server can send the result to client.jsp?EID=7) Question originally posed by Anoop Kumar A (http://www. what's the design pattern for handling exceptions in those methods? Should I catch all Throwables and rethrow RemoteException. 2000 Modified: 2000-09-28 Author: John Zukowski ( The client doesn't know it is making a request that will eventually be carried out with native code. Can I call a JNI method using RMI? Location: Author: Benjamin McCartney (http://www.

then it's better to have the exception caught at the server side and a concise version passed to the client.] What happens to the threads that time-out? If there is problem with a resource that the threads require before completing. However. Comments and alternative answers Further in debugging mode. If it gets caught in a long or never ending loop then it may not be able to break out of the code when the time expires. consider the following: When timing a request. the stack trace does not get passed on to the stub since it does not implement the Serializable interface.jsp?EID=233358 We know of no time limit for an RMI Call.jsp?EID=240325) Question originally posed by Nader Said (http://www. once again. the RMI Connection threads still hang.jsp?EID=21992 It is the choice of developer rather than any set design pattern.Question originally posed by Maxim Senin (http://www. The VM must create and destroy every thread. There may come a time when the VM cannot sustain any more threads and the entire VM becomes unusable. the RMI Connection thread cannot time itself. there are serious problems with this approach. the server can just throw the exception and the client can catch it. then. 2000 Modified: 2000-11-03 17:29:35. On the other hand. Is there any limit on the time duration of an RMI call? Does RMI support timeouts? Location: http://www. there may come a time when the VM cannot sustain any more threads and the entire VM becomes unusable.] We have a commercial product that solves this problem. The RMI Connection thread may time the new thread and if the time expires the RMI Connection thread informs the calling client that the request cannot complete.jguru. If the remote server wants to provide summary information about the cause of failure. it is necessary for the RMI Connection thread to start a new application thread. each client application must add proprietary timing code.jguru. Rather than have a standard timing mechanism on the server. In this case. For every request there is a new application thread. [Even with the timing code in the client. Therefore.632 Author: Edward Harned (http://www. [Some developers may put the timing code in the client.jsp?EID=240365 Created: Oct 30. it is better to catch the exception at the server and wrap the stack trace within your own exception class before passing it to the client. if the developer wants a simple design and does not worry about the exact details of the exception cause (stack trace). This seems simple enough. This overhead puts a severe strain on resources.jguru.

2002 Where can I find your "commercial product that solves this problem"? Are there any tips or rules for increasing performance of RMI calls? Location: http://www. Instead of coding ChatRoom remoteChatRoom.jsp?EID=10). Oct 9.jsp?EID=241638 Created: Oct 31.jguru. 2000 Modified: 2000-11-06 21:44:57.jguru.jguru. Commercial Product? Author: Chris Normand (http://www. sometimes we have to pass objects.. 2000 Marshalling objects can be See http://www. RE: Are there any tips or rules for increasing performance of RMI calls . // chat server will take care // about finding local reference to room // by object id and somehow post message in it chatServer. The only object I was unable to avoid passing as a parameter in most applications is String.. Oct 31. // .jguru. Suppose you write a chat application with RMI. Author: Tim Rohaly (http://www.jsp?EID=3419 for a hint that will greatly improve marshalling performance. But don't pass _big_ objects - required time increase mach faster than object size! In one project we have to pass vector of 16000 complex items (also vectors).. Re: Are there any tips or rules for increasing performance of RMI calls? Author: Alexander Derazhne ( so that clients operate with IDs only. I'd use // when connecting to chat room.jsp?EID=21992) So far I discovered only one rule of thumb: avoid passing objects as parameters or return values .jsp?EID=434414). I'd define an API that uses object IDs. It take more than 50m. get room ID int CHAT_ROOM_ID = (message). 2001 Author: Maxim Senin (http://www. Jun 6. and the server performs all the work of finding reference to object by ID.. message).postMessage (CHAT_ROOM_ID. After splitting it into 16 slices of 1000 items transfering take only types serialize much faster than objects because Java objects are so flat.jsp?EID=1010125). Any better ideas? Comments and alternative answers Marshalling objects can be expensive. See http://w. somehow get reference to chat room remoteChatRoom.getRoomID().

com/guru/ Why such a complicated solution? Author: Michael Hull (http://www.exit(). This is so that the Server is persistent until manually shut down. Firstly is there any way to store the reference of the client in the database which can be retrived later to send the response to that specific client. Why does it need to start another thread and use wait/notify? In the RMI CallBack Mechanism the reference of the client is sent to the server along with the request. you can provide a remote method. for the Remote Server. The shutdown thread. Jun 20. 2000 Modified: 2000-11-18 after a two (2) second delay.jsp?EID=240325) Question originally posed by mike niemaz (http://www. 2005 I don't understand why you don't just have the shutdown() remote method call the cleanup code and then System.jguru.jsp?EID=442241). calls System. Comments and alternative answers RE: How can I programmatically stop a RMI server? Author: James Haiar (http://www. shutDown(). 2000 Modified: 2000-11-18 17:19:42. Author: James Haiar (http://www. how can the server restrict the request coming from a specific client. This will allow the server to not accept any more remote calls.jguru. This method starts a shutdown thread. i.jsp?EID=442241).jsp?EID=254143 Created: Nov 15.e how to get the ip address of the client from the reference? Location: When the Server finishes all clean-up processing it wakes up the shutdown thread.jsp?EID=248768 Created: Nov 8. to end the Java Virtual Machine. 2001 You can also use the 'unexportObject' method in UnicastRemoteObject.jguru. 2001 Using externilizable instead of serializable makes marshalling faster How can I programmatically stop a RMI server? Location: http://www.417 Author: Edward Harned (http://www. The shutdown thread remains waiting for a notify().jsp?EID=200205 RMI Servers start a thread that never ends. Jun 20.65 .jguru. Apr 23. The delay is so that messages from the Server to the initiating Client complete the journey.

jsp?EID=255334 Created: Nov 16.." Secondly: One way is to have each client pass an identifier. and look at the characters. How can I have multiple clients remotely access multiple instances of a particular remote server? Apparently.jguru.rebind("name1".jguru.jsp?EID=46923 Firstly: java. RMI only allows for Point-to-Point communications between a client and a Remote server.get. object) ) different . For example.getClientHost() method? It is simpler when the client is exported for This way if ip addresses change you would not have to change you Server side. We took the below quote rrom the RMI-IIOP Programmer's Guide: "If you are not using the RMI registry for naming services.rmi.jsp?EID=12720). 2001 Why not using the java. It also does not mean the ip address is in there for every platform in every way. I have a need for multiple instances of that Remote server to handle high volumes of client ( Naming. Location: http://www..jsp?EID=243710 There is no such thing as multiple instances of a particular remote server.Author: Edward Harned (http://www. If you want the same code instantiated as separate JVM's then you must give the code. The following is NOT recommended: You can use toString().jsp?EID=240325) Question originally posed by Makkapati Ramanjaneyulu (http://www. Comments and alternative answers Why not using the java.jguru.RemoteServer.server. this does not mean that the ip address will be in there tomorrow. you have some other way of bootstrapping your initial remote object Author: Edward Harned (http://www. TODAY.server.jsp?EID=240325) Question originally posed by Byl Sottile (http://www.rmi.rmi. Is there a way to utilize the RMI frameworks to accomplish this task? Thank you in advance.RemoteObject implements Serializable so you can serialize the reference and save it to a byte array or use toString(). Author: Ray Ye (http://www. The ip address is in there. 2000 Modified: 2000-11-18 17:18:48. However.RemoteServer. as Mar 13. your server code may be using Java serialization to write an RMI object reference to an ObjectOutputStream and passing this to your client code for deserializing into an RMI stub.server.

ActivationDesc desc = new ActivationDesc (agid. I am getting connection refused error after 25 request are made simultaneously from 25 threads in a client.policy". (this is how the RMI and JNDI Registries work. "file:<package. true). A huge overhead problem in the client calling the router that calls the work server that returns to the router that returns to the client. 2000 Modified: 2000-11-22 16:56:19.jguru.put("java.register(desc). There was a lively discussion on load balancing in the Jini forum at http://www. What several people suggested was to set up a front end RMI Server that kept track of how many requests were allocated to each "work" RMI Server and pass the request along to one of those "work" Servers. myGroupDesc. Activatable.class>". if I create activatable two class ActClass1 and ActClass2 and run them I get two JVMs.341 Author: Greg Granato (http://www.jguru.createGroup(agid. How can I run a single JVM for different classes that are activated by different activation classes? For example.) Load balancing has been the subject of many books and articles since multiprogramming first appeared. The RMI and JNDI Registries are not the only places one may keep the reference to a remote object. ActivationGroupDesc myGroupDesc = new ActivationGroupDesc(" How you get access to this private registry may involve native code for each operating system.class>".221 Author: Edward Harned (http://www. 2000 Modified: 2000-11-28 Created: Nov 27. For this there is no easy solution.Now the problem is which remote server should the client call to balance the load. If you were to register both of your classes under the same ActivationGroupID then they would be served from the same JVM. props.registerGroup(myGroupDesc). ActivationGroup. You can serialize the reference and store it in your own. private "registry. 0). Location: http://www. Is it possible to run both classes in one JVM? Location: http://www. You are probably doing this once for each of your I believe this is controlled by the ActivationGroup.jsp?EID=260449 Created: Nov 22. Since you indicated a high volume of client in Sept/Oct 2000. "policy").jguru. null). null.jsp?EID=260445) Question originally posed by Daniel Lee (http://www. ActivationGroupID agid = ActivationGroup. this may not be a feasible solution. When you register the class you are probably doing something like: Properties props = new Properties().jsp?EID=240325) .getSystem(). "< by The createGroup translates into a JVM instance. How can I increase the maximum number of requests that an RMI server can handle

jguru.lookup(our_name).jsp?EID=253824 Without knowing more of the details. where the receiver is overloaded. how can I spread workload of RMI server between several server hosts? Location: http://www.rmi. Most developers use an intermediate RMI Server. (pass through).Question originally posed by Sunil Bansal (http://www. 2.664 Author: Edward Harned (http://www.jguru. you may be running into a temporary condition.Naming. issues for each of these are: Pass Back: .jsp?EID=21992 What you are looking for is called Load Balancing. (there are many). } catch(ConnectException e) { We use a retry loop for connection errors. (like a packet storm).(pass back).com/guru/viewbio. a Router.jsp?EID=240325) Question originally posed by Maxim Senin (http://www.jguru. The Router contains the logic to determine which Server should process the request from a client. There are two basic scenarios: 1.jguru. // got one return. The client contacts the Router and the Router passes the request to the Server. The client contacts the Router and the Router returns the RemoteObject for the Server. 2000 Modified: 2000-11-30 12:03:58. } catch(Exception e) { // add your code here // try to connect this many times int count = 10. // keep trying the connection while (count > 0) { try { ourRO = (OurRemoteObject)java.jsp?EID=266326 Created: Nov 30. } } How can I scale an RMI server? For example.

com/guru/viewbio.jsp?EID=111308) Question originally posed by Steve Kennedy (http://www.jguru. You can start a new thread for each Client call back.jsp?EID=245713 Start first with (default rmid port at 1098): ActivationSystem system=(ActivationSystem)Naming. way beyond what we can provide here.jsp?EID=276947 Created: Dec 13. 2000 Modified: 2000-12-18 This involves deserializing the object in the Router and re-serializing the object in the Router to return to the client Both these scenarios require extensive analysis and design way.ActivationSy stem"). and one of the clients is in There is no method invocation timeout that we know about.jguru.jguru.rmi.jsp?EID=266329 Created: Nov 30.activation. How to get rid of the hanging thread is another issue involving queue and thread management. This involves deserializing the object in the Router and re-serializing the object in the Router to pass on to the Server.jsp?EID=240325) Question originally posed by Maxim Senin (http://www. 2000 Modified: 2000-11-30 12:03:10. Clients may only use the Server RemoteObject one time since it may not be best able to handle the next request. If the thread does not finish in the "time you desire".This resembles the Internet where every "www" request must go to a common service that passes back the IP address. The object the Server returns to the client must go through the Router. rmid) is currently running? Location: http://www.jguru. Is there a simple way to find out if the activation system (i.jguru.797 Author: Edward Harned (http://www. then you know that Client is stalled and should not receive any more messages.e. .35 Author: vincent eggen (http://www. We use application threads to process our Client's requests. how can I timeout the method invocation? Is there a way to "post-and-forget" method invocation from server to the client? Location: http://www. If the RMI server broadcasts some data to all clients via callbacks. Pass Through: The object the clients pass to the Server must go through the Router.lookup("//:1098/

com/faq/view.511 Author: Edward Harned (http://www. • Using a physical address to identify a client is usually not a good idea.If (system==null). we advise our customers to include a unique identifier. (not RMI-IIOP or other plug-in).jsp?EID=282033 Created: Dec 19. this method generally is unacceptable: • The method only returns the TCP address of the host on which the client resides. When the location is always CallBack. the RMI Runtime keeps track of the identification of Clients that have unmarshalled this Server's RemoteObject. Using a "soft wiring" method means the client can take its identification with it when it moves. 2000 Modified: 2000-12-19 19:33:29. • rebind(String name.jguru. Thirdly.) However. not the actual client identification and this method is only available to pure Java.jsp?EID=240325) Question originally posed by Prabhpreet Singh ( there is an rmi Server method. machines come and go.jguru.957 Author: Edward Harned (http://www. the object will be bound to the name within the registry as implementations.jsp?EID=282032 Created: Dec 19. Object obj) will throw an AlreadyBoundException if there's already an object bound to that name within the rmiregistry. then an administrator must alter all tables. What is difference between bind and rebind? Location: http://www. How do I read/write a file from the implementation class of the RMI Server so that it does not give the AccessControlException? Location: http://www. Secondly -. By passing the Server the Client "RemoteObject". The network may change. for use by the Server within the parameter it passes to the Server.jsp?EID=240325) . the Server knows the ID of the API access to this data is not available. the object will be bound to the name within the registry. If there was no match.jguru. 2000 Modified: 2000-12-18 18:00:20. If there was no match. This is "hard wiring". (This has to do with the Distributed Garbage (possibly a long integer). getClientHost().jsp?EID=275762) Question originally posed by balamurali datla (http://www. 2000 Modified: 2001-01-10 22:37:27.jsp?EID=276956 Created: Dec 13.jsp?EID=267316 • bind(String name.259 Author: Jorge Jordão (http://www.jguru. Therefore. Object obj) will replace any existing binding for the name within rmiregistry.jsp?EID=207656 First How can I uniquely identify clients in RMI? Location: http://www.jguru. the activation system isn't running.

Use a policy file and specify the location on the command line for the Server: -Djava. If your Server handles ten concurrent the RMI Run Time destroys the RMI Connection Thread and must create a new RMI Connection Thread for the next request. How can I better handle threading in RMI? How could I have a thread pool that RMI uses to service clients rather than create a new thread each time? Is this within the power of the developer.jsp?EID=253363). you already have a pool of threads.jsp?EID=283836 Created: Dec 21. As each request finishes.jguru. ( "n" seconds).jguru.jsp?EID=240325) Question originally posed by Benjamin McCartney (http://www. I have been implementing an RMI client/server system which needs to detect when clients are finished with their remote references.AllPermission.. Otherwise.jsp?EID=216688 This is the security feature of Jan 12.jguru. As far as we know the wait time. or does it need to be part of the underlying RMI implementation? Location: http://www.. then there are ten RMI Connection Threads processing these requests. 2001 The general policy file which grants all permissions is as follows.jsp?EID=282035 Created: Dec 19.gc() which invokes the unreferenced method on the server.777 . Author: Sujatha Sundaram ( 2000 Modified: 2000-12-19 19:32:43. 2000 Modified: 2000-12-21 During heavy usage the waiting pool should suffice.jguru. Comments and alternative answers The general policy file which grants all permissions.Question originally posed by Sameer Bhardwaj (http://www.jsp?EID=109357 Technically. the clients set the reference to null and call system.runFinalization() is called).policy=file:/path_to_policy_file See the security feature in the SDK documentation. the RMI Connection Threads waits for the next request "n" seconds. If the next request comes in within this window. On Windows.709 Author: Edward Harned ( }.jguru. is part of the RMI implementation and is not alterable by developers. Any ideas why? Location: http://www. grant { permission then a waiting RMI Connection Thread handles the request. Under solaris however the unreferenced() method is not called (even if

) 2. We sell a framework for RMI Created: Jan 15. The unrferenced() method is only called when ALL clients no longer hold a reference to the remote object or when the lease time expires.leaseValue. Since this is the purview of the Distributed Garbage the application may take some action. url = "rmi://" + url + "/service".lookup(url). the registry must be running on the web server from which it came.jsp?EID=100886 You can find complete details for getting RMI to work with applets. We keep track of the idle period.jguru.jsp?EID=253363) Question originally posed by Sarvotham pai (http://www.jguru. we are not dependent on any implementations of DGC and we have much more flexibility. If you register your remote object with one of these. Where can I find a detailed instructions for the steps to be followed while using RMI with applets? Location: http://www.doc.jguru.jguru. (java.jguru.jsp?EID=7) For untrusted that is .121 Author: John Zukowski (http://www. Object obj = Naming. The necessary code follows: String url getCodeBase().jsp?EID=297130) Question originally posed by Ann George (http://www. 2001 Modified: 2001-01-15 Question originally posed by Benjamin McCartney ( (such as deactivating.sun. What is rmic? Location: http://www.the time when no Client has called the Server.Author: Edward Harned (http://www.jsp?EID=297399 Created: Jan 9. You can then cast the returned object to whatever type you want.html How do I lookup a service in the RMI registry from an applet? Location: http://www.042 Author: Sujatha Sundaram ( Author: Deepa Lakshminarayanan ( When this idle period reaches a threshold.jsp?EID=109357 1. then your unreferenced() method will never be called. (RMI/JNDI) are clients.jsp?EID=302866 Created: Jan 2001 Modified: 2001-01-15 22:05:09.jsp?EID=295412 . The Registries. 2001 Modified: 2001-01-15 21:57:07.jguru.) In this way. We do not implement the Unreferenced along with example code at: http://java. each operating system may implement this differently.3/docs/guide/rmi/getstart.dgc.jguru.

com/guru/viewbio.jsp?EID=297130 An interesting article that talks about A stub is a proxy for a remote object that is responsible for forwarding method invocations on remote objects to the server where the actual remote object implementation resides. Sep 27. A skeleton for a remote object is a server-side entity con.jsp?EID=241600 The activatable object is activated on demand by default. boolean restart) Comments and alternative answers This only works on restart Author: Steve Hoffman ( with the following constructor: public ActivationDesc(String className.76 Author: Edward Harned (http://www. Applets.taining a method that dispatches calls to the remote object implementation.jguru. String location.jguru. .rmic is the Java RMI Stub Compiler. How can I activate it without waiting for the first RMI call? Location: http://www. a client's reference to a remote object is actually a reference to a local stub.jsp?EID=323100 Created: Feb 7. MarshalledObject data. 2001 Modified: 2001-01-21 2002 According to the you have to call the Remote for it to start. The rmic compiler generates stub and skeleton class files for remote objects from the names of compiled Java classes that contain remote object implementations.539 Author: Bapu Patil ( Therefore. 2001 Modified: 2001-03-21 Currently.sun.jsp?EID=49941) Question originally posed by Deepa Lakshminarayanan (http://www. As far as I can tell. I've confirmed this in a test.jguru. and RMI can be found at: http://developer. it only activates on a restart and NOT the first time.jsp?EID=305015 Created: Jan 17. (see the javadoc for the full details) Set up your java.jguru.activation.jsp?EID=240325) Question originally posed by Kelvin Ho (http://www. Where can I find a code example of Applet-RMI communication? Location: You can have it activated when the activation daemon starts by setting the restart boolean to true in the Activation Description.jsp?EID=1005113). the activatable object registered in rmid is activated on demand.

Location: http://www.jsp?EID=326113 Created: Feb 11.How interoperable is the RMI-IIOP transport from Sun with existing ORBs? Is it possible to use my RMI client or server implementing RMI-IIOP with other ORBs like Visibroker? Location: http://www. because the obj references a valid stub which references null. Comments and alternative answers From what I back is still null if (back == null) You would not test "rs" since this is the reference to the Remote Object. I let the method return null. to interoperate between an RMI-IIOP client and a C++ object you would need to: 1.jsp?EID=308330) Question originally posed by jerome arrault (http://www. Define the remote interface of the object in Java as an RMI Interface 2.jsp?EID=329179 Created: Feb 14. 2001 Modified: 2001-02-14 as if (obj == null) returns false. Run a C++ stub compiler against the IDL file to produce the C++ skeleton for your C++ server object What is the cleanest way to design methods of remote objects that may return null? Normally. RemoteServer rs . For example. Therefore.jsp?EID=240325) Question originally posed by Ted B ( back = rs. Run rmic -iiop against the interface to produce the stub for your RMI-IIOP client 3. Run rmic -idl against the interface to produce IDL compatible with the RMI interface 4. 2001 Modified: 2001-02-13 14:50:58.383 Author: Edward Harned (http://www. I think the easiest thing to. and the code that calls the method checks for null before using the object that was returned.jsp?EID=123993 If the existing CORBA object has its remote interfaces defined originally in CORBA IDL..jguru.jguru.jguru. Unfortunately. "RemoteServer".jguru. String back = // here.jsp?EID=319546 We are not sure we understand the question.. when the remote method getName returns null. this doesn't work with RMI. RMI-IIOP applications can interoperate with other CORBA objects only when their remote interfaces are originally defined as Java RMI interfaces. then interoperability is not possible..jguru. the "cleanest" way is the most direct way.877 Author: Suresh Rangan (http://www.

Mar 23. stream-based protocol that is only partially specified is now in two The second version was released with the Java 2 SDK. In the Java 2 SDK implementation of makes the call to the remote service implementation object. RMI uses a wire level protocol called Java Remote Method Protocol (JRMP). Comments and alternative answers No skeleton in java new version Author: Shalini Aggarwal ( The skeleton carries on a conversation with the stub.jsp?EID=330333 Created: Feb 15.). 2001 From what I understand. the new wire protocol has made skeleton classes obsolete. 2001 Modified: 2001-02-15 Aug 15. use it as the return type of the original method.jsp?EID=327237 A skeleton is a helper class that is generated for RMI to use.jguru. On top of TCP/ JRMP is a proprietary. RMI uses reflection to make the connection to the remote service object. Remote method call returning null Author: James Chiang (http://www.58 Author: Suresh Rangan (http://www. The first version was released with the JDK 1.1 version of RMI and required the use of Skeleton classes on the server.jguru. It has been optimized for performance and does not require skeleton classes.jsp?EID=80178).com/guru/viewbio.jsp?EID=308330) Question originally posed by Ruby India (http://www. The skeleton understands how to communicate with the stub across the RMI link. ageed with reflection but how?????This is a big question Re: No skeleton in java new version Author: Suresh Rangan (http://www. 2001 The answer given just tells that this feature is there but doesn't tell how come without the skeleton RMI works. Author: Mark Webb (http://www. Just create your own exception and then allow the remote method to throw it.jguru. I think the easiest thing to do here is to just throw an exception instead of returning null. 2001 Just define another remote object(and its impl. Mar 5. and then writes the return value back to the stub. it reads the parameters for the method call from the link. If skeleton classes are not required in Java 2.jsp?EID=341533). Apr 2001 .jsp?EID=308330).jguru. accepts the return value. how does the communication & invocation of remote methods actually take place? Location: http://www.

We do not have "the" There was no "time- out" in Question originally posed by praveenkumar thirkkol (http://www. 2001 Modified: 2001-02-18 21:29:45.256 Author: Suresh Rangan ( 2001 Modified: 2001-02-18 21:36:35. Comments and alternative answers . Distributed Garbage Collection "Garbage Collection of Remote Objects" is a chapter in itself. once again. (the default time-out for this is 10 minutes). implementation dependent.jguru.jsp?EID=322685 Good question.1 on WindowsNT using the IBM or Symantec implementations. This question has been here for several days so we submit the following: The Java specification leaves implementation details to those who write the JVM. There was no "time-out" in JDK1.jsp?EID=332524 Created: Feb 18.leaseValue().com/guru/viewbio.1 on WindowsNT using the SUN implementation but not since SDK1. This is what the skeleton was doing till it was deprecated. Release and implementation We noticed a "time-out" in JDK1.jsp?EID=331657 Created: Feb 16. It takes the object from the stub and then by reflection principle of java it identifies the class of the object which is passed on wire.jguru. 2. You may also want to see the rmi server property: java.jguru.207 Author: Edward Harned (http://www.jsp?EID=320826 If a non-remote non-serializable object (an object which doesn't implement Remote nor Serializable interfaces) is passed as an object parameter.NotSerializableException Non-remote objects which are passed as parameters must be Serializable and are passed by copy.jguru. When and how the garbage collector frees references to remote objects and exactly what else it does is. this is dependent on two factors: 1.1 on Linux (Blackdown) or other Unix type operating systems.jsp?EID=240325) Question originally posed by Sridhar J (http://www.jguru.jguru. you will get a java. What happens if an object parameter that does not implement Remote or Serializable is passed to a remote object? Location: http://www. Does RMI have a timeout period within which a remote invocation must return? Can I change this timeout period programatically for a specific remote method invocation? Location: http://www.dgc.

} public ServerSocket createServerSocket(int port) throws IOException { return new ServerSocket(port).com/guru/ } }).). port).com/guru/viewbio. I suppose it would be possible to modify the timeout dynamically.setSocketFactory(new RMISocketFactory() { public Socket createSocket(String host.setSoLinger(false. communication between a remote object and its client is done over TCP sockets. RMISocketFactory. 2001 Modified: 2001-02-18 21:31:23. Author: Niyi Gbodimowo (http://www.jsp?EID=327885).jsp?EID=240325) Question originally posed by Dnyanesh Bendre (http://www.jsp?EID=332525 Created: Feb Mar 6. 2001 As you well know.jguru. Mar 18... socket.rmi. Author: John Tenney (http://www.RMISocketFactory class that maintains a reference to the sockets created and allows you to change the socket timeout value return socket. int port) throws IOException { Socket socket = new Socket(host. communication between a remote . then you can write a simple wrapper for the java.setSoTimeout(timeoutMillis). As you well know. 0).server. Can I pass an Image object from a remote server to the client using RMI? Location: http://www. By playing with the socket timeout... Since you can specify a RMIClientSocketFactory as an argument to the UnicastRemoteObject class.exportObject(. This is done automaically if your remote class extends UnicastRemoteObject or you may explicitly call UnicastRemoteObject.jsp?EID=380336). though not for a specific call. socket. The socket is created and bound when you export the object.jguru.483 Author: Edward Harned (http://www. 2001 You might try this.jguru. The key here is to set the socket timeout value of the client-side socket. Create a custom socket factory.jguru.jsp?EID=274207 .

serializable (An object that implements the Serializable interface will not actually be serializable if the classes of one or more of its member variables are non-serializable).com/guru/viewbio. it is a violation of the J2EE specification to pass or return a parameter of type java. The compliant application servers (the J2EE reference server itself for example!) will allow the deployment and use of EJB's that .image. in fact.ImageIcon. Comments and alternative answers RE: Can I pass an Image object from a remote server to the client using RMI? Author: Vitaliy Rabotnik (http://www.jsp?EID=349855) Question originally posed by Randall Minter (http://www.lang.jguru. 2001 Modified: 2001-03-13 11:38:35.Serializable interface and is. java.Object from an EJB method because the Object class does not implement Serializable. for example you open a DataInputStream on an image file. May 18. "The arguments and return type must be legal types for Java RMI.For what class? The basic rule for passing objects by RMI is that the class must implement the java.jsp?EID=349856 Created: Mar 12. Interestingly. for this interface explains what it is and how to use it.jsp?EID=424640).awt." Location: yes. I think it's doable What are the legal RMI types refered to by the J2EE Developer's Guide? As one of the method no. get/set methods } Use DataOutputStream on the other side to write the bytes in the buffer into the file. it often says. String name. javax. Some EJB etc.457 Author: Ashley Tate (http://www. read the bytes into a buffer . and what if you create a serializeable class as follows public class MyImageFile implements Serializable { byte[] buffer.jsp?EID=116341 A legal value type for RMI is an object that implements the java... (too long to put here).jguru.Serializable Interface.jguru. 2001 What if.

6 of the RMI specification at: http://java.jsp?EID=453834).321 Author: Govind Seshadri (http://www.3/docs/guide/rmi/spec/rmiTOC. Jul to set up RMI to resuse incoming requests.violate this constraint if at runtime the bean methods actually pass and return sub- types of Object that are serializable. Implementing callbacks. 2001 Modified: 2001-03-26 20:51:41. Here. and how does it work? Location: http://www. the interface defines the methods that may be invoked by any object with access to the interface. See the Dr. and how. 2001 If you can implement your client the serializable interface. however. Location: Question originally posed by Rajneesh Garg (http://www. Is there a way to reuse threads that are used to handle incoming requests in RMI? I have read that there are application servers that will do this. The real "functionality" is present within some other object that actually implements this interface and it is "called back" by the target object. Is there a way to reuse threads that are used to handle. and the like).com/guru/viewbio. but do not know of any. Author: Bertrand Folleas (http://www. make it implement some remote interface). is not without challenges -. which are then asynchronously invoked in response to an "event" (timers. Callbacks are implemented in RMI by setting the client itself as an exportable remote object (that is. then registering a reference of this with the remote-server object. if you run the Verifier tool that comes with the J2EE reference server. an alternative way for server to call remote method of the client is to pass the instance of the client to the server (by a remote method of the server) Created: Mar 21. you will be informed that the bean method parameters do not conform to the RMI-IIOP value type guidelines. Java uses interfaces to give you access to the same functionality in an object-oriented world. Comments and alternative answers RMI's callback without have the client's reference in server's rmiregistry. Dobb's article on "Implementing callbacks with Java RMI" for complete details...sun. the server can asynchronously invoke the remote methods of any connected client in the same way the client can asynchronously invoke the methods implemented within the remote-server objects. For a more detailed explanation of legal RMI types. This way. and is it possible to use standard RMI classes that come with the JDK 1. read section 2. and then the server call the client's remote method on the instance of the client. However. What actually is a 'callback' concept in RMI.jguru.html What actually is a 'callback' concept in RMI.jguru.jsp?EID=386346 .jsp?EID=310913 Event-driven programming in languages like C has traditionally used function pointers to pass references to functions. Are there any that do this.particularly in a distributed-object environment like RMI. mouse clicks.

2001 . than the thread processes the request. of data.jsp?EID=80178 Re: Is there a way to reuse threads that are used to handle. int. So.jguru. Can I pass a database connection using RMI? Location: http://www. (serializable).com/guru/viewbio.jsp?EID=396593 Created: Apr 5.jguru. If no new request comes in within this value.getConnection(). only copies.jguru. The answer is that you cannot. There is a timeout value for this thread. Comments and alternative answers look at rmijdbc Author: Gabriel Artaud (http://www. within the database after a Select.jsp?EID=41777) Question originally posed by Jawahar Pandian (http://www.jsp?EID=47746 Re: How can I start an RMI server on demand? The Java RMI activation API (java. The Server can issue the SQL statements saving the fields in an then the thread is distroyed.Connection from java.jguru. RMI reuses the RMI-Connection thread that processes the incoming 2001 Author: Edward Harned (http://www. 2001 Author: Edward Harned ( May We assume you mean: java. 2001 Author: Mikael Jakobsson (http://www. etc. The Server returns that object to the Client that displays the data.sql.jsp?EID=240325) Question originally posed by saji Devassy ( Question originally posed by Mark Webb (http://www. and you will need to run the rmid daemon on the server that will handle the activation for you.jguru. How can I start an RMI server on demand? How can I start an RMI server on demand? Location: http://www.jsp?EID=386349 Created: Mar 24.jguru.Created: Mar 24.). If a new request does comes in within this value. You cannot pass a reference to something other than a RemoteObject() with RMI. It is IMHO not the most pleasant API to work with.1.activation) enables you to make your RMI objects to activate on What you can pass are the data fields. (we do not know whether this value is adjustable).jsp?EID=9114).jguru. (String. You can find more information here. in a GUI Client you can pass the parameters for a Select to the RMI Server.jguru.DriverManager. Since JDK1.

ServerException: RemoteException occurred in server thread.rmi.[server]_Stub Any ideas how I can avoid this? Location: http://www. All the core APIs and standard extensions (javax.jguru. nested exception is: java.server.jsp?EID=317296 I had the same problem.jguru.rmi. including RMI since it is a part of the JSDK/JRE archives.objectweb. When you download the JRE or JSDK you are presented a license that is applicable to all the downloaded nested exception is: Created: Apr 5. You may want to create a way to retrieve a serializable equivalent of a ResultSet in bulk instead of looping remotely Can I use the RMI registry for the commercial purpose without having to pay Sun royalties or licensing fees for the same? My guess is I don't since it is a part of the JRE. 2001 Author: Sehner Ralf (http://www. i. I start my Created: Apr you have not to pay any royalty.jguru.codebase=file://<IP>/<Drive- Letter>:/<Path to the root directory of your packages>/ <Class with main> Do not forget to use the trailing '/'.jguru.jsp?EID=101985) Question originally posed by Shalini Aggarwal (http://www. Why do I continue to get ClassNotFoundException on server stub class? After I start rmiregistry.rmi. 2001 Author: Luigi Viggiano (http://www. -Djava.jguru. The solution was to use the parameter -Dxxx like in the following call: java -classpath=. What you could do is create a RemoteConnection (which extends UnicastRemoteObject) Have a look at: http://www.jsp?EID=385716) Question originally posed by jimmy bellows (http://www..jsp?EID=385559 RMI is a part of Java Core APIs. but what is the definitive answer on this? Location: http://www.UnmarshalException: error unmarshalling arguments. Comments and alternative answers .htm The only problem of rmijdbc is the and it is subject to the same license as JRE/JSDK. but am getting the exception: java.* packages) are free for use within your {package}. it's free.

java..0 and JDK 1.jguru. May 18.jar.UnmarshalException: error unmarshalling arguments. 2001 I get this exception when i run my server 2002 .jsp?EID=409452). Sep 17. That works for Windows NT 4.jsp?EID=424640).ServerException: RemoteException occurred in server thread. If I do so.3..j Problem is that I have to jar and sign the code on the server side. Now I cannot connect to my rmiregistry and I'm ge C:\WINDOWS\jbproject\RMIPrototype\classes.[server]_Stub I tried to run my server by using the following line java -classpath=..rmi.ClassNotFoundException: {package}. 2001 My application works fine as it is. nested exception is: java.jar. Jun 8.3\jre\lib\rt.codebase=file://<IP>/<Drive-Letter>:/<Path to the root directory of your packages>/ <Class with main> even though i am getting exception as Exception in thread "main" noclassdefinitionfounderror: servername please let me know how to run the server RE: Author: Vitaliy Rabotnik (http://www. I think that wonderful tool looks into the CLASSPATH shell variable for classes for the RMIClassLoader. ClassNotFoundException on server stub class Author: Linda Hassan (http://www.jsp?EID=498587).jsp?EID=740379).jguru.3\jre\lib\ it still gives me the same exception .com/guru/viewbio. May 16. 2001 I've already use the Dxxx parameter for for 2001 Try to start your rmiregistry with the CLASSPATH shell-variable set to the base directory of your classes.server. Jan 30.C:\Borland\AppServer\lib\\JBUILDER5\JDK1.jsp?EID=1229872).C:\JBUILDER5\JDK1. I get exactly same above mentioned exception . But attention you must be sure the rmiregistry isn't already running Simple solution Author: Jan Rovner (http://www.3\lib\dt. ClassNotFoundException on RMI Server start Author: Arno Schürhoff (http://www.jsp?EID=435970). 2005 If you put the following line of code in the server class (before to call the "rebind" method) it works fine: LocateRegistry. -Djava.RMI Author: kumar618 pandian (http://www. rmi.createRegistry(int Port).jar.C:\jbuilder5\lib\dx.rmi. Feb 28. and your solution did not help a bit.C:\JBUIL Re: ClassNotFoundException on server stub class Author: Andrea Coloru (http://www.lang.jguru. but I need to store my client source code in a signed jar so that I could grant permissions (such as io) for the applet on the client side.jguru. nested exception is: java.jguru.jguru...

jsp?EID=402272 Answer by Edward Harned Re: about rmi callback See the jGuru example at Sun's JDC: Where can I get a simple example of RMI callback? Location: http://www. -Johnathan Re: Simple solution Author: Venugopal Similar Author: Nefarious Burrito ( . In my case. work for both rmiregistry and your server object) I use simple batch file I was attempting to run the server class within a jar file: java -jar /path/to/jar/ With the manifest specifying which class to run..jsp?EID=967143). I made sure to run the rmiregistry contained in sun's jdk and not the one which appears to ship with RedHat linux. Sep 8. Well rightnow i'm at a very initial stage in rmi. 2001 Author: Govind Seshadri ( 2004 hi jonathan. 2002 That works! Thanks.jguru. 2004 I had the exact same problem. its better that you send me a detailed e-mail.zzz just start rmiregistry from the directory where you have server object (to make . That solved my problem.jguru. my email address is sjvenugopal@yahoo.yyy. Apr 20. I finally decided to explode the jar and call the class file directly.jguru. Jul 27. After much searching.jsp?EID=1164386). Also. (http://www. For Win users: If you have CLASSPATH set to .jsp?EID=14) Question originally posed by Sharaschandra Rai (http://www. Can you plz explain the whole procedure how to encounter this error.jsp?EID=1197988).com/guru/viewbio.bat with command @start /min rmiregistry Then start the server as ususal For Unix users: use rmiregistry & Re: Simple solution Author: Johnathan Lam (http://www.jguru.jguru.jguru.jsp?EID=403078 Created: Apr

you don't have to deal with Microsoft anymore. Comments and alternative answers Netscape & IE's JVM in its support on RMI Author: James Chiang (http://www. y=- 1000).jsp?EID=404997 RMI doesn't work in Internet Explorer because Microsoft decided not to support it in its attempt to ruin Java. after which your Internet Explorer will support RMI.RegistryImpl does it for and specify the starting position (x and y) outside the visible area of the screen (like x=-1000. 2001 Author: Govind Seshadri ( They did put a patch file somewhere on their site that you can download and install. I'm not sure as to why RMI wouldn't work on Netscape though.jsp?EID=341533).jsp?EID=14) Question originally posed by Victor Gomez (http://www.jsp?EID=411869 Created: Apr 28. and you can even use Swing and other Java2 stuff in your applets.jguru. That way.jsp?EID=310661) Question originally posed by S L (http://www. Location: http://www. Microsoft trial]. You can create a Windows Link (something like a . I get a dos console all the time. it does work. 2001 . Is there something like this for rmid? If I use "start rmid". Why doesn't my applet's RMI-calls work in a web-browser? They are working correctly on a appletviewer. but RMI-calls are not working at all. you can also change your applet so it doesn't need RMI anymore. in a further attempt to ruin Java).jguru.jguru. This was done on purpose [which became clear after the Sun vs. i think it should work on there.0 and Actually.jguru.How can I start rmid in the background under win32? I found that javaw sun.registry.jsp?EID=407579 Created: Apr 21. but that doesn't help much if you have an applet and you want all your visitors to use it (since they'd all have to download that patch. 2001 Author: Niek van Suchtelen (http://www. i think if you load the applet locally (instead of over the network). Aug 15. Any idea what the problem is? Can there be some security problems? I am using both Internet Explorer It might be that you have to change the security settings in there. but there might be some other reason for It's quite a big download for the average user (about 5MB if i'm not mistaken). but still a lot easier for end-users to install than the Microsoft RMI patch. Location: http://www. which is buried somewhere deep in a hard to find place on Microsoft's site.jguru.jsp?EID=349972 Answer by Luigi Viggiano Try hiding it.rmi. Probably the best solution for you would be to use Sun's Java plug-in. The applet is running within the web- browser.

codebase="file:///c:/my project/classes/" Comments and alternative answers Spaces in RMI File URLs Author: Avi Abrami ( 2001 how did you configure IE to run Sun's JVM ? Also how do you configure applet so that if doesnot require RMI ? how do you configure so that applet dont need RMI anymore ???? Author: sam pitroda (http://www. Speaking in a Java context we should specify Java RMI is a protocol that enables a remote object to be used just as it would on a local RMI stands for Remote Method Invocation and is a Network Layer to let a client application to invoke methods of objects located on a remote RMI can be considered the object orientation counterpart of Remote Procedure Call (RPC).jguru.jguru. The word "RMI" is not specific to the Java language: the RMI concept is not recent and has been implemented in many other languages. Is it possible to use the Location: http://www. also let me know how to configure IE to use Sun's plug-in What is RMI? Location: http://www.jsp?EID=9114) Question originally posed by Peter Mularien (http://www. Further more. Sun's JVM 1. Aug 21.7X does support RMI as a client. .rmi.jguru. 2001 Author: Luigi Viggiano (http://www. Aug 21.jguru.jsp?EID=101985) Question originally posed by John Zukowski PREMIUM (http://www. Re: Netscape & IE's JVM in its support on RMI Author: sam pitroda (http://www.jguru.jguru.jsp?EID=416074 Created: May 5. 2001 how do you configure so that applet dont need RMI anymore ???? If This is particularly important on NT systems. Netscape 4.server.jguru.rmi. May 6.server.1 plug-in on IE5 still got strange run-time exception.jguru.jsp?EID=476938). space is the delimiter which defines multiple entries in this property.jsp?EID=476938).codebase property with file urls which have spaces in the name? For this property.jsp?EID=82909 You can try having something like: Created: Apr But Netscape 6 has some 2001 Author: Gabriel Artaud (http://www.

You could say "file:/c:/program%20files/RMITest/" or "file:/c:/progra~1/RMITest/". rmiregistry must be running on the same computer than the RMI server If you need to be able to run a service directory (an equivalent of rmiregistry) on a different computer than the one where you server is running.jsp?EID=417817 Created: May 8.4. . Re: It's not a valid URL Author: Mr Miep (http://www. May 14.even if surrounded by quotes.jsp?EID=1100983). It's not a valid URL Author: Ian Beaumont (http://www. spaces in the value of the 'java. and will connect to the appropriate remote object server. 2003 I tested with JDK 2001 I recently had the same problem. my RMI application always gave errors if there were spaces in the Using your example. I found the %20 didn't work.3 DOS name for the value.server.%20 instead of blank works fine Is it possible to run rmiregistry on a different machine than the remote object? How is it possible for remote objects running on different machines to "share" a common registry? Location: http://www.jsp?EID=349687).com/faq/view. 2001 The rmiregistry does not have to be running on the same server as the remote objects.jguru.jsp?EID=9114) Question originally posed by Dnyanesh Bendre (http://www. this would be: file://c:\myproj~1\classes\ Cheers. 2001 On my Windows 2000 system. What I didn't try . Jul using the May 27.rmi.but it may work .jsp?EID=274207 I'm afraid the answer to your question is no.jguru.1 / Windows XP . you should consider looking at CORBA instead of RMI (but CORBA is more complicated and will cost you money) Comments and alternative answers rmiregistry can be on any local server! Author: Paul Gier (http://www. 2001 Author: Gabriel Artaud ( Avi.jguru.codebase' property just does not work .com/guru/viewbio. When the server application starts up. No matter what I tried. Clients can look this object up using the same URL. A guy at Sun emailed me with >> It's not valid to have a space in a URL. simply register the name of the object as rmi://hostname:port/LookupName where hostname is the hostname of the rmiregistry.

jsp?EID=349687). Then pass this file to the rmiregistry upon startup like this: rmiregistry -J-Djava.rebind disallowed. Re: Re: Re: ***URGENT *** Re: rmiregistry can be on any local server! .168. }.jguru.jguru.jsp?EID=446443). Tried the same on the linux box.1.1.rmi. the next step is to find out the exact permissions needed to allow binding of remote objects because it's not very secure to have your rmiregistry running with all permissions.ServerException: RemoteException occurred in server thread.32/192. thanks for the response.32 is non-local host: Re: ***URGENT *** Re: rmiregistry can be on any local server! Author: Paul Gier (http://www. To give all permissions create a file containing the following: grant { permission FYI the machine on which the Rmi Registry is running is Linux and even then it seemed to give me the same problem. it did not work. If this works. 2001 It sounds like you need to set one of the permissions on the rmiregistry server via a policy file.jsp?EID=446443). but i get this exception.1. I am trying to do the same as mentioned by you . 2001 Hi Pual. java. it did not Please see if you can help me on I tried it out on my Win 2000(Professional) as the Rmi Registry Server with the same command given by you and was trying to bind from another system. Am i missing something here or how do we do about from here.policy=<filename> Then try to bind the remote object again. Hope this helps! Re: Re: ***URGENT *** Re: rmiregistry can be on any local server! Author: Ramesh Vudatala (http://www.Registry.jguru.168.AccessException: Registry. Please help. or is it the file name and its path which has the problem. 2001 Hello. It says non- local host and AccessException do this mean any permissions or the RMI REgistry needs to be run on specific login. Nov 6.AllPermission. origin 192. I was tried nested exception is: java. Nov 5. Nov 5.***URGENT *** Re: rmiregistry can be on any local server! Author: Ramesh Vudatala (http://www.

jsp?EID=101985) . 2001 Author: John Mitchell ( Check out the RMI example which is part of the Sun JSSE sample code. Say I take some class file: how can I know if it is a stub or a plain class file? Do not tell me by file name.dgc.lookup your file "/etc/hosts". Dec it just stop at "Naming. Sorry for the 2001 I tried it out too.rmi. take a look at java. I need to generate a GUID and have seen suggestions about using an RMI server but nothing about how to actually generate the GUID itself.jguru. I run my rmi server well under RedHat7. Location: http://www. 2001 Author: JIA Java Italian Association (http://www. Location: http://www.jguru.0. Maybe they did allow this functionality in an earlier version of the rmiregistry. Anyway. I think that my original statement was should run your rmiregistry in the path that includes your _stub.jsp?EID=349687).jsp?EID=566153). I need a technical answer that is made on the basis of the content of the binary Author: Paul Gier (http://www.jguru. You should be able to accomplish the same thing using an LDAP server.1 localhost" 2.lookup(url)" and said " Maybe this could be enough for your purposes.jsp?EID=426322 Created: May 22.rmi. and got the same error message you did.1 but everytime I run my client.nested is null" Where can I find examples of using SSL with Java RMI? Location: http://www.jsp?EID=316131 I'm not sure you can generate a GUID without writing native code to get the network card number or ethernet address.jsp?EID=429779 Created: May 28.jsp?EID=429781 Created: May 28.0. Unfortunately.jsp?EID=414973) Question originally posed by ewan harrow (http://www. But now there does not seem to be a way to do a remote bind() to the rmiregistry.there is a line "127. but I don't know the implementation details of this.jguru. Nov 7.VMID for generating unique identifiers across all Java Virtual Machines. Re: ***URGENT *** Re: rmiregistry can be on any local server! Author: lei yuan (http://www. 2001 Have you run your application successfully now? I think you should 2001 Author: Luigi Viggiano (http://www.

The delegation is performed through the ref.jguru.jsp?EID=429822 Created: May 28. When stubs are invoked by a client. To understand if a class is a businness object or just a stub you have to check its source code and understand its server object performs what was required and returns the result to the client etc.jguru.RemoteStub.jsp?EID=431183 Created: May Yes if your event extends EventObject which is serializable Be sure to define non-serializable properties of your new event as transient (note that doing so you won't be able to send them thru RMI) You can also include remote references in your event (ie references to UnicastRemoteObjects) Where can I learn (more) about Application Servers? Location: It also implements the remote interface.jsp?EID=4) . otherwise. To decide whether it's a stub or a plain class file.jguru. John Is it possible for a client to send an event to an RMI object.jguru.jguru. if it just acts like an intermediate to the network layer it's a stub. otherwise is a plain class.2.Question originally posed by Mahjoub Langar (http://www. 2001 Author: John Mitchell (http://www.jsp?EID=9114) Question originally posed by John Kavanagh (http://www. they delegates the call to the RMI/JRMP engine. Jul 10. at runtime you can check if the class is instance of java.jsp?EID=421987 A stub is just a dummy implementation of a remote object interface delegating the real job using network. and vice versa? Location: http://www. If it does businness jobs directly it's a plain class.server. if yes it's a and it's methods..2) which is part of the methods body in the stub. which again forwards the call to the server object. .invoke call (jdk1.jsp?EID=331034). When invoked it delegates the invocation to RMI 2001 Stubs are proxies that implements RMI interfaces (which are also implemented by a remote object).RemoteStub.jguru. Comments and alternative answers Stub or plain class file Author: John Norgaard ( look for these features: The generated stub class extends java. For RMI.jguru. 2001 Author: Gabriel Artaud (

jguru.jsp?EID=4) Check out the jGuru Networking . Where can I learn (more) about Java Serialization? Location: Where can I learn (more) about Java's support for developing multi- threaded programs? Location: http://www. Where can I learn (more) about Java's support for transaction processing? Location: http://www. 2001 Author: John Mitchell (http://www. 2001 Author: John Mitchell ( Created: May 31.jsp?EID=431210 Created: May Check out the jGuru JMS FAQ.jguru.Check out the jGuru AppServer FAQ.jsp?EID=431188 Created: May Check out the jGuru CORBA Created: May 30. 2001 Author: John Mitchell (http://www.jguru.jsp?EID=431245 Created: May 30.jguru.jsp?EID=431248 Created: May 30. Where can I learn (more) about Java's support asynchronous and publish/subscribe messaging using JMS (Java Message Service)? Location: http://www.jsp?EID=4) Check out the jGuru Serialization 2001 Author: John Mitchell (http://www. Where can I learn (more) about Java networking capabilities? Location: Created: May 2001 Author: John Mitchell (http://www.jsp?EID=4) Check out the jGuru Jini Check out the jGuru Threads FAQ. Where can I learn (more) about CORBA (Common Object Request Broker Architecture)? Location: http://www.jguru. 2001 Author: John Mitchell (http://www. Where can I learn (more) about Sun's Jini network technology? Location: http://www.jguru.jguru. 2001 Author: John Mitchell (http://www.

"Project JXTA"? Location: before starting the RMI Registry.jsp?EID=4) Check out the Project JXTA site. After modification.2/docs/guide/rmi/faq. Will multiple Lan cards cause problems using rmi? If a host has two or more network cards (only one of which is Internet-enabled). Even if the RMI Registry is started running on the fully qualified domain name that you have chosen. Location: 2001 Author: srinath mandalapu (http://www.jsp?EID=430437) Question originally posed by Sri Kundurs (http://www.jguru. The answer is to set the system property and has a client-side callback method invoked by the server.jguru. 2001 Author: Chris Arrowood (http://www.jguru. is the change visible in other clients.jsp?EID=451232 Just declare this method (changes the static variable of RMI server) like any other remote method in the remote interface supported by RMI server and implement this method in RMI Server implementation (Remote object implementation).jsp?EID=463464 Created: Jul Where can I learn (more) about Sun's peer to peer.jsp?EID=419443 RMI Server and static variable I am trying to implement a RMI server that has a static variable.jguru.Check out the jGuru Transactions FAQ.jguru. Many Thanks Sri Location: http://www. This method must be synchronized. how does RMI know which IP address to use? There seems to be a problem when such a client registers with an RMI service. Is there anyway the clients can access this static variable on the server side and modiy it.jsp?EID=431963 Created: May 31. See the Suns FAQ on this topic at 2001 Author: John Mitchell ( (RMI runtime may service remote client requests on a remote object concurrently in multiple threads) . the RMI objects may have the local unqualified name embedded in them.jsp?EID=443590) Question originally posed by Andy Ho (http://www.jsp?EID=447248 Created: Jun 28.

.jsp?EID=390903) Question originally posed by viswabharathy kunapuli ( manipulation of the database would be threadsafe if I simply "synchronized" the changeDatabase() method. 2001 Author: Dermot Hennessy ( Yes.jsp?EID=463929 Created: Jul public void changeDatabase(){ change a database } .jsp?EID=476938). Naming.jsp?EID=390903).. 2001 Author: Edward Harned (http://www.jguru.jguru.jguru. Aug right? Location: http://www. ss). Both get a reference by: Naming.rebind("//S/S". .com/guru/viewbio. Comments and alternative answers is marshaling/unmarshaling secured ? Author: sam pitroda (http://www.jsp?EID=240325) Question originally posed by Bo Lee (http://www. but transport.. My question is: do A and B always work on the same object instance(ss) of class S? If they work on the same instance. Apr 3. 2001 do I need to do something else to make object over RMI secured ? ( like encryption ?) Re: is marshaling/unmarshaling secured ? Author: Dermot Hennessy (http://www.What is the meaning of marshalling and unmarshalling? Why is it done? Location: http://www.jguru.jguru..jsp?EID=440534 Marshalling is serialising an object to enable it to pass across process boundaries efficiently (normally conversion to a byte stream).com/faq/view. } Than I get a instance of class S and bind it to rmiregistry: S ss=new S()"//S/S"). Do RMI clients always work on one single object instance of RMI server class? Suppose I have a rmi server class: class S { . 2002 Yes. Unmarshalling is carried out in the other process to reconstruct the original object from the serialised version. The purpose of marshalling/unmarshalling is not security. Now I have two rmi client A and B. and then call method changeDatabase(). there is only one instance of the RMI Implementation Class.jsp?EID=463933 Created: Jul 28.

com/guru/viewbio. This is the normal TCP accept bahavior. However. the RMI Runtime creates a thread to handle each request from a Client. you can bind the socket to a particular local port before making a connection to the remote server in normal socket programming. Location: http://www. This port is determined by the OS at runtime depending upon the availbility of the port. then you must ensure thread synchronization. RMI reference layer manages connection management.2. sometimes one or more of them gets an Oct 10. Am I missing something? We have the following setup: Oracle 8. .com/faq/view. S. when the client connects to the server. Atleaset on the client side.jguru.2_008.jsp?EID=430437) Question originally posed by Ganesh Vaideeswaran (http://www. both Clients A and B run in separate threads. But in The RMI server uses thin JDBC to communicate with the DB. When several clients execute the same remote method concurrently.exportObject. We've tried to synchronize the method with no apparent change in behaviour. Once the request finishes.jsp?EID=463939 Created: Jul 28. I see different ports being used between the server and the client when the server accepts a connection from the client.For most implementations.jguru.2. I am wondering if I can give a range of ports that the RMI server can use while accepting connections from a client.jsp?EID=230945). In this way. 2001 As far as I understand (and from the actual behavior) the port number of the socket that is returned by accept is the same port number as the one the server is listening to. I see that I can control the port that an RMI server listens on while exporting the server object using UnicastRemoteObject. the thread waits for a brief period for the next Client request. Windows and Linux clients running JRE 1. Therefore. the RMI Runtime destroys the thread.2_008. Comments and alternative answers Is there really a problem? Author: Gaddy Barchana Lorand (http://www. Is there a way to control the ports opened by an RMI server while accepting connections from a client. If you have private fields within your Server Class. 2001 Author: srinath mandalapu (http://www. the RMI-Connection may reuse threads.7. RMI server running on Linux or Windows NT with JRE 1.jsp?EID=450195 I don't think you can control the value of the port returned by the accept call on server side runtime. The RMI server creates a new impl-object for each client request. If no new request comes in.1.

com/guru/viewbio. at least we haven't been able to reproduce the problem.One method where we seem to succeed is one where the database call can be executed once.6. How can I do this myself with my own SSL sockets? I tried creating just one socket and .7. I call my create object method on an interface in the RMIRegistry created with Naming. it obviously keeps a stack of connections or something along those lines. So the answers are as follows: Q1: We use OracleConnectionCacheImpl. storing the result in a static variable.Rebind. and the created object is also derived from UnicastRemoteObject so it's interface can be used directly by the client.3.1 but we think it is because it is faster and we therefore got some extra time before the EmptyStackException occurs and we didn't use enough clients to have any problems. I want to use SSL.2 and 1.3. Now. Q3: We still don't know why it worked using JRE 1. I call: super(0. Oh well. Is there a significant difference between 1. This stack gets empty on 2001 Author: Pontus Strand (http://www. I get a lot of server sockets created - even some I don't use if I happen to create an object for use in the server or client internally. you learn by your mistakes :-) I have a Java app which uses RMI calls on bound interfaces to create remoteable in this case? Location: http://www.jsp?EID=249440) Question originally posed by Fredrik Duprez (http://www.jsp?EID=463940 Created: Jul 28. so I created server and client socket factories and in the constructors for all objects derived from UnicastRemoteObject.jguru.1. When not using the socket factories.3. It was caused by a bug in Oracle's thin JDBC client version 8. We probably would have found the reason for this much earlier if we had caught the exception on the server instead of on the client. Question one: Which stack is empty??? Question two: How can we solve the problem? Question three: When we changed the JRE on the server to 1. the Java RMI code internally shares its server port so that only one gets created.getConnection in our connection pool. Because I create a lot of these objects. new ServerSocketFactory(protocolname)). new ClientSocketFactory(protocolname).jsp?EID=449614 The problem has now been solved. This works fine.jguru.1.jguru.1 we haven't been able to reproduce the error. Q2: This bug seems to be fixed in version 8.2.

The communication between the RMI . but also must bear the logic to decipher the response from the server. With RMI.jsp?EID=14) Question originally posed by Matthias Suter (http://www. Are there any guidelines as to when I should use RMI and when I should prefer plain old socket connections? What are the advantages/disadvantages of each of these technologies ? Location: The amazing part is that the remote objects may be under the jurisdiction of an entirely different JVM. Also.jguru. Is there an easy way for me to exchange XML objects between the RMI client and server? Location: http://www. And likewise for the server.jguru.jsp?EID=466799 Use Java objects can easily invoke the methods of remote objects as if they were locally RMI elevates network programming to a much higher plane.having the socket factory return that one all the Created: Aug 15. 2001 Author: Govind Seshadri (http://www.jsp?EID=477124 Prgramming sockets in Java is to apply a procedural networking idiom to an object- oriented computing environment. 2001 Author: Paul Beadle (http://www.jguru. ensure that all socket factories implement the hashCode and equals methods to force correct cleanup. it appears that using the same socket factory rather than a new one for each remoteable object derived from UnicastRemoteObject ensures that RMI shares the SSL connection for all objects. but I get a java.Document is a serializable object so you can exchange it through RMI without much trouble. org.jsp?EID=260183) Question originally posed by Govind Seshadri PREMIUM (http://www.jguru. Here.jdom. running on a different host halfway around the world! Sockets-based network programming can be a fairly laborious task. Is there a way of telling the RMI system that I want to create my own server sockets but want to share them? Location: http://www. RMI automatically provides you that feature by utilizing the underlying Object Serialization which serves to define the precise byte-oriented sequence of the After further investigation.jsp?EID=479169 Created: Aug 18. 2001 Author: Bozidar Dangubic (http://www. since you interact with an RMI object much like a local object.jsp?EID=466990 Created: Aug 2. remote methods can send and receive just about any valid Java object without having to worry about flattening it out to a serial data stream.jguru.jguru. all client/server communication must be mediated by a user-defined application protocol.jsp?EID=433955) Question originally posed by sayeed sami (http://www. A client must not only be responsible for creating the message.NoSuchObjectException on the client because the server doesn't know about the object after I created it.

RMI remote objects serving as wrappers to database and legacy system integration code are also highly scalable due to the inherently distributed nature of the technology itself.jsp?EID=488301 Created: Aug 31. like RMI. which uses XML. Soap works on the request/response model of making remote procedure calls. SOAP.jguru. RPC.jsp?EID=14) Soap (Simple Object Access Protocol) and RMI are entirely different technologies. They also do not suffer from the latency issues due to object serialization and are easily integrated through corporate firewalls. see the excellent Javaworld article by Jeff Wilson. forms a valid SOAP XML response and sends it back over HTTP or SMTP.client and server itself is facilitated by the Java Remote Method Protocol (JRMP) or Internet Inter-Orb Protocol (IIOP). However there are some similarities. you will also have to take care of multithreading issues within your server. a smart proxy is more useful than the RMI stub in that you can change the behavior of the remote interface to do more than forward calls to the remote object. instantiated in the client VM. and RMI What are smart proxies? Location: invokes the requested method with any supplied parameters.jguru. see: A closer look at SOAP. parses and validates it. For more details. 2001 Author: Govind Seshadri (http://www. The server picks up the SOAP Created: Aug 31. 2001 Author: Govind Seshadri (http://www. For instance.jguru. that holds onto a remote object reference.jsp?EID=14) A smart proxy is a class. How does SOAP compare with RMI? Location: http://www. The client program forms a request which consists of a valid SOAP XML document and sends it over HTTP or SMTP to a server. RMI is especially useful for deployment as a multi-tier bridging mechanism. just like an RMI stub. For a good paper comparing SOAP with RMI. It implements the object's remote interface and typically forwards most of the calls on the interface to the remote object. Get smart with proxies and RMI I am using RMI. allows you to make an RPC on another machine over HTTP or SMTP. There is no doubt that programming low-level sockets enables your client-server applications to be much more efficient in their conversation. The RMI client is available to any application that needs to store objects in the object database. compared with RMI applications. is language independent. RMI is Java-centric. a smart proxy can locally cache state from the remote object to avoid the network overhead on every method call. Unlike RMI. However. whereas SOAP. But this comes at a cost of your programs being much more difficult to develop and and can serve as an effective "glue" for integrating other enterprise Java technologies like JDBC and JNI. where the client is in Windows 2000 and the server is in Linux. I have an object database at the RMI server for storing When I store a class it gives a .jguru.

codebase system property.jguru. regardless of the client. The ClassName is the object that has to be stored. That's the reason for the ClassNotFoundException that you're getting. etc. The hitch is that my RMI client will be used by many application to store objects in the object database and I can't put each object what they store in the server side. The RMI client developed by me is supplied in a jar file. Mar 31.jsp?EID=818963). here: • Try to use built-in types for all the objects that you are sending over RMI (like Vector.ClassNotFoundException:ClassName(no security manager: RMI class loader disabled) at the client. • Have a central repository where all the class files can be found. When the server tries to de-serialize the object. physically. this is what i did for a program i am working on . 2002 one easy way to solve this problem is to have the client set the java. Comments and alternative answers dynamic class dl Author: Alex Field (http://www.jguru. turning the client into a class file server.rmi.jguru. it works. But when I put the ClassName at the server end.server. This is a hard problem to you don't have to worry about the clases being there. then the server can download client class files from the codebase if it cant find them locally because the client will annotate the codebase to all objects it sends. The ClassName is in the CLASSPATH of the client. Is there any way to overcome this? Location: just serializes it. • Ditch RMI altogether.class file in the server. and why it clears up when the server has that class file.jguru. it must have the class definition. 2001 Author: Christopher Schultz (http://www. Then. which includes nothing but the data. the RMI mechanish doesn't send then class file with the object .jsp?EID=320017 When you push/pull objects over RMI. and still requires you to figure out how to represent your objects without using their original class definitions.jsp?EID=502971 Created: Sep 24. Clients will have to send their class files to that central repository before using your RMI server. This is usually hard to do. Hashtable. I wish you good i. Have the server turn around and connect to the client to download the class explicity store the ClassName. • Have each client bind itself to a local socket. You have several options.e.).jsp?EID=138382) Question originally posed by Brijesh Kumar (http://www.

and ClientSocketFactories seem to be straight forward but how could I specify .jsp?EID=101985 I hope this will clarify the concepts and it will answer your question: Java RMI is just a set of APIs and a model for remote objects for building distributed applications. Jan Garbagnati ( I am trying to run RMI over a SSL connection.jsp?EID=502975 Created: Sep 2002 I guess the original question asked here was: Is RMI protocol and JRMP protocol two different names for the same protocol or these are two different protcols ? ie in other words one of the way to invoke remote object is rmi://host/object and the questions is that is there any thing like jrmp://host/object ? Re: Difference between RMI and JRMP protocols? Author: bill clinton (http://www. Another example of a transport protocol used by RMI is IIOP (Internet Inter-ORB Protocol). which will serve any client which extends the remote interface provided.jsp?EID=710659). JRMP is one transport protocol that is used by RMI to transfer data across the network. normally there're two protocols available for RMI. hope that is helpful (and correct!) Alex Is there any difference between JRMP (Java Remote Method Protocol) and RMI? Location: http://www.jsp?EID=729472). The Server. Comments and alternative answers Difference between RMI and JRMP protocols? Author: Arun Sethi (http://www.jsp?EID=32727) Question originally posed by Luigi Viggiano PREMIUM (http://www. 2002 RMI is not a protocol. one is JRMP. 2001 Author: Alessandro another is RMI-IIOP.jguru. The original version of RMI uses a combination of Java serialization and the Java Remote Method Protocol (JRMP) to turn local method invocations into remote method invocations. which is compatible with CORBA. which is language dependent. Jan 5.jguru.jguru.

com/guru/viewbio. e. so to create the server socket for this object I need a KeyStore. but as I haven't implemented this yet I will reserve judgement.jsp?EID=505561 Created: Sep 27. I want to use it for further authentication.jguru.. so no sweat.jguru.jsp?EID=488125 I am not exactly sure of why you would want to pass the key pair to the I want to pass them dynamically.. and finally register the callback object with the server. with J2SE The JSSE example would work. Using this method I believe you could use randomly generated certificates to send to your clients and add these on the fly to the servers (transient)truststore. but I would be interested to receive any commments. Location: what keypair to use for the SSL connection. That means I can't just load the keys from a static key file. compare it to a presented X.rmi. The reason for this clunky inelegant solution is the current server interface expects the client object as a parameter of the login/authorization method. Currently I am requesting a KeyStore from the client using an https URL connection to the server which opens a keystore file in my webstart server and loads it into the client. Can I log the client-side remote calls of an RMI client? Location: http://www. I reckon this approach is as secure as I can make it..jsp?EID=455365) Question originally posed by Markus Lorch (http://www. you can now log client-side remote calls and exceptions of an RMI client by setting the system property sun. 2001 Author: Sandy McPherson (http://www. which means that you don't have to hand out any sensitive data.509 certificate.jguru.jsp?EID=503552 Created: Sep 25. What I need to do is to make this a four phase operation: first authorize the client via a login. I have a client callback object which is using SSL. As the client is loaded via Java Web Start I don't want to interfere with the plug and play by requiring the client's user to configure keystores and truststores. But is there a way to later access the public-key that was used by the client to set up the secure communication. at least to the client.when I request a remote object.client. You can also now control the granularity of the logging mechanism . create the callback object using this Keystore as the source of the server certificate. then request a Keystore object from the server (storing this as a transient object in the client).jsp?EID=14) when starting up your client. 2001 Author: Govind Seshadri (http://www.g.4. On the server side the key pairs can be loaded from disk. but I guess your situation must be similar to my own.jguru.

I am using String datatypes here. Otherwise.jsp?EID=510444 Created: Oct 3.3. 2002 Hi. 2002 I am using JDK 1. that's true only with RMI systems prior to JDK 1.jsp?EID=738215).8 and it is found that it can send data which is larger than 64K. Regards. the server would throw a java. Jan RMI For example: in a Vector.jguru. 2001 Author: Raymond Blum (http://www. where you cannot serialize a string greater than 64k. JDK do keep mind that for this to compliant.html Is it true that I cannot send data greater than 64K between an RMI client and server? Location: http://www. But the the performance of the system is very slow. since the serialization protocol has been enhanced with JDK 1. if your.3.jsp?EID=505569 Created: Sep 27. see http://java. Is there any size limitation when you use RMI for transferring files. you should now be able to serialize strings greater than 64K.jsp?EID=131288) .through additional properties. Is there anyway I can improve the performance ? Can I use Swing components within RMI? Location: http://www. For say. Feb RMI server tried to read serialized data greater than 64K sent by a JDK 1.sun. Is there any maximum upper limit for String datatypes ? Can we send data > 64KB that are not String datatypes. both the client and server JVMs need to be JDK 1.StreamCorruptedException.jsp?EID=14) Yes. You would have a java.jguru.UTFDataFormatException thrown if you tried. 2001 Author: Govind Seshadri (http://www. Comments and alternative answers Is it true that I cannot send data greater than 64K between an RMI client and server? Author: Amit Kushwaha (http://www.1. Amit Re: Is it true that I cannot send data greater than 64K between an RMI client and server? Author: Ashwath Krishnamurthy (http://www.jguru.

4.setSocketFactory(new sun.e.cgi does not seem to be installed anywhere.jsp?EID=1093723). you need to configure the call forwarder program running at a specific url (i. my_server = (MyServer)Naming.jguru.jguru.rmi.RMIHttpToCGISocketFactory()).RMIHttpToCGISocketFactory as your default ClientSocketFactory and set it as RMISocketFactory.jsp?EID=507902) Question originally posed by Neeliagari Sreedhar (http://www. 2003 After installing j2sdk Do you mean to pass Swing Components as parameters to remote objects using RMI? If so.proxy. there are workarounds such as [implementations of] ListModel which can be "disconnected" from any reference to a JList and then passed to Remote objects.transport.transport. Where should I find it ? Where can I get a copy ? A client I've written is trying to connect to a server that resides on another machine. Is there any way by which I can force RMI invocations to always tunnel via HTTP? Location: http://www. the java-rmi.jguru. Jun 13.Question originally posed by Prashanth Katamaneni (http://www.lookup() call in the client I'm getting a ClassCastException: For some Swing & AWT related classes. To force http-tunneling you have to create a MyServerImpl_Stub This is the code in question: MyServer my_server = null.1_01 and jwsdp-1. you are probably out of luck as most if not all of them are not directly Serializable. 2001 Author: Christoph Dittberner (http://www.rmi.jsp?EID=525738 Created: Oct 20. //exception thrown here . String name = "//121.jguru.cgi which in turn "unwraps" the RMI call and forwards it to the appropriate remote object making the remote invocation. The server is an implementation of the interface MyServer. and is called MyServerImpl.proxy.2 with Tomcat and using both successfully (j2sdk for years !) I wanted to implement RMI tunnelling over http. During the Naming.jguru./cgi-bin/java-rmi. However. After that all RMI calls are encapuslated via a HTTP POST request and forwarded to the CGI program name ).42/MyServer".cgi Author: David Gradwell (http://www. Comments and alternative answers Where is java-rmi.0.jsp?EID=507745 Firstly.

Is it mandatory for me to instantiate a security manager within my RMI server? Location: http://www. Anyone have any ideas why it's not working? Location: http://www.jguru. 2001 Author: Govind Seshadri (http://www. Why? Location: http://www.jguru. same java version. 2001 Author: Govind Seshadri (http://www.jsp?EID=532475 Created: Oct 29. You might want to restart the client. and there *is* a stub being returned from the lookup call.jguru. server and rmiregistry and see if it clears things. the only thing that's different is that the server is Solaris 8. That means i am trying to invoke remote method on server side by object of interface object. this should work. I took the compiled RMI STUB and SKEL files from the server and replaced the corresponding files on the client machine with but when i am running with inly one method invocation then program is runnung successfully but it gives me Exception ClassCastException when i am trying two remote method invocation simulteneously from the same 2001 Author: Matt Senecal ( 2005 I have the same problem but only when i am trying to invoke two rmi methods from the same machine. Apr but apparently there's a disagreement between the stub being returned and the variable used to hold it.jsp?EID=464625 Here's how I finally solved this.I've checked. From what I can tell. I am suddenly seeing and the problem vanished! Interesing. Same code. i want that porblem's solution.jsp?EID=14) It is not mandatory to set a security manager for the use of Java/RMI.jsp?EID=532767 Created: Oct 29. Comments and alternative answers on ClassCastException Author: vaidehi saheba (http://www. The server is up and running on the other machine.jsp?EID=14) The most likely reason is that some of the of the classes may have been modified and recompiled while the RMI application was still If the security .jguru.jguru. The reason to do this is so that the Java/RMI client can handle serialized objects for which the client does not have a corresponding class file in its local CLASSPATH.lang. and was compiled from the same code that the client is referencing. in my RMI application that was previously running fine. and the client is Win 2000. Then I re-ran the client.jsp?EID=1241829).jsp?EID=532690 Created: Oct 29.jsp?EID=464625) Question originally posed by Matt Senecal (http://www.jguru.

jguru. handling transactions and object pooling and more. since there are simply more things to check and handle compared to plain RMI where no such functionality exists.jsp?EID=41777) Question originally posed by Sashi Reddy ( object pooling.jsp?EID=32727) Question originally posed by Omar Khan (http://www. RMI is used in this framework as the mechanism for object distribution.jsp?EID=232689 Omar. if required. as it allows the server to generate subclasses for any Serializable object and provide the code to handle these subclasses to the See http://www. "marshalling" refers to the process of converting the data or the objects inbto a byte-stream.execpc.jsp?EID=395494 EJBs are (as I am sure you are aware) a framework for distributed components. The purpose of the "marshalling/unmarshalling" process is to transfer data between the RMI system. as long as the client has access to definitions for all objects that might be returned. In few words. What is the meaning of marshalling and unmarshalling? Location: http://www. the client can download and instantiate class files from the Java/RMI server. 2001 Author: Mikael Jakobsson (http://www. This mechanism is actually fairly important to Java/RMI. An EJB application server adds more to distributed components than RMI does. performance-wise. .jguru.jsp?EID=568006 Created: Nov and "unmarshalling" is the reverse process of converting the byte-stream beack to their original data or object.html for more details. What is the case for RMI? I used to do RMI before the EJB Created: Nov 25. 2001 Author: Alessandro A.manager is set to the RMISecurityManager.jguru. The application server will handle transactions. It is entirely possible to use Java/RMI without setting the security manager. The conversion is achieved through "serialization".jguru.jguru. Garbagnati ( This extra functionality comes at a price. disadvantages etc of both approaches ? Is there any difference as far as performance is concerned? Location: http://www. Java/RMI's ability to handle the passing of any object at any time using Serialization and class file download is possible only because the JVM provides a portable and secure environment for passing around Java byte codes that form the Java executable from which Java objects can be reconstructed at run-time. Can we not do everything we want to with RMI probably with a stateless session bean? Why would one use RMI instead of a stateless session bean? Can someone tell me the advantages. database connection pooling and more.

• The reason for using RMI instead of sockets is often that it is so much easier to distribute components via As Application server comes into picture its adds up the Cost and Overhead.Stateful) bean can run forever in the background regardless of Client connecting. There is definitely some extra milliseconds to spare there too. I think that there is no "correct answer" to this issue. then you have to go for RMI Solution. 2003 EJB makes the work for programmer easy as application servers gives some services to the components such as Pooling . Security & Transaction. which is an important parameter in many projects . the pure RMI solution will probably be the best solution. So if your priority is performance. 2004 When you need a Server which will run in background doing some task as periodically apart from serving clients (like Scheduler). due to the overhead introduced by the application server. The same holds true for the EJB vs RMI discussion. Such generic code needs to perform more checks and needs more layers of logic to handle almost any possible type of problem. since it is likely to be optimized for the problem at hand. If you DO need some functionality that is provided by the application server it is much simpler and quicker to use the existing EJB framework than developing your own functionality for common problems such as DB connection pooling. where any Bean (Stateless.Therefore. Apr when it comes to comparing performance.jsp?EID=1080478). The EJB framework is a generic framework that can handle most cases where distributed components are desired. Using the EJB framework is many times more cost-effective. Comments and alternative answers EJB vs RMI Author: Santosh Kumar (http://www. These checks and extra layers will introduce some performance overhead. The decision to go for EJB/RMI Frame Work/Socket Programming should be based on requirement and accordingly programmer/architect takes the decision. .jsp?EID=1160292). Apr 5. There are at least two ways to look at this: • The "Pure RMI" solution would probably be faster. but I hope the above has added some input in the debate on where and when to use what technology.jguru. EJBs can only be slower than a similar construction using RMI directly. To take this to the extreme you could save some extra performance by skipping the (generic) RMI framework and go directly for the Sockets. Background Servers Author: Rajarshi Mukherjee (http://www.jguru. The development time is simply much shorter if RMI is used. Q: But what if you code all the extra functionality yourself? A: That depends on what your priorities are. I am not aware of any situation.

I am getting an : "java..jguru. As well.jsp?EID=568019 Created: Nov 30.jguru.jsp?EID=433624) Question originally posed by Asif Akhtar (http://www.give the path to ur jdk/bin in a more prominent position(at the beginning)and <start rmiregistry> from the location where u have ur class files.jsp?EID=546111 You need to run rmic and recompile those stubs and skeletons every time you add/delete/modify a method within your remote interface.UnmarshalException: error unmarshalling arguments. 2001 Author: ryan wexler (http://www.. a service might have a separate thread running to measure are decisions a programmer or system administrator must make.UnmarshalException: error unmarshalling arguments.I made some changes to my remote interface and recompiled the When this thread determines that the object is idle.. the driver script loaded an old rmiregistry which was in a more prominent position in the PATH. Dec 14. Jan depends on the situation. 2002 StockMarketImpl Market = new StockMarketImpl( "NASDAQ").. " Why? Location: http://www.jguru. this shud fix it! Re[2]: Error like this but it apear after first compilation Author: Yu Limin (http://www.inactive(activationID) to inform the object's activation users&F=&S=&P=17995 I am trying to do something using RMI Activation and I read an article discussing RMI activation in which the author said: "There is no standard way to measure whether an object is "heavily" or "lightly" For nested exception is: May be errors core in the settings of CLASSPATH? Re: Error like this but it apear after first compilation Author: bijoy jayachandran (http://www.sun. Nov 2.rmi." . Now.rmi.jguru.RemoteException: java.rmi.jsp?EID=1208774).jsp?EID=1216388). it calls Activatable. even if objects are rarely used but the server they're running on has a light load. 2004 http://archives.jsp?EID=719128). to fix it . it would make no sense to deactivate these objects. 2004 The reason. Comments and alternative answers Error like this but it apear after first compilation Author: Yuriy Chumak (http://www.

gc() after setting some objects to null. then method X is being used 1000 times per then we call inactivate().jsp?EID=568075 Created: Nov 30. That is -- not a field within the _impl Class. then those object will never be garbage I get a java. I tried to use System. 2001 Author: Edward Harned (http://www.lang.jguru.OutOfMemoryError.jguru.But i just want to measure whether an object is "heavily" or "lightly" used . Is this heavy or light? It depends on the after executing the same method for a number of times.jsp?EID=539646 Our company uses the activation framework.jguru. Is there any way to close the present server and create a new instance before the method returns? Location: http://www.jsp?EID=388091 If the threads you created have a reference to the objects used to save data. However when the remote method returns. When no method counters are greater than the last time the thread ran. If you pointers on using persistent storage.and even how many times the methods of the object is called. We have a daemon thread that runs every n-minutes. But how do I measure performance and how to communicate with the RMI Activation System? Any suggestions would be appreciated highly. a service might have a separate thread running to measure use.jsp?EID=240325) Question originally posed by Panos Koup (http://www. . It looks at each RMI method counter to see whether each counter is greater than the last time the thread but with no luck. Is the ActivationMonitor interface in RMIActivationSystem is helpful here? the author also said that "For If the time is one minute and method X counter is 1000 greater than when last the thread ran. 2001 Author: Edward Harned (http://www. Each RMI method increments a counter of times used in persistent Every time my remote method is executed.". the memory allocated for these objects and threads is not freed. As a result. Location: http://www.jsp?EID=568091 Created: Nov 30.jguru.jguru.jsp?EID=240325) Question originally posed by f qf (http://www. hop on over to developerWorks and read the RMI Server Framework article: it creates a number of threads and an equal number of other objects used to save data.

jsp?EID=63013).com/faq/view. ResultSet rs = st. The RMI Runtime reuses the RMI-Connection thread on subsequent remote invocations so any objects the thread creates remain alive as well as any threads created.jsp?EID=592454 Created: Dec 20.jsp?EID=336747 Look. As in Connection con. and want to return ResultSets VIA RMI back to the Client. Which is serializable . 2001 Author: Benoit Quintin (http://www. You must solve the storage problem. You have a design flaw somewhere and this is where Java tools come in handy. so u can send RowSet object . I would be grateful if somebody could give me an example of this. Comments and alternative answers JDBC RowSet Author: V S N Murthy Boggavarapu (http://www. If the threads you created do not end. Statement st. You are right. while(rs.return in the run() the threads you created explicitly set their reference to the objects to null and the RMI-Connection thread sets its references to the objects to null.jguru. then there are no more references to the object and it is subject to garbage collection. that is -. a resultset really doesn't make ANY sense once serialized out of the JVM it was created in. Dec 21. then you will keep creating more and more threads until you finally run out of resources. There are products on the market to display memory and object usage (like JProbe).next) { v. I have read that this can't be done (But it can be got you could go through your ResultSet and Return a Vector).jguru.NO. Location: http://www. I Have a server that access a database via JDBC.jguru.jguru. As far as close the present server and open a new one -. 2001 Use RowSet instead of ResultSet. going through your resultset and adding it to a Vector is a decent way of doing it. as far as I understand Vector v = new Vector(). Better yet if there is some way of passing the ResultSet Back.jsp?EID=394478) Question originally posed by JavaDB OOP (http://www. } then close your resultset and serialize the vector. I tried making the ResultSet serializable but that didn't"query here"). Look here on JGuru or go over to JavaWorld for a list of tools.add(rs.getXXXXX).

which is void .jguru. Location: May 19.will the Client know this from the stub it gets from Registry that its not getting anything in return? 2. your logic would be entirely correct.jsp?EID=2011) Generics and Method Objects is an excellent source for information on how to use "Generics" with Java Can I use compression to improve RMI performance when transferring large datasets between the client and server? Location: http://www. I started working on RMI recently and this particular concept is not clear to me: 1.html and http://www-106.Or the Client thread will finish sending what it has to send to Server and free that thread to do something else. It does not seem necessary for the Client Thread to be blocked even when there is no return data from Server. You can see a detailed discussion of issues and patterns in this at http://www. I'm fairly certain (though I haven't tried it) that if you truly want asynchronous communication. and returning . More information on "Generics" can be found at Generics and Java.jsp?EID=592455 Created: Dec 20. over network . Re: JDBC RowSet Author: ariel javier ( 2005 can you give some lines of code on how to use need not convert it into Vector. If it weren't for that issue.jguru.When the client invokes a remote method. 2001 Author: Govind Seshadri ( 2001 Author: Dave Bucci (http://www.jsp?EID=553775 I believe that the call is synchronous because the client must be prepared to receive exceptions back. RowSet is in package so then will the Client thread still wait for some kind of Ack from Server before it could do something else 3.jsp?EID=580534) Question originally posed by Sandhya Nagamangala (http://www. your server object can cause that to happen by creating a thread to perform the processing. 2001 Author: Davanum Srinivas (http://www.jguru.jsp?EID=701493 Created: Dec How can i use Generics to improve my Java RMI programs? Location: http://www. which may be thrown at any time throughout the server object's Created: Dec 28.

zip. Registry r = 2002 I got same problem. you should be able to use the ZipInputStream and ZipOutputStream classes within a custom socket factory to give you a new socket type that transparently compresses data.. You have to use either of the below constructors for your .jguru. Re[4]: java. so use ServerImpl server = new ServerImpl().ZipException: no current ZIP entry Author: Bill Zhang ( For a tutorial on how to do this. Aug 30.ZipException: no current ZIP entry Author: Antony Cook (http://www. Naming. see: http://www. 2002 The instructions on compression for RMI input/output doesn't seem to work.jguru.jsp?EID=455721). when you construct your ServerImpl. Mar you're NOT making use of the Zip Socket. 2003 By using the default constructor.Yes. 2003 me too.ZipException: no current ZIP entry Author: David Duran ( Mar 14..util. 2003 thanks to a colleague that pointed this out.rebind("//localhost:1090/ZipServer" Re[2]: java. Registry r = LocateRegistry.jsp?EID=991814).ZipException: no current ZIP entry Author: Antony Cook (http://www.html? Comments and alternative answers java. NOT ServerImpl server = new ServerImpl(SOME_PORT).com/javaworld/javaqa/2001-12/01-qa-1207-ziprmi. Is anyone else getting this problem? Re:"//localhost:1090/ZipServer".server).ZipException: no current ZIP entry Author: Ben Chen (http://www.util.jsp?EID=784979). including sample code. Mar 26.server).zip.javaworld. don't use the constructor that takes the port number.createRegistry(1090).createRegistry(1090). Anyone found out how to get this to work ? Re[3]: java.jguru. use the default constructor. I get a no current ZIP entry when running my client application.util.jsp?EID=1066177). Mar 6.

Unicast/Activatable objects respectively, in order to use the the custom
socket factories.

Note that passing 0 in for the port number is the same as calling the no-
arg. constructor. It will just use an anonymous port.

UnicastRemoteObject(int port, RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)
Activatable(ActivationID id, int port, RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)

In other words, this problem doesn't seem like it's been solved yet :)

WebLogic implementation
Author: David Toyer (, Nov
18, 2003
Any idea how I would do this in WebLogic. It's implementation
UnicastRemoteObject does not support the constructor being used in the example

What changes do I have to make to my existing RMI program for it to use
Created: Dec 28, 2001
Author: Govind Seshadri (

Sun has come up with a fairly good cookbook approach for converting existing RMI
programs to use IIOP. See
iiop/rmi_iiop_pg.html#Convert. Also, note the Restrictions When Running RMI
Programs Over IIOP section.

What is PortableRemoteObject.narrow() method and what is used for?
I found somewhere that it is "CORBA compliant". Why?
Created: Jan 25, 2002
Author: Alessandro A. Garbagnati
( Question originally posed by
Sarvotham.Pai. Hosdurg (

When you execute a lookup to get the home interface of your bean, you normally use
the lookup() method of the javax.naming.Context interface.
This method will return you an Object that needs to be casted to the home interface
you've asked for. Unfortunately, this cannot be done using the normal/explicit casting
[MyHome myHome = (MyHome)returnedObject].

As you have already found out, the reason is connected to CORBA. Why?
For EJB, the communication between the server and the client is based on RMI (both
remote and local interfaces, in fact, do implements the java.rmi.Remote interface).
The underlying protocol that it is used for the communication is IIOP (I think 1.2),
that is part of CORBA standards. It is normally used to describe this communication
system using the Java RMI over IIOP.

IIOP has not been designed for Java, but for generic languages, and this means that
there are some limitations. Some languages, in fact, do not have the concept of
Java RMI-IIOP provides a mechanism to narrow the the Object you have received
from from your lookup, to the appropriate type. This is done through the
javax.rmi.PortableRemoteObject class and, more specifically, using the narrow()

Just a note: when you are using the new EJB 2.0 Local Client API, you should be able
to do a direct/explicit cast from the looked up Object, to the interface you need.

Comments and alternative answers

without Narrow Method
Author: Sudhir Sharma (, Jan
21, 2003
I hope that if we don't use Narrow method to cast the
object, it will work. In Ejb 2.0, it is possible to
cast the object as we cast it in Java, if we are using
Local Home and remote interface. But I hope in ejb 1.0
and 1.1 also, we can use direct casting over lookedup
objects. Please clear me this thing if it is essential to use Narrow() method to cast the

Author: Deepak Kalra (, Mar
10, 2004
Since Remote and Home interface implements java.rmi.Remote interface. ThE calls
to these interface will be remote calls and Most of the conatiner use IIOP as
communication network protocol and IIOP is CORBA standard. So we have to use
narrow method of PortableRemoteObject as Its define as the standard of IIOP.Normal
cast operator will not work as Application server use IIOP protocol

Author: Kacel Kacel (, Apr
11, 2004
The spec says to always narrow. If your ejb server (container) doesnt serv IIOP on
wire , then the usual cast should work BUT your client code wont be vendor
independent. Deploying, again, your ejb on an IIOP server, yhis time, will break
your clients (without narrow). Think narrow instructions as portable condition for
your bean, and think that your client is not always written in Java.

Author: Suresh Subramanian
(, Feb 11, 2005
I have seen a single application using both normal java casting and narrowed
objects. In this application all servlets use normal casting to lookup ejbs and ejbs
use narrow to lookup other ejbs like client java command line applications. Is
there a specific reason to have this difference in approach? I want to know the
difference. Please explain Thanks Suresh

How do I transfer a text file from server to client? I am trying to transfer a
text file from server to client using File objects. but i am not getting
success. so how can we transfer a text file without going into the Socket
programming and streams.
Created: Jan 30, 2002
Author: gunther van roey (
Question originally posed by sameer mohta

In Java, a File Object simply represents a possibly existing file on the file system.

If you create a file object like this:
File f = new File ( "c:\\test.txt" );
and the file "c:\test.txt" doesn't exist, this will throw no exception (but f.exists ( )
will tell you so).

If you want to work with a file's content, you'll ask an InputStream for it, and only
then you'll really access the file.

What you can do to solve your problem, is to read the file on the server side, store
it's content (in a String, byte array, or whatever ...) and pass the content to the

This has to be done, because the remote machine can't access the local machine's
file system.

This can be implemented by putting a method in you remote interface like this:
byte[] getFileContents ( String fileName ) throws RemoteException;
if you then implement this method on the serverside and return a byte array, you
can write a new file on the client side, or keep the data in memory, according to your
needs ...

I am trying to run a server (say a Apache Server or a tomcat servlet
engine)on a remote machine using RMI for which I utilize the capabilities
provided by the java.lang.Runtime class.When I execute the command I
would like to show the results of the process to the user and at the same
time I would like to specify whether the server has started successfully.For

jguru.jsp?EID=761813).com/faq/view.jsp?EID=733188) Question originally posed by Sudhakar Santhanam ( (this is a limitation to the concept of RMI). (If you search the RMI-user archives at java.createRegistry(int port) method... 2002 This is now http://crazybob. Dec 16. Is there a suitable way to show the process messages to the user and at the same time specify whether the process was started successfully.jsp?EID=710858) Question originally posed by yogesh dhake (http://www.jguru. If you run apache or something. these can not exist multiple times in the same VM. http://crazybob. 2002 Author: Bob Lee (http://www.jsp?EID=741015 Created: Jan 30. .com/guru/ Comments and alternative answers File Moved Author: Bob Lee (http://www. I get the exception "Exception in Edit the "runtime.jguru. Location: http://www.jsp?EID=561986 I wrote a RemoteRuntime server geared at just that. you'll find a more detailed explanation).com/faq/ I have a problem with the LocateRegistry. As a side I preferred to get the input stream of the process buffer it and read it.jsp?EID=741019 Created: Jan 30. Since RMI needs to have a few objects with a known Object ID for allowing clients to find the Registry.because the input stream of the process has not ended.jguru. the call to the RemoteRuntime does not return until the process has completed.policy" file to tighten/ease the security restrictions.when I try to read the stream I am unable to come out of the loop. 2002 Author: gunther van roey (http://www. The registry starts of fine with no problem with the first passed port number but later if I try to start the registry again with another port number.createRegistry : internal error: ObjID already in use" Kindly let me know the solution Location: problem now I am facing is . make sure it's set up to return the results and fork another process so that the first can return.jsp?EID=706734 The problem is that there can be only one RMI registry created in a Vitrual Machine.

com/guru/viewbio.jguru. Comments and alternative answers Multiple servers per rmiregistry Author: Trevor Stokes (http://www. if we don't want to extend RemoteObject via UnicastRemoteObject.exportObject ( this ).com/guru/viewbio.jsp?EID=731298 If you extends this class.jguru. You R Right.export() Author: Gundu Venkata Chala Bhaskar ( Apr 22. 2002 Author: gunther van roey ( Question originally posed by viswanath r (http://www. Why should my remote object extend UnicastRemoteObject? Location: http://www. Can someone bother to explain that Re: about overriding equals() and hashCode() methods when using UnicastRemoteObject. typically via .What you can do is start one RMI registry from within your application with LocateRegistry.createRegistry. 2002 I have a related question.jguru.We need to implement the hashCode(). Am I correct in stating that only one server can communicate with one rmiregistry? In other words. Jul If your class is already extending another class.jsp?EID=742049 Created: Jan 31.jsp?EID=849009).export() Author: karthik Guru (http://www. Comments and alternative answers about overriding equals() and hashCode() methods when using UnicastRemoteObject. a second server would have to start and bind to an rmiregistry running on a different port? I know that the one server can register many names/objects. 2002 i guess i need to take special care and provide implementations for equals and hashCode if i use export() static method i guess. and start one or more other RMI registries externally (on the command prompt with 'rmiregistry').jguru. or you just don't like extending from UnicastRemoteObject.jsp?EID=1025802). Objects that require remote behavior should extend RemoteObject. 2005 Hi.equals() and toString() methods. Nov your object will be automatically exported for RMI access. you can also do the following: UnicastRemoteObject.

Essentially. Where can I find a complete example of using RMI in applets? Location: http://www. In EJB we use Home interface which is not avaliable in RMI.jguru. In RMI we dont have any concept like home interface.jguru.4. please visit: http://java.why we particularly go for Home Interface Both RMI and EJB are distributed applications.V.jguru.jsp?EID=740621) Question originally posed by sam pitroda (http://www. and toString methods inherited from the Object class. RMI is a lower level technology that allows java objects to be distributed across multiple you seem to be comparing RMI and EJB as if they were the same type of technology and they are definately not.jguru.jguru. There must be several reasons for using Home Interface of EJB. can any one give reason for this? Location: http://www. Edwards book: 2003 Author: Edward Harned ( I want to connect a jini service to a rmi client. Having said Location: http://www. It is a framework that allows you to build enterprise applications by (among other things) abstracting Created: Mar 19. the answer to your question is the RMI abstracts sockets and inter-JVM communications. Home interfaces act as factories to create session . 2002 Author: Jason Rosenblum ( Please tell me how to do this as I have to complete my project.jsp?EID=1055376 Start by reading Dr.jsp?EID=1057310 Created: Feb 16.jguru. database access and concurent processing.jsp?EID=1081979 Created: May 5. The home interface is EJB's way of creating an object. equals. 2003 Author: Nick Maiorano (http://www.html Sun provides one in their Getting Started with RMI guide.jguru. If UnicastRemoteObject is not extended.jguru. the implementation class must then assume the responsibility for the correct semantics of the hashCode. For further information. is a technology built atop of RMI but does so much more than allow java objects to be distributed. on the other hand.jsp?EID=1075172 By posing this question. so that they behave appropriately for remote objects. EJB.html why we use home interface in EJB.jsp?EID=780589) Question originally posed by vishnu rajan t k (http://www.jsp?EID=240325) Question originally posed by ahsan askari (

.No creation of object takes place. Sun and IBM have both studied carefully the usage patterns on the servers and built agressive optimization strategies. 2003 RMI is basically used to serve the distributed object same as EJB. Although EJB originally started as a technology for remoting. TO get the EJBObjectref we call the create method which requires home interface because of EJB Object Author: Deepak Kalra ( laurent just want to add Author: Shashank B (http://www.. leading to faster intra-VM In recent years. taking care of synchronizing memory and database when necessary. You would have to create it yourself..jguru. I do believe that the real defining feature of EJBs is the life cycle management provided by the application server.but the main difference is RMI serves only one object which is registered with RMI registry. cheers. These factories are provided by the application container and take care of many low level details.whereas in EJB we use the object from factory/pool. and therefore made use of RMI for containers implementations.jsp?EID=1152019). Dec 16. the JVM itself has received many improvements in the area of memory management and garbage collection.jguru. Marc Fleury (the vibrant voice behind JBoss) recently published an interesting white paper about the optimizations built into modern EJB containers. the technology has now outgrown its original intent. Comments and alternative answers more EJB/RMI Author: Laurent Mihalkovic (http://www.0. Jun The introduction of local interfaces geve EJBs a boost for situations where remoting was not necessary. Since RMI is a lower level technology. The paper is really interesting.jsp?EID=407112).jsp?EID=1134131). 2003 couple things. it does not offer the home interface. as well as an interesting view (I happen to share it) that with the flexibility introduced by CMP 2. These caches keep the raw database data in a format directly usable by Java code.jguru.beans and entity beans. Mar .. In view of this departure form the remoting nature of EJBs. EJB containers are rapidly becoming elaborate caches.. and it gived an interesting glimpse at what modern technilogy based on dynamic class instrumentation has in store for the future of EJB containers.

2004 Well We Know Client invokes the method on EJB Object rather than on actual bean an instance of an object will be created and assinged to the client through which several business methods will be invoked. and one to call "create". and return with the ejb object .one to get the home stub.e. To be more meaningful and generic. Oct 18. In the case of session beans creation is a must.our lookup could do the lookup+create on the server side.. in order to get the reference of EJB object and container services Re:why we use home interface in EJB.jsp?EID=1205091). Client use Home Object i.jsp?EID=449849).jguru.L. Now to get the reference of EJB Object. this could be implemented on the server . I have a related question Author: efrat n (http://www. I think the authors of the EJB specification seperated the Creation from Lookup .why do we need the 2 separate steps? do we ever use the home stub for anything but "create" (or find)??? Thanks Re: I have a related question Author: Praveen Dunna (http://www. lookup the Home Object through JNDI.jguru.jguru. Oct 13.So we write a Home interface in EJB to provide this information i. So this way we use Home interface in EJB. 2004 Why can't the creation of the ejb (create()) be called on the server side? instead we have to make 2 remote calls . create method in home interface In RMI we do not have any concept of conatiner services and in EJB.T (http://www. So lookup need to be seperated from creation. Jun 28. container use the EJB Object to provide all the services like transacion. 2004 In the case of entity beans . Author: Ram V. RMI is used for method invocation.e. Now to give the reference of EJB Object.10.. Home Object should know How to initialise the Object and Home Object Class is provided by the conatiner. i.jsp?EID=142919). 2004 It can be said that EJB is an advacned version of RMI.. security find methods are used apart from create. EJB is object invocation..