I'm trying to use the rmi registry to get a reference of a remote object. This is my code
void initialize_server () {
//Look for other servers
String[] otherservers = null;
try {
otherservers = Naming.list("//localhost:1099/");
} catch (RemoteException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
}
System.out.println("breakpoint");
if (otherservers != null) {
for (int i = 0; i < otherservers.length; i++) {
System.out.println(otherservers[i]);
IServer ref;
try {
ref = (IServer) Naming.lookup(otherservers[i]);
model.addServer(ref);
} catch (RemoteException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (NotBoundException e) {
e.printStackTrace();
}
}
}
And until here it works fine but it doesn't find any server of course, cos there is none. So when i try to bind one at the rmi like this:
String server_rmi="rmi://localhost/" + servername;
try {
Naming.rebind(server_rmi,this);
} catch (RemoteException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
I get an error that never ends:
java.rmi.ServerError: Error occurred in server thread; nested exception is:
java.lang.UnsupportedClassVersionError: shared/IServer : Unsupported major.minor version 52.0
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:416)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:275)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:252)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:378)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:177)
at server.ServerController.initialize_server(ServerController.java:77)
at server.ServerController.<init>(ServerController.java:29)
at server.ServerStarter.main(ServerStarter.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
The IServer interface is this:
package shared;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.Vector;
public interface IServer extends Remote {
Vector<IClient> Search (String search) throws RemoteException;
void SaveReference (IClient x) throws RemoteException;
}
I'm using ubuntu and the java -version command returns this java version "1.7.0_55" Java(TM) SE Runtime Environment (build 1.7.0_55-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
I've lost two hours on this one and I cant get it to work. I really don't know what to do, please help me.