?
Solved

Help with thrown exception when using RMI.

Posted on 2004-09-28
37
Medium Priority
?
431 Views
Last Modified: 2008-02-01
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
Comment
Question by:pulupul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 19
  • 15
37 Comments
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 2000 total points
ID: 12171897
officechat.common.InterfazRemota is not existing in ur classpath.

How you are setting the classpath for this interface??
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12171925
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12171961
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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 3

Author Comment

by:pulupul
ID: 12171971
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
 
LVL 3

Author Comment

by:pulupul
ID: 12171987
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12172008
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12172095
Hmmm,

did u try from dos, instead of executing from JBuilder
0
 
LVL 3

Author Comment

by:pulupul
ID: 12172156
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12172198
Generated stubs and skeletons also should be in classpath

this class officechat.core.MetodosRemotos_Stub  should be in ur classpath
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12172213
>>Isn't JDK 1.5 supposed to automatically generate stubs?

Try generating them using RMIC
0
 
LVL 3

Author Comment

by:pulupul
ID: 12172267
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12172327
It should be there
by looking at http://www.cs.umb.edu/~wrc/java/jdk1.5/bin/
0
 
LVL 3

Author Comment

by:pulupul
ID: 12172395
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12172445
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12172473
"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
 
LVL 3

Author Comment

by:pulupul
ID: 12172495
It's the same isn't it?
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12172556
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
 
LVL 3

Author Comment

by:pulupul
ID: 12172643
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12172696
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12172716
>>officechat.core.MetodosRemotos_Stub

I mean  ur stub classes should be in classes\officechat\core
0
 
LVL 3

Author Comment

by:pulupul
ID: 12172780
As I said, it is there.
0
 
LVL 3

Author Comment

by:pulupul
ID: 12172786
I have tried with set classpath=... with the same result.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12172951
try running RMIRegistry from command prompt and let me know
0
 
LVL 3

Author Comment

by:pulupul
ID: 12173038
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12173046
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12173110
0
 
LVL 92

Expert Comment

by:objects
ID: 12174977
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12176790
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
 
LVL 3

Author Comment

by:pulupul
ID: 12180725
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
 
LVL 3

Author Comment

by:pulupul
ID: 12180805
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12180811
yes, that's true. I thought that you did like that only. And I was surprised when it was not working
0
 
LVL 3

Author Comment

by:pulupul
ID: 12180854
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
 
LVL 3

Author Comment

by:pulupul
ID: 12180890
I was launching it from random locations, from wherever directory I was at that time :)
0
 
LVL 3

Author Comment

by:pulupul
ID: 12181187
I'm requesting a refund, anyone has something to say?
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12182375
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question