I started coding for a client-server machine on
java, using RMI(Remote Method Invocation). The code works fine on my machine. It basically gives commands to the client machine and the client processes these commands and responds accordingly. After executing the command, the machine sends back its status to the server. An example would be, the server requests for an image feed from the client and the client returns an image to the server.
I used git to clone the current project and push it to another machine. When I execute the client side code, it works completely fine and the other machine(to which I pushed the source) responds the way it should.
However, when I run the server side code to code on the other machine, it gives a cryptic error that says:
C:\Users\RdX\Desktop\Thiswa
javax.naming.NamingException [Root exception is java.rmi.ServerError: Error occurred in server
thread; nested exception is:
java.lang.UnsupportedClassVersionError: javadrone/Server (Unsupported major.minor version 51.0)]
at com.sun.jndi.rmi.registry.RegistryContext.rebind(RegistryContext.java:159)
at com.sun.jndi.toolkit.url.GenericURLContext.rebind(GenericURLContext.java:249)
at javax.naming.InitialContext.rebind(InitialContext.java:427)
at javadrone.server.ServerImpl.<init>(ServerImpl.java:46)
at javadrone.server.DroneServer.<init>(DroneServer.java:45)
at javadrone.server.DroneServer.main(DroneServer.java:84)
Caused by: java.rmi.ServerError: Error occurred in server thread; nested exception is:
java.lang.UnsupportedClassVersionError: javadrone/Server (Unsupported major.minor version 51.0)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:349)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:207)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
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:534)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.rebind(RegistryContext.java:157)
... 5 more
Caused by: java.lang.UnsupportedClassVersionError: javadrone/Server (Unsupported major.minor version 51.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at java.lang.ClassLoader.loadClass(ClassLoader.java:282)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
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:639)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:309)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:241)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1469)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1432)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:342)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:207)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
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:534)
To be specific,
namingContext.rebind(RMI_PROT + name, ServerImpl.this)
is the line that generates the error.
I searched a lot of places and they say that when the JDK compliler is of a higher version than the JRE version, it may produce such an error.
However I uninstalled all prior JDKs and JREs and recompiled the code after installing JDK 7.03. It still gives the same exception.
Why is this happening and how do I correct it?
[NK: Added code tags,
UseCodeTags]