RemoteException java.rmi.UnmarshalException: error unmarshalling return [duplicate]
Asked Answered
R

5

13

I'm running the program here on 2 JVMs on diff physical machines. I get the error

RemoteException
java.rmi.UnmarshalException: error unmarshalling return; nested exception is: 
    java.lang.ClassNotFoundException: CalculatorImpl_Stub (no security manager: RMI class loader disabled)

I've even tried running it on the same machine(unchanged program) and it works but it doesnt work on diff machines. Can someone pls help me out?

@beny23- Thanks but I still end up with this error:

RemoteException
java.rmi.UnmarshalException: error unmarshalling return; nested exception is: 
java.lang.ClassNotFoundException: CalculatorImpl_Stub

How can the client side have a copy of CalculatorImpl_stub?

Retiary answered 8/9, 2011 at 22:48 Comment(0)
M
7

It sounds like your not using a security manager:

Have you got a policy file (my.policy):

grant {
  permission java.security.AllPermission;
};

and run your program using

java -Djava.security.manager -Djava.security.policy=/some/path/my.policy MyClass
Morganatic answered 8/9, 2011 at 23:0 Comment(2)
He doesn't need either a SecurityManager or a .policy file to solve this problem, unless he is trying to use the RMI codebase feature, which isn't stated.Idden
EJP please add more information! It sounds quite useful but i don't get it.Sutton
C
16

I had this problem because I had different package names in client and server code:

package my.pkg; 
// server side interface definition...

// ------------- //

package my.pkg.something;
// client side interface definition...

I changed the name of client-side package and set it as the name of server-side package:

package my.pkg; 
// server side interface definition...

// ------------- //

package my.pkg; // renamed to the name of package in server-side .
// client side interface definition...

and the problem went away.

Coze answered 20/6, 2014 at 20:28 Comment(3)
This answer solved my problem. Do you have any idea of the reason for that being happening?Mcnutt
@RodrigoBorba No! Unfortunately I can't remember it...Coze
Helped me with RMI cache replication in ehCachePuerilism
C
9

I had a working RMI Client and Server for my Java class. I decided to place these into their own packages rather than running as a default package.

After I placed them in their own Packages the java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.lang.ClassNotFoundException: error started happening on connection,.

I put the programs back into the default package and it all started working again.

I realize that there is probably a technical reason for this, but this worked for me!

Cheesy answered 8/8, 2012 at 0:50 Comment(1)
incredible, it worked for me.Vaasta
M
7

It sounds like your not using a security manager:

Have you got a policy file (my.policy):

grant {
  permission java.security.AllPermission;
};

and run your program using

java -Djava.security.manager -Djava.security.policy=/some/path/my.policy MyClass
Morganatic answered 8/9, 2011 at 23:0 Comment(2)
He doesn't need either a SecurityManager or a .policy file to solve this problem, unless he is trying to use the RMI codebase feature, which isn't stated.Idden
EJP please add more information! It sounds quite useful but i don't get it.Sutton
I
3

There are three cases.

  1. If you get the error when binding to the Registry, the Registry doesn't have access to that class on its classpath or via the codebase feature.

  2. If you get the error when looking up the Registry, your client doesn't have access to that class on its classpath or via the codebase feature.

  3. If you are using the codebase feature, that in turn can be caused by the Registry having access to that class on its classpath, which causes it not to use the codebase, which causes loss of the codebase annotation, so your client doesn't know to use the codebase for that class.

  4. If you aren't using the codebase feature, ignore the previous paragraph ;-)

Idden answered 8/9, 2011 at 23:45 Comment(1)
just landed on this...could you kindly explain about the codebase feature that you are talking about?Johnsson
C
2

i solved it with rename package name. the server and client is in two different project , but rather with same package naming.

Clomb answered 24/4, 2017 at 7:13 Comment(1)
This worked for mePlenish

© 2022 - 2024 — McMap. All rights reserved.