my dog learned polymorphism*
The moose likes Distributed Java and the fly likes Unmarshalling Error while registering an object in RMIRegistery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Unmarshalling Error while registering an object in RMIRegistery" Watch "Unmarshalling Error while registering an object in RMIRegistery" New topic
Author

Unmarshalling Error while registering an object in RMIRegistery

mohsin Rasheed
Greenhorn

Joined: Jul 25, 2011
Posts: 14
Hi guys ,
I am executing the code , in which i try to "Server.java" file which binds an object to the RMI registry , but when i run this file it give me following error.

Exception:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: bankrmi.Bank




Could anyone please help me out in resolving this issue.
Vijay Tidake
Ranch Hand

Joined: Nov 04, 2008
Posts: 146

Hi,

please check this link


The important thing is not to stop questioning.Curiosity has its own reason for existing.
mohsin Rasheed
Greenhorn

Joined: Jul 25, 2011
Posts: 14
Thanks , but my problem is not solved yet .
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

Do you have a class called Bank in a package bankrmi? According to the error the RMI registry can't find one of your classes.


Hunter


"If the facts don't fit the theory, get new facts" --Albert Einstein
mohsin Rasheed
Greenhorn

Joined: Jul 25, 2011
Posts: 14
yes i have .
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

Can post some more information? Like the directory structure you are using? I can't really help if I have nothing to go on but
mohsin Rasheed
Greenhorn

Joined: Jul 25, 2011
Posts: 14
Please find the attached screenshot for error and structure , do you something more ?



[Thumbnail for RMI_Error.png]

Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

can you post the definition of BankImpl?


Hunter
mohsin Rasheed
Greenhorn

Joined: Jul 25, 2011
Posts: 14
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

What is the value of the bankname variable? it is supposed to be a url, something like





Hunter
mohsin Rasheed
Greenhorn

Joined: Jul 25, 2011
Posts: 14
I am passing it in the argument as 'Nordea' for the bank name .
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

try using "rmi:Nordea"
mohsin Rasheed
Greenhorn

Joined: Jul 25, 2011
Posts: 14
I got the same error while try using rmi:Nordea.

While compiling the source code , i have noticed that i am getting an error .

Compiling 7 source files to C:\Users\Dell\Documents\NetBeansProjects\RMI_Example01\build\classes
Note: C:\Users\Dell\Documents\NetBeansProjects\RMI_Example01\src\bankrmi\BankImpl.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details
.

could it be the cause of error.
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

No that just means you are using deprecated code somewhere in your program, it isn't as big of an issue as the ServerException. Do you have the Bank.class file in the bankrmi.classes.bankrmi folder?
mohsin Rasheed
Greenhorn

Joined: Jul 25, 2011
Posts: 14
yes i guess ,please find the attached screenshot.


[Thumbnail for RMI_Error.png]

mohsin Rasheed
Greenhorn

Joined: Jul 25, 2011
Posts: 14
While i am generating the classes and stub s using the following command , in the command prompt.

javac -d classes -cp classes *.java
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

I think you need the .class files in the bankrmi folder as well.

This is an example directory structure from an example in the Core Java Vol. 2 Book:

server/
->WarehouseServer.class
->Warehouse.class
->WarehouseImpl.class

client/
->WarehouseClient.class
->Warehouse.class

Notice how the Warehouse.class file (in your case Bank.class) is in both folders

Hunter
mohsin Rasheed
Greenhorn

Joined: Jul 25, 2011
Posts: 14
If you mean that all the classes including the stubs needs to be in the "main" bankrmi folder , then i have tried it out , but it did not make any impact, maybe its not the reason of error.
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

I didn't mean to imply all the class files, just the Bank.class file. The JVM can't find bankrmi.Bank, that is what the ClassNotFoundException you got is referring to.

Hunter
mohsin Rasheed
Greenhorn

Joined: Jul 25, 2011
Posts: 14
I tried it prior , got same error.
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

I know for a fact that you need it in both folders, other than that I'm out of ideas..Sorry

Hunter
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19761
    
  20

Hunter McMillen wrote:No that just means you are using deprecated code somewhere in your program, it isn't as big of an issue as the ServerException.

Not deprecated code, non-generic collection classes. In this case, the Hashtable and Enumeration.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

Rob Spoor wrote:
Hunter McMillen wrote:No that just means you are using deprecated code somewhere in your program, it isn't as big of an issue as the ServerException.

Not deprecated code, non-generic collection classes. In this case, the Hashtable and Enumeration.


Thanks, I didn't know that I thought it was for deprecated code.

Hunter
mohsin Rasheed
Greenhorn

Joined: Jul 25, 2011
Posts: 14
I think i have got the problem , when i extend the Interface with "java.rmi.remote" , its giving me the unmarshalling exception , but when i did not extend it with Remote, the "Server" works fine.
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

Do you have the server extending java.rmi.Remote? Because the server isnt supposed to do that. The server has access to the real objects(non-remote)


Hunter
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19761
    
  20

It's about time I move this thread to our Distributed Java forum. I should have done so days ago...
mohsin Rasheed
Greenhorn

Joined: Jul 25, 2011
Posts: 14
can we discuss that problem over the skype , it would be easier than to solve it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unmarshalling Error while registering an object in RMIRegistery