3

I'm working on a twitter like, using rmi. I work, on Windows and everything works fine.

But on linux I have :

java.rmi.UnmarshalException: error unmarshalling return; nested exception is: 
    java.lang.ClassNotFoundException: server.SimpleBark
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:196)
    ...

This exception pops out on the client side, and it seems that the client does not use the codebase server, the codebase server doesn't receive any connection.

I repeat that everything works fine on Windows, i can't find where this comes from.

Jayan
  • 18,003
  • 15
  • 89
  • 143
Giacogiac
  • 189
  • 1
  • 11
  • Could it be a hostname issue or other related issue if the code works on windows? Did you try specifying the following: -Djava.rmi.server.hostname=ipAddressHere ? – rimero Jun 02 '13 at 15:14
  • I'm working on only one computer, everything works fine on linux except the codebase server and yes i tried -Djava.rmi.server.hostname it didn't change anything – Giacogiac Jun 02 '13 at 15:24

2 Answers2

4

From the JDK 7 guides

From JDK 7 Update 21, the RMI property java.rmi.server.useCodebaseOnly is set to true by default.

From the JDK 7 guides, that hasn't been updated

java.rmi.server.useCodebaseOnly

If this value is true, automatic loading of classes is prohibited except from the local CLASSPATH and from the java.rmi.server.codebase property set on this VM. Use of this property prevents client VMs from dynamically downloading bytecodes from other codebases. This property is ignored in the implementations of 1.2 and 1.2.1 because of a bug.

So it would seem that the version of Java on your Windows machine is out of date. Once updated, the best way to fix this is to include the required classes on the client side rather than dynamically loading classes across the network.

Tom Hawtin - tackline
  • 145,806
  • 30
  • 211
  • 305
  • Thank you, -Djava.rmi.server.useCodebaseOnly=false made the trick. But this is a project for school and I need to dynamically load classes. I there a way to do it safely ? – Giacogiac Jun 02 '13 at 16:47
0

Just remove the classes from the client and registry class paths.

user207421
  • 305,947
  • 44
  • 307
  • 483