rmi

How to serialize ByteBuffer

时光毁灭记忆、已成空白 提交于 2019-12-01 17:16:52
问题 I wish to send a java.nio.ByteBuffer accross a network using RMI, however ByteBuffer isn't serializable. I've tried the following custom class to no avail: public class NetByteBuffer implements java.io.Serializable { ByteBuffer buffer; public NetByteBuffer(ByteBuffer buffer) { this.buffer = buffer; } public ByteBuffer getByteBuffer() { return this.buffer; } } The client still gets a non-serialzable exception. Any ideas? Thanks 回答1: You can't. You'd better obtain the byte[] and send it instead

How to serialize ByteBuffer

回眸只為那壹抹淺笑 提交于 2019-12-01 17:04:02
I wish to send a java.nio.ByteBuffer accross a network using RMI, however ByteBuffer isn't serializable. I've tried the following custom class to no avail: public class NetByteBuffer implements java.io.Serializable { ByteBuffer buffer; public NetByteBuffer(ByteBuffer buffer) { this.buffer = buffer; } public ByteBuffer getByteBuffer() { return this.buffer; } } The client still gets a non-serialzable exception. Any ideas? Thanks You can't. You'd better obtain the byte[] and send it instead and reconstruct the ByteBuffer on the other side. You are of course losing the advantages of it being a

Java socket EOFException

半世苍凉 提交于 2019-12-01 15:31:08
I use RMI and socket to transfer files between a client set. The problem is when running the code below sometimes i get this exception in client side : java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2671) at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3146) at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:858) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:354) at javafxcyberwind.serverSocket.run(serverSocket.java:38) at java.lang.Thread.run(Thread.java:748) This is a sample

Deserialize remote object to the narrowest accessible class

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 14:52:16
In shared.jar I have: abstract class MyParent { } abstract class MyClass { MyParent getFoo(); } server.jar contains abstract class MyChild extends MyParent { } abstract class MyClassConcrete { MyParent getFoo() {return new MyChild();} } client.jar : MyParent foo = myClass.getFoo(); If all 3 jars are in one classloader everything works well. But client and server are in different JVMs while: JVM-1 contains: server.jar , shared.jar JVM-2 contains: client.jar , shared.jar Client makes call to server. Server returns MyConcreteClass and Java fails to deserialize it ( ClassNotFoundException ). What

Java socket EOFException

会有一股神秘感。 提交于 2019-12-01 13:34:11
问题 I use RMI and socket to transfer files between a client set. The problem is when running the code below sometimes i get this exception in client side : java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2671) at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3146) at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:858) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:354) at

RMI responding very slow

邮差的信 提交于 2019-12-01 13:05:29
I am testing a web application using Java Remote Method Invocation (RMI). When I am connected to internet through dongle, broadband; it takes very long time for the RMI to respond to the request. It takes around 10 seconds in completing the method call. I can also see the data transfer rate rising in the internet connection as soon as I make a method call. So definitely it seems to be making an RMI connection between two internal processes through the external network. While disconnected from internet it responds vary fast, like in few milliseconds. My /etc/hosts file have entry for 127.0.0.1

RMI cannot connect to remote server

夙愿已清 提交于 2019-12-01 11:14:58
问题 I've been plying with RMI recently and while I managed to make it work on locahost I've been having all sorts of problem when trying to use a remote server. Here's the basic code I'm trying to run: Server: public class RmiServer extends UnicastRemoteObject implements RmiServerIntf { public static final String MESSAGE = "Hello world"; public RmiServer() throws RemoteException { } public String getMessage() { return MESSAGE; } public static void main(String args[]) { System.out.println("RMI

RMI responding very slow

試著忘記壹切 提交于 2019-12-01 10:08:05
问题 I am testing a web application using Java Remote Method Invocation (RMI). When I am connected to internet through dongle, broadband; it takes very long time for the RMI to respond to the request. It takes around 10 seconds in completing the method call. I can also see the data transfer rate rising in the internet connection as soon as I make a method call. So definitely it seems to be making an RMI connection between two internal processes through the external network. While disconnected from

Clean way to stop RMI server

 ̄綄美尐妖づ 提交于 2019-12-01 10:00:17
问题 A RMI server which works fine without the stopServer functionality. public class HelloServer extends UnicastRemoteObject implements HelloInterface { private final static int PORT=1102; private final String serverName="server"; private Timer timer; public HelloServer() throws RemoteException { timer = new Timer(); //At this line a new Thread will be created timer.schedule(new StopServerTask(), 5000); } @Override public String serverResponse(String request) throws RemoteException { return

Writing a secure RMI server-client application

為{幸葍}努か 提交于 2019-12-01 09:27:51
I'm writing a server-client application where communication is done over the internet and I have several questions and concerns regarding security. I have done some research and found some posts here useful, but I would like more information. Some related questions I read were: Secure authentication of client over RMI java rmi authentication & security. exportObject makes it public? Is communication in java rmi secure? I have 3 parts to consider: Information exchanged between the client and the server. Authentication of the client. Exploiting a running RMI server (hacking etc.). What I know: