Stateful RMI server object
How do I design and write stateful RMI client/server applications?
I just find the examples on the Web that introduce RMI with some sample RMI client/server programs which are stateless, that means the RMI client and server do not maintain session information.
I would like to design and write stateful client/server applications with RMI, i.e. a new instance of server object is invoked to handle a client Java applet connection session, and maintains state/session information such as security context in the server instance's local variables.
Is that possible? Where can I find sample programs and design guidelines for this topic??
I suggest that you approach this slightly differently.
1. RMI generally gives access to a common server object, with each remote request being handled in a different thread. You can just as well have that common object do a lookup on a (synchronized) table of sessions. In other words, when a new client makes a request, look that client up, and if it is not in the table, then create a new session object and put it in the table. So now you have saved state.
2. A variation on this: Make your common server object create a session object, and return a remote reference to the caller. All subsequent requests go to the individual session object. (The terminology hear is probably misleading; we have done such designs, and call the registered object an "entry", and the individual objects "servers".
Similar Messages
-
RMI server object lookup in a session bean
Hi all,
I am getting MarshalException when I call java.rmi.Naming.lookup() in a session
bean. Following is the code and exception. Please note that I am using java.rmi
package instead of weblogic.rmi and that both the session bean and RMI server
object (a startup class) is deployed on the same machine.
Thanks for your help in advance.
// a simple, replica-aware session bean method
// some code here
try {
MediatorInterface mediator = (MediatorInterface) java.rmi.Naming.lookup("rmi://localhost:7001/TestMediator);
catch (Exception e) {
// log the exception
The exception:
java.rmi.MarshalException: Error marshaling transport header; nested exception
i
s:
java.io.EOFException
java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:224)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:206
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:318)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:84)
at test.mgmtop.CreateNetworkOpHandler.execute(CreateNetworkOpHandler.jav
a:88)
at test.mgmtop.CreateNetworkOpHandler.perform(CreateNetworkOpHandler.jav
a:28)
at test.ejb.MgmtServiceBean.create(MgmtServiceBean.java:57)
at test.ejb.MgmtServiceSession_idi8yo_EOImpl.create(MgmtServiceSession_i
di8yo_EOImpl.java:46)
at test.ejb.MgmtServiceSession_idi8yo_EOImpl_WLSkel.invoke(Unknown Sourc
e)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:346)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:114)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:300)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:762)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:295)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)Hi Pyung,
How about trying this instead:
InitialContext ctx = new InitialContext();
MediatorInterface mediator = (MediatorInterface) ctx.lookup("TestMediator");
This assumes your startup class binds the Mediator to the JNDI name "TestMediator".
- Matt
Pyung Yoon wrote:
Hi all,
I am getting MarshalException when I call java.rmi.Naming.lookup() in a session
bean. Following is the code and exception. Please note that I am using java.rmi
package instead of weblogic.rmi and that both the session bean and RMI server
object (a startup class) is deployed on the same machine.
Thanks for your help in advance.
// a simple, replica-aware session bean method
// some code here
try {
MediatorInterface mediator = (MediatorInterface) java.rmi.Naming.lookup("rmi://localhost:7001/TestMediator);
catch (Exception e) {
// log the exception
The exception:
java.rmi.MarshalException: Error marshaling transport header; nested exception
i
s:
java.io.EOFException
java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:224)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:206
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:318)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:84)
at test.mgmtop.CreateNetworkOpHandler.execute(CreateNetworkOpHandler.jav
a:88)
at test.mgmtop.CreateNetworkOpHandler.perform(CreateNetworkOpHandler.jav
a:28)
at test.ejb.MgmtServiceBean.create(MgmtServiceBean.java:57)
at test.ejb.MgmtServiceSession_idi8yo_EOImpl.create(MgmtServiceSession_i
di8yo_EOImpl.java:46)
at test.ejb.MgmtServiceSession_idi8yo_EOImpl_WLSkel.invoke(Unknown Sourc
e)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:346)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:114)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:300)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:762)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:295)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133) -
Hello All,
Does WLServer6.1 take care of having a pool of RMI Server objects, similar
to the way EJB container does it for EJBs. I guess what I am trying to
achieve is an effect of Servlets that spawn light threads per invocation
though now using RMI Server Object. I did look at the "executeThreadPool"
options which would allow for increasing performance. I am not 100%
satisfied with it though. Is there any way I can do this. Thanks,
Chirag"Pyung Yoon" <[email protected]> writes:
MediatorInterface mediator = (MediatorInterface) java.rmi.Naming.lookup("rmi://localhost:7001/TestMediator);This implies JRMP which the server does not support. You need to use t3 or iiop.
andy -
RMI server object getting garbage collected
Hi all,
I have seen a number of posts regarding the ConnectException and found that this can occur in a number of situations.
I am having a problem here.
I am having an RMI server that is always up and running. And the server object gets requests from the client at regular intervals. But, when the server object is not receiving any requests for a long time (ex: 1 day), then I think the remote object itself is getting garbage collected. And so, tough I am able to get the remote reference using the lookup method, I am getting "Connection refused to host: 192.168.0.216; nested exception is:
java.net.ConnectException: Connection refused" when I call a method using this reference.
I believe that this is because the server object getting garbage collected as there are no requests for the server since long. Please correct me if my assumption is wrong.
I want to know, after how much time the server object gets garbage collected if no requests are received. But, my requirement is that the server object should always be available and WHENEVER a client request comes then that should be processed. What should I do to accomplish this task.
If any one have any suggestions, please reply as soon as possible.
Thanks in advance,
srik4uYou might do some research into using an activatable remote object. You run rmid (the rmi activation deamon) and register a subclass of java.rmi.activation.Activatable (instead of the usual UnicastRemoteObject) with it. With an activatable object, the remote reference to the activatable object doesn't need to have a live object behind it. If an activatable object is not running (ie: it hasn't been constructed yet, or it has been garbage collected ...as in your case) a remote reference to the object can still be exported to a client. The first time the client calls a method on the remote object, the activation service on the server sees the object is not active, and activates the object for the client. If the object is running ...it is rmi as usual. But if it gets gc'd again, the next invocation on the remote object will trigger the activation service again.
(The above explanation paraphrases author David Flanagan from Java Enterprise in a Nutshell, O'Reilly)
I have only built one of these, which loosely followed an example from the above mentioned book. It's a whole other ballgame over and above a regular rmi object. But like anything else, if you dig in and get your head wrapped around it, it eventually makes sense. Ok, why lie ...it confused the hell out of me and left me a little queasy. But you know the drill, by the time you build a few of them it will probably seem as easy as mapping the human genome, right? At any rate, it seems like what you might be after ...so have a look at it. Good luck, and wear your lifejacket. -
RMI Server Object Startup Error
Greetings,
I am trying to set up a computer lab at my college. I currently have one server running Slackware 9.1 and one client (my laptop) running Windows XP Home. I can telnet and ftp from my client. I can also access the Apache web server running on the Linux machine. I recently discovered RMI as a way to do distributed computing (we are trying to build a proof-of-concept distributed computing system). However, I cannot get RMI to work. When I take the code I wrote and use my laptop as both client and server, everything works. However, when I try to use both machines, it does not work. I want the Linux box to be the server and my laptop to be the client. After compiling my RMI server class (the class that registers the server object for use under RMI) and running it by typing java RemServer, I get a strange error (see bottom of this message). I cannot find this error anywhere else on the internet. I have the rmiregistry program running. I do everything the same as when I do RMI on just my laptop. Please help!
RemServer Remote Exception: java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
java.net.SocketException: Connection reset
[Ljava.lang.StackTraceElement;@13d93f4
Thanks,
JasonOne thing I did discover is that I have not been explicitly starting rmid. Some documentation says that rmi starts rmid automatically. If I need to start rmid, what parameters to I need to pass to it?
Thanks,
Jason -
Regular RMI server object with WebLogic JNDI
Is that possible to register a regular RMI object with WebLogic JNDI
tree? I was building a simple program (using javac and rmic only) based
on the java.rmi.* (without changing the import statements to
weblogic.rmi.*) and using the weblogic.jndi to register the server
object. Below is some piece of code,
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://172.20.20.20:7001");
ctx = new InitialContext(ht);
ctx.bind("HelloServer", obj);
The code failed for the following reason,
javax.naming.NamingException. Root exception is
java.rmi.MarshalException: failed to marshal public abstract void
weblogic.jndi.internal.NamingNode.bind(java.lang.String,java.lang.Object,java.util.Hashtable)
throws javax.naming.NamingException,java.rmi.RemoteException; nested
exception is:
java.rmi.server.ExportException: A description for
examples.rmi.hello.HelloImpl was found but it could not be read due to:
[Failed to find examples.rmi.hello.HelloImpl_WLStub or
examples.rmi.hello.Hello_WLStub for class examples.rmi.hello.HelloImpl]
java.rmi.StubNotFoundException: Failed to find
examples.rmi.hello.HelloImpl_WLStub or examples.rmi.hello.Hello_WLStub
for class examples.rmi.hello.HelloImpl
at
weblogic.rmi.internal.BasicDescriptor.<init>(BasicDescriptor.java:101)
at
weblogic.rmi.internal.BasicRuntimeDescriptor.<init>(BasicRuntimeDescriptor.java:50)
at
weblogic.rmi.internal.DescriptorManager.resolveClass(DescriptorManager.java:55)
at
weblogic.rmi.internal.DescriptorManager.getDescriptor(DescriptorManager.java:39)
at
weblogic.rmi.internal.DescriptorManager.getDescriptor(DescriptorManager.java:30)
at
weblogic.rmi.internal.OIDManager.getRequestDispatcher(OIDManager.java:281)
at
weblogic.rmi.internal.OIDManager.getReplacement(OIDManager.java:270)
at
weblogic.rmi.internal.OIDManager.replaceObject(OIDManager.java:98)
at
weblogic.common.internal.ChunkedObjectOutputStream.replaceObject(ChunkedObjectOutputStream.java:55)
at
weblogic.common.internal.ChunkedObjectOutputStream$NestedObjectOutputStream.replaceObject(ChunkedObjectOutputStream.java:239)
Any idea?
- SteveC"Pyung Yoon" <[email protected]> writes:
MediatorInterface mediator = (MediatorInterface) java.rmi.Naming.lookup("rmi://localhost:7001/TestMediator);This implies JRMP which the server does not support. You need to use t3 or iiop.
andy -
XDK 9i Issues : setXSLT - NullPointerException And RMI Server hangs
Present Scenario :
JDK 1.3
Oracle DB : 8.1.6
JDBC Driver : OracleThin.jar
XML Parser : xmlparserv2.jar : ( size = 1121488 )
XML-SQL utility : xsu12.jar : ( size = 180522 )
We use RMI with JDBC. RMI server object connects to database , uses xsu12.jar and xmlparserv2.jar to convert data into XML. Servlet connects to RMI server and gets this XML. Everything works fine.
Problem Scenario :
Since this parser does not support JAXP , I downloaded XDK 9i from oracle site.(9.2.0.1.0 - Dated 01/31/02 ) . After extracting , I replaced xmlparserv2.jar and xsu12.jar with this new ones. And problem started. There are 2 problems :
A. setXSLT( String, String ) throws NullPointerExcpetion
B. When I commented setXSLT method, RMI server completes execution of remote method which can be verified from Log. But it never returns , so client gets blocked. When RMI server is stopped by doing ctrl-C , client gets correct XML document.
Then I installed latest JDBC2.0 driver for 8.1.6 from site which is classes.zip. This also resulted in to same problems mentioned above. But it did work fine wirh earlier version of xmlparserv2.jar and xsu12.jar. Just FYI : I noticed significant size difference betwenn new and old jars.
New xmlparserv2.jar : size = 660421
New xsu12.jar : size = 473249
Thanks for patience
What could be possible solution ?Thanks Jinu
Problem A of setXSLT throwing NullPOinter Exception is solved. However problem B of RMI server not returning still there.
Just as an FYI , following is system
DB : oracle 8.1.6
xmlparserv2.jar : 9i xdk
xsu12_816.jar : 9i xdk
classes12.zip : JDBC2.0 for 8.1.6
When RMI server is stopped ( ctrl- C ) , client gets correct XML document alongwith proper Node names as set in setStyleSheet( String, String). -
Lesson 8: RMI, Error in Run the RemoteServer Server Object
Hello guys,
Please Help!
I try to test and run the samples in
JavaTM Programming Language Basics, Part 1
Lesson 8: Remote Method Invocation
http://developer.java.sun.com/developer/onlineTraining/Programming/BasicJava1/rmi.html
I already compiled the samples, but when I testing to run the RemoteServer Object it gives me error.
Here's the following line command:
java -Djava.rmi.server.codebase=file:
g:\home\zelda\public_html\classes
-djava.rmi.server.hostname=kq6py.eng.sun.com
-Djava.security.policy=java.policy RemoteServer
The ERROR:
Exception in thread "main" java.security.AccessControlException: access denied (
java.net.SocketPermission kq6py.eng.sun.com resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at RemoteServer.main(remoteserver.java:38)
PLEASE HELP!!!
Thanks in advance,
RodelOooppssss, I got it.
uh huh!!!! -
Java.rmi.server.ExportException: object already exported
I'm encountering an RMI error that I have never seen before. The exception is the following :
<p><b>
java.rmi.server.ExportException: object already exported
</b>
I am only invoking the UnicastRemoteObject.exportObject() method once. Any ideas on why this error is occurring? This one is about to drive me crazy.
Thanks in advance!There is no need to exportObject() if your implementor extends the UnicastRemoteObject. In such a case it is automatically exported. However in the other case when not extending UnicastRemteObject it can be explicitly exported by exportObject methods.
-
Hello
I have a function in the RMI client that passes an object to the RMI server. The server updates one of the members of this object.
When I try to get this memebr from the client, I get 0.
This is the Object code:
public class Progress implements Serializable {
private static final long serialVersionUID = 8168473416653301292L;
private int mProgress = 0;
/** Creates a new instance of Progress */
public Progress() {
public int getProgress()
return mProgress;
public void setProgress(int progress)
System.out.println("progress = "+progress);
mProgress = progress;
}This is the function that passes the Object to the server:
public RequestResult executeAdminAPI(int aDbTypeOrdinal, String aHost, int aPort, String aUser, String aPassword,
String aInput, Progress progress) throws RMIClientException, SCException {
try {
if (mServerInitialised)
return mJNICommRMIServer.executeAdminAPIWrapper(aDbTypeOrdinal, aHost, aPort, aUser, aPassword, aInput, progress);
else {
synchronized (mServerInitializedMutex) {
return mJNICommRMIServer.executeAdminAPIWrapper(aDbTypeOrdinal, aHost, aPort, aUser, aPassword, aInput, progress);
catch (RemoteException e) {
// We'll restart the server on JNIFatalException
// means that we should kill the process and restart it
// JNIFatalException means that the cpp code send an error code which
// We don't restart the server on SocketTimeOut like the other functions,
// because this function may take a long time to execute
if (e.detail instanceof JNIFatalException) {
restartServer("executeAdminAPI got an exception: " + e.detail.getMessage());
if ((e.detail instanceof ConnectException)) // RMI-TODO check perhaps it
// should be restartServer()
startServer("executeAdminAPI got an exception: " + e.detail.getMessage());
if (e.detail instanceof JNIException)
throw new SCException(((JNIException) (e.detail)).getErrorCode(), ((JNIException) (e.detail)).getErrorMessage());
else
throw new RMIClientException(e);
}The "setProgress" (called by the server) prints the correct numbers, but the "getProgress" (called by the client) returns 0.
Can anyone explain please?
Thanks,
LibbyArguments are passed by value in RMI unless they are exported remote objects. So the update took place at the server only. If you want it reflected at the client, either (i) return the updated object as the result of the method, or (ii) make the updatable object an exported remote object, i.e. a callback. But note that (ii) doesn't play with firewals in place.
-
Urgent Help Required For Starting RMI server from servlet.
I am currently working on rmi project.
I want to send request to remote machine(Web host) where my application is from desktop client .For that we are using RMI.
I am writing servlet and inside it i am binding object to registry for rmi server.
which will be deployed on remote server.
code ....
Registry reg;
reg=LocateRegistry.createRegistry(1099);
Server server=new Server("server");//class whose remote object to be accessed
//extends unicast remote object.Implement ServerInt interface which extends Remote.
reg.bind("server",server);
When i am trying to access this object i am getting following exception.
javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalExcepti
on: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: ServerModule.ServerInt]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at RequstReplication.main(RequstReplication.java:27)
Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested excep
tion is:
java.lang.ClassNotFoundException: ServerModule.ServerInt
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
... 4 more
Caused by: java.lang.ClassNotFoundException: ServerModule.ServerInt
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.rmi.server.LoaderHandler.loadProxyInterfaces(Unknown Source)
at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadProxyClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(Unknown Source)
at java.io.ObjectInputStream.readProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
... 5 more
I can access naming enumeration of registry and object bound to it.
by following program.I shows corect objects.
Context namingContext=new InitialContext();
NamingEnumeration<NameClassPair> e=namingContext.list("rmi:");
while(e.hasMore())
System.out.println(e.next().getName());
While when i start RMI server from simple java program i can access these objects from registry.
I am not getting what is problem problem.Is there any other way to send request?
Plese give quick response.I am currently working on rmi project.
I want to send request to remote machine(Web host) where my application is from desktop client .For that we are using RMI.
I am writing servlet and inside it i am binding object to registry for rmi server.
which will be deployed on remote server.
code ....
Registry reg;
reg=LocateRegistry.createRegistry(1099);
Server server=new Server("server");//class whose remote object to be accessed
//extends unicast remote object.Implement ServerInt interface which extends Remote.
reg.bind("server",server);
When i am trying to access this object i am getting following exception.
javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalExcepti
on: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: ServerModule.ServerInt]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at RequstReplication.main(RequstReplication.java:27)
Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested excep
tion is:
java.lang.ClassNotFoundException: ServerModule.ServerInt
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
... 4 more
Caused by: java.lang.ClassNotFoundException: ServerModule.ServerInt
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.rmi.server.LoaderHandler.loadProxyInterfaces(Unknown Source)
at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadProxyClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(Unknown Source)
at java.io.ObjectInputStream.readProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
... 5 more
I can access naming enumeration of registry and object bound to it.
by following program.I shows corect objects.
Context namingContext=new InitialContext();
NamingEnumeration<NameClassPair> e=namingContext.list("rmi:");
while(e.hasMore())
System.out.println(e.next().getName());
While when i start RMI server from simple java program i can access these objects from registry.
I am not getting what is problem problem.Is there any other way to send request?
Plese give quick response. -
Not able to run a simple RMI server
I am running an RMI program like follwing
import java.rmi.* ;
import java.rmi.registry.* ;
import java.rmi.server.* ;
public class CallBeanServer extends UnicastRemoteObject implements ICallBeanServer
//main
public static void main(String args[]) throws Exception
int port = 1000 ;
Registry reg = null ;
if( args[0].equals("true"))
reg = LocateRegistry.createRegistry(port) ;
System.out.println("Successfully created registry") ;
else
reg = LocateRegistry.getRegistry(port) ;
System.out.println("Connected to existing registry") ;
CallBeanServer callBeanServer = new CallBeanServer(reg) ;
}//main
//constructor
public CallBeanServer(Registry reg) throws Exception, RemoteException
super() ;
reg.rebind("CallBeanServer",this) ;
System.out.println("CallBeanServer Object bound") ;
//my public method
public String callBeanServer() throws RemoteException
{ return "Success" ;
I have run the rmiregistry at port no 1000 like
rmiregistry 1000
I have compiled ICallBeanServer also and run rmic also over CallBeanServer like
rmic CallBeanServer
when I run this program using
java CallBeanServer false
it gives the follwoing errors
Connected to existing registry
Exception in thread "main" java.rmi.ServerException: Server RemoteException; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: CallBeanServer_Stub
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: CallBeanServer_Stub
java.lang.ClassNotFoundException: CallBeanServer_Stub
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at CallBeanServer.<init>(CallBeanServer.java:38)
at CallBeanServer.main(CallBeanServer.java:30)
Can you please tell me what is the error?
Thanks
Prashant GuptaAdd the classes (the stubs included) to the classpath when you start the registry.
-
Help needed to move a java.rmi.Remote object.....
Hi,
I have an object extending java.rmi.Remote on a server. I want to get it onto a client (ie the actual object, not a reference to the object on the server).
The catch (isn't there always one):
The client must only get class definitions/interface definitions from the java.rmi.server.codebase
(ie I don't want to use a network classloader).
Anyone any ideas?
Kev.If you have a class that implements java.rmi.Remote then the objects of that class by definition are available for Remote access (ie, they are passed by reference). Remote objects can't be passed by value. However, if you want objects of a particular class to be passed by value you could have the class implement java.io.Serializable instead of java.rmi.Remote.
Hope this helps. -
Cant create JDBC Connections in RMI Server
I am having a pretty weird problem which I am struggling with for the last three days. In the main method of the Server object, following three things are supposed to happen:
1) Creation of a JDBC Connection
2) Creation of a Remote Object and then publishing the same to Registry.
3) Creation of another JDBC Connection (exactly same as in step1)
step 1 and 2 successfully executes and the third one always errors out. I just simply get a NullPointerException.
If I comment out step 2, step 3 executes successfully. Can someone please tell me the mystery? I need your response really urgently so please help me.
TIA
Code Snippet:
public static void main(String[] args) {
System.setSecurityManager(new RMISecurityManager());
try {
Properties dbProps = new Properties();
dbProps.put("user", "SDAWOODI");
dbProps.put("password", "SDAWOODI");
java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:oracle:thin:@wonder.cisco.com:1521:ODSDEV", dbProps);
catch (Exception sqle) {
System.out.println("[11111]"+sqle.toString());
Properties props = new Properties();
props.put("java.rmi.server.codebase", rmiCodeBase);
System.setProperties(props);
try {
SchedulerRImpl schedulerR = new SchedulerRImpl(ssce_sch1);
String nameStr = "s-sce-scheduler";
try {
Naming.bind(nameStr, schedulerR);
if (Scheduler.m_debug_flag) System.out.println("[Scheduler.main] Scheduler bound with RMI registry!!!");
catch (AlreadyBoundException abe) {
if (Scheduler.m_debug_flag) System.out.println("[Scheduler.main] Scheduler is already bound with RMI registry ... trying RE-bind ...");
try {
Naming.rebind(nameStr, schedulerR);
if (Scheduler.m_debug_flag) System.out.println("[Scheduler.main] Scheduler RE-bound with RMI registry!!!");
catch (Exception e) {
if (Scheduler.m_debug_flag) System.out.println("[Scheduler.main] Rcheduler RE-binding failed :(((");
catch (Exception e) {
if (Scheduler.m_debug_flag) System.out.println("[Scheduler.main] SchedulerR instantiation failed:((( : "+e.toString());
Properties dbProps2 = new Properties();
dbProps2.put("user", "SDAWOODI");
dbProps2.put("password", "SDAWOODI");
try {
java.sql.Connection connection2 = java.sql.DriverManager.getConnection("jdbc:oracle:thin:@wonder.cisco.com:1521:ODSDEV", dbProps2);
if (connection2==null) {
System.out.println("connection is NULL");
else {
System.out.println("connection is NOT null");
catch (Exception sqle2) {
System.out.println("[22222]"+sqle2.toString());
}In reply to reply #4:
You can also quote the other part of my reply when it comes to snippets. There are so many pieces of code missing from your snippet that I simply cannot guess what is wrong. (Please do not put your entire class structures here.)
We get connections in many different classes at many different times. It is after all an application that does user work and the user work involves database accesses. Some of those accesses are before RMI (to establish repositories, etc). Most are after.
This URL (jdbc:oracle:thin:@wonder.cisco.com:1521:ODSDEV) appears to use a network connection (yes?). Is the 1521 a port? Are you trying to reuse this port? (the first conn uses the same URL). What port does RMI use?
There is nothing in your snippet that stands out obviously as "this is wrong".
RMI uses networking. JDBC uses networking.
Try substituting some other networking code in place of the RMI code and see if you still get a null trying the second connection. As you say, if you leave out the RMI code the second get.conn works.
Try leaving out the first get.conn. Do the RMI and second get.conn.
Try this and try that and try some more. I once had this problem with a network printer that would not print. The code was fine. The URL was fine. The response from the network and printer were both fine. The damn thing just wasn't printing. Turns out there was this bit, yes a single bit, in one word of a property called the "start print bit". If this bit wasn't on, nothing happened. I tried every combination until I finally found it.
I wish you the best. -
hi
Can anybody tell me how to stop the Jvm to free the Rmi server port and the remote object?Hi,
The first step: unbind the bound object from the registry!
As far as I know the UnicastRemoteObject calls the exportObject() method in its constructor. If you want to force the unregistering call the UnicastRemoteObject's unexportObject() method on the server object.
After these two calls (Naming.unbind(), UnicastRemoteObject.unexportObject()) the server object surely is no longer listening the remote calls, the JVM exits smothly...
Sany
Maybe you are looking for
-
I am using a Samsung SyncMaster 243T for my primary monitor and an ACER AL2051W for my second monitor. I bought a mini-DVI adapter which allows me to send a cable to my second monitor which now works. Unfortunately, it is acting strangely. When I dra
-
Installation error-Argument tnsnamesOraTemplate must point to an existing f
Hi experts, I am getting below error during installation ERROR 2011-08-30 19:19:44.309 [sixxcstepexecute.cpp:937] FCO-00011 The step doNetworkConfigurationClient with step key |NW_Doublestack_DB|ind|ind|ind|ind|0|0|NW_CreateDBandLoad|ind|ind|i
-
Internal order discription in source doc
Hi Is it possible to have the description of the internal order to appear on the source document (Cheque Payment Voucher, Cash Payment Voucher or Material Requisition Note). If so pls advice on that... Thanx. K
-
Reader X will not install on Vista
Hey all, First time forumer here... Here's the story downloaded pdf zip for taxes. "access is denied" Nowheres to be found in downloads folder... download each pdf indiivually and fine in 8 downloaded pdf to AR831 Scrolls slow Download 1mb pdf...
-
What is the best way to run windows on my mac?
What is the best way to run windows on my mac? I have a particular program that i need to run, and it only runs on windows. I have a macbook pro