Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 440
  • Last Modified:

Help with thrown exception when using RMI.

I'm getting this RMI related exception thrown and I don't know why:

"C:\Archivos de programa\Java\jdk1.5.0\bin\javaw" -classpath (...)  officechat.core.Servidor
Exception in thread "main" java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
      java.lang.ClassNotFoundException: officechat.common.InterfazRemota
      at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:385)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:343)
      at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
      at officechat.core.Servidor.inicializarRMI(Servidor.java:52)
      at officechat.core.Servidor.<init>(Servidor.java:58)
      at officechat.core.Servidor.main(Servidor.java:72)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
      java.lang.ClassNotFoundException: officechat.common.InterfazRemota
      at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
      at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:375)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: officechat.common.InterfazRemota
      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:290)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:236)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:303)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:242)
      at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:707)
      at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:651)
      at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:588)
      at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:626)
      at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:293)
      at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238)
      at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1491)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1454)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1690)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1296)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
      ... 9 more


It is thrown by this piece of code:

            MetodosRemotos mr = new MetodosRemotos();
            Registry registry = LocateRegistry.getRegistry();
            registry.bind("InterfazRemota", mr); // <-- it is thrown here

And this is the MetodosRemotos class, which has nothing special:

public class MetodosRemotos extends UnicastRemoteObject implements InterfazRemota
{
      public MetodosRemotos() throws RemoteException
      {

      }
      (methods of InterfazRemota here)
}

And finally this is the remote interface:

public interface InterfazRemota extends Remote
{
      public boolean logon( byte [] password) throws RemoteException;
      public Settings getSettings() throws RemoteException;
}

Tell me if you need more info. I'm using JDK 1.5 Beta2, and rmiregistry is running.
JBuilder tells me this warning, but I have no idea of what it means: "serializable class MetodosRemotos has no definition of serialVersionUID".
I'm not using rmic anymore, because in JDK 1.5 you are not supposed to.
Please help.
0
pulupul
Asked:
pulupul
  • 19
  • 15
1 Solution
 
sudhakar_koundinyaCommented:
officechat.common.InterfazRemota is not existing in ur classpath.

How you are setting the classpath for this interface??
0
 
sudhakar_koundinyaCommented:
Your API should be somethinglike this

package  officechat.common;
public interface InterfazRemota extends Remote
{
     public boolean logon( byte [] password) throws RemoteException;
     public Settings getSettings() throws RemoteException;
}
0
 
sudhakar_koundinyaCommented:
because
Basically u are getting following exception
java.lang.ClassNotFoundException: officechat.common.InterfazRemota

So try as suggested above.

If you are already doing that. Check your classpath. That  class should be added to ur classpath
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
pulupulAuthor Commented:
It is, I have checked it and it does exist. The classpath is "C:\Documents and Settings\k\jbproject\Servidor\classes", and InterfazRemota.class exists in "C:\Documents and Settings\k\jbproject\Servidor\classes\officechat\common". I'm using JBuilder so all the classpath stuff is automated.
0
 
pulupulAuthor Commented:
That's the way I have it:

package officechat.common;

import java.rmi.*;

public interface InterfazRemota extends Remote
{
    public boolean logon( byte [] password) throws RemoteException;
    public Settings getSettings() throws RemoteException;
}
0
 
sudhakar_koundinyaCommented:
if ur classes are in Jar file

check whether classes from this folder( officechat/common) are added or not

if ur classes are in folder directly

Assuming u r doing at  c:\

set classpath=%classpath%; c:\officechat\common; c:\officechat\core;

Regards
Sudhakar
0
 
sudhakar_koundinyaCommented:
Hmmm,

did u try from dos, instead of executing from JBuilder
0
 
pulupulAuthor Commented:
I've tried from DOS, and now I get a different exception:

Exception in thread "main" java.rmi.StubNotFoundException: Stub class not found: officechat.core.MetodosRemotos_Stub; nested exception is:
        java.lang.ClassNotFoundException: officechat.core.MetodosRemotos_Stub
        at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:98)
        at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:55)
        at sun.rmi.server.UnicastServerRef.setSkeleton(UnicastServerRef.java:179)
        at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:142)
        at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:129)
        at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:275)
        at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:178)
        at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:75)
        at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:61)
        at officechat.core.MetodosRemotos.<init>(MetodosRemotos.java:11)
        at officechat.core.Servidor.inicializarRMI(Servidor.java:50)
        at officechat.core.Servidor.<init>(Servidor.java:58)
        at officechat.core.Servidor.main(Servidor.java:72)
Caused by: java.lang.ClassNotFoundException: officechat.core.MetodosRemotos_Stub
        at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at sun.rmi.server.RemoteProxy.loadClassFromClass(RemoteProxy.java:191)
        at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:93)
        ... 12 more


Isn't JDK 1.5 supposed to automatically generate stubs?
0
 
sudhakar_koundinyaCommented:
Generated stubs and skeletons also should be in classpath

this class officechat.core.MetodosRemotos_Stub  should be in ur classpath
0
 
sudhakar_koundinyaCommented:
>>Isn't JDK 1.5 supposed to automatically generate stubs?

Try generating them using RMIC
0
 
pulupulAuthor Commented:
I know, the thing is that maybe I need to run rmic to generate that class (which at this time does not exist), although one of the improvements in Java 1.5 is that running it is not needed.
0
 
sudhakar_koundinyaCommented:
It should be there
by looking at http://www.cs.umb.edu/~wrc/java/jdk1.5/bin/
0
 
pulupulAuthor Commented:
I've generated the stub (rmic -d . officechat.core.MetodosRemotos). Now MetodosRemotos_Stub.class is in officechat/core.

"C:\Archivos de programa\Java\jdk1.5.0\bin\java" -classpath "C:\Documents and Settings\k\jbproject\Servidor\classes;C:\Documents and Settings\k\jbproject\Servidor\classes\common;C:\Documents and Settings\k\jbproject\Servidor\classes\core"  officechat.core.Servidor

Exception in thread "main" java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
        java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
        java.lang.ClassNotFoundException: officechat.core.MetodosRemotos_Stub
        at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:385)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
        at sun.rmi.transport.Transport$1.run(Transport.java:153)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
        at java.lang.Thread.run(Thread.java:595)
        at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
        at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:343)
        at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
        at officechat.core.Servidor.inicializarRMI(Servidor.java:52)
        at officechat.core.Servidor.<init>(Servidor.java:58)
        at officechat.core.Servidor.main(Servidor.java:72)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
        java.lang.ClassNotFoundException: officechat.core.MetodosRemotos_Stub
        at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
        at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:375)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
        at sun.rmi.transport.Transport$1.run(Transport.java:153)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
        at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: officechat.core.MetodosRemotos_Stub
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:290)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:236)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:303)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:242)
        at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:430)
        at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
        at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:618)
        at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:246)
        at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1535)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1457)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1690)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1296)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
        ... 9 more
0
 
sudhakar_koundinyaCommented:
it should be something like this
set classpath=%classpath%;C:\Documents and Settings\k\jbproject\Servidor\classes\office\common;C:\Documents and Settings\k\jbproject\Servidor\classes\office\core;

0
 
sudhakar_koundinyaCommented:
"C:\Archivos de programa\Java\jdk1.5.0\bin\java" -classpath "C:\Documents and Settings\k\jbproject\Servidor\classes;C:\Documents and Settings\k\jbproject\Servidor\classes\officechat\common;C:\Documents and Settings\k\jbproject\Servidor\classes\officechat\core" officechat.core.Servidor


                     or

set classpath=%classpath%;C:\Documents and Settings\k\jbproject\Servidor\classes\officechat\common;C:\Documents and Settings\k\jbproject\Servidor\classes\officechat\commob;

java officechat.core.Servidor
0
 
pulupulAuthor Commented:
It's the same isn't it?
0
 
sudhakar_koundinyaCommented:
no u are missing officechat in ur classpath
C:\Documents and Settings\k\jbproject\Servidor\classes\common

should be

C:\Documents and Settings\k\jbproject\Servidor\classes\officechat\common
0
 
pulupulAuthor Commented:
Ah ok, I have put it like that :
java -classpath "C:\Documents and Settings\k\jbproject\Servidor\classes;C:\Documents and Settings\k\jbproject\Servidor\classes\officechat\common;C:\Documents and Settings\k\jbproject\Servidor\classes\officechat\core"  officechat.core.Servidor

But still get the last exception. As far a I know, it is enough to put the root path ( in this case C:\Documents and Settings\k\jbproject\Servidor\classes) in the classpath, all subfolders are not needed to be included in the cp.
0
 
sudhakar_koundinyaCommented:
did u try like this??


set classpath=%classpath%;"C:\Documents and Settings\k\jbproject\Servidor\classes\officechat\common";"C:\Documents and Settings\k\jbproject\Servidor\classes\officechat\core";

java officechat.core.Servidor


And also check once again, if the stub classes are there in "C:\Documents and Settings\k\jbproject\Servidor\classes\officechat\common"
0
 
sudhakar_koundinyaCommented:
>>officechat.core.MetodosRemotos_Stub

I mean  ur stub classes should be in classes\officechat\core
0
 
pulupulAuthor Commented:
As I said, it is there.
0
 
pulupulAuthor Commented:
I have tried with set classpath=... with the same result.
0
 
sudhakar_koundinyaCommented:
try running RMIRegistry from command prompt and let me know
0
 
pulupulAuthor Commented:
I'm already running it, if I stop it the exception I get is:
Exception in thread "main" java.rmi.ConnectException: Connection refused to host: 192.168.0.3
0
 
sudhakar_koundinyaCommented:
0
 
sudhakar_koundinyaCommented:
0
 
objectsCommented:
It seems like its the remote vm that cannot find the class, not the local one.
May sure the classes are available to both vm's.
0
 
sudhakar_koundinyaCommented:
Do this as objects suggested

Place all compiled classes , stubs and skeletons at both server side and client side and execute the application

Regards
0
 
pulupulAuthor Commented:
I found out that it works if from the console I start rmiregistry from the classpath root (C:\Documents and Settings\k\jbproject\Servidor\classes), but not if I launch it from a different location.
0
 
pulupulAuthor Commented:
Now I'm always launching rmiregistry with the parameters: -J-classpath -J"($Classpath)".  Where ($Classpath) is replaced by JBuilder with the project classpath. And it works great!.
Thank you everybody for your time.
0
 
sudhakar_koundinyaCommented:
yes, that's true. I thought that you did like that only. And I was surprised when it was not working
0
 
pulupulAuthor Commented:
rmiregistry doesn't seem to look at classpath environment variable, it is only possible to pass the classpath to it with the -J options.
0
 
pulupulAuthor Commented:
I was launching it from random locations, from wherever directory I was at that time :)
0
 
pulupulAuthor Commented:
I'm requesting a refund, anyone has something to say?
0
 
sudhakar_koundinyaCommented:
why,

I have  tried to help you in all possible ways. I also asked you to execute the rmiregistry from console too. Only thing you did not mention last night is how you are executing the rmiregistry.

I assumed that you executed from the classpath itself, which you did not do last night.

Regards
Sudhakar
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 19
  • 15
Tackle projects and never again get stuck behind a technical roadblock.
Join Now