Forum » Programiranje » RMI
RMI
mov ax 0x7c0 ::
Zdravo!
Rad bi napisal preprost RMI server in Client (no ja, sem jih že). Imam pa problem z zagonom Clienta! Server mi dela! Ko zaženem Client z ukazom:
java -Djava.security.policy="c:\path\"policy Client
mi javi tole izjemo:
HelloImpl err: Error unmarshaling return header; nested exception is:
java.io.EOFException
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception
is:
java.io.EOFException
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
203)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:350)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at Client.main(Client.java:15)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:333)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
189)
... 3 more
kaj to za vraga pomeni?
koda HelloImpl.java:
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.server.RemoteServer;
import java.rmi.server.ServerNotActiveException;
public class HelloImpl extends UnicastRemoteObject implements Hello
{
public HelloImpl() throws RemoteException {
super();
}
public String sayHello(String arg) throws RemoteException {
String client;
try {
client = RemoteServer.getClientHost();
}
catch (ServerNotActiveException e) {
client = "*unknown*";
}
System.out.println("Server received from host " + client + " following message: " + arg);
return "Server says hi!";
}
}
koda Client.java:
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
public class Client
{
public static void main(String args[]) {
// get host where registry is running
String host = args.length>0 ? args[0] : "localhost";
try {
// get reference to registry
Registry registry = LocateRegistry.getRegistry(host, 5001);
// connect to remote object via registry
Hello obj = (Hello)registry.lookup("/HelloServer");
// invoke remote method
String ret_value = obj.sayHello("Hi from client!");
// print return value
System.out.println("Message from server: " + ret_value);
}
catch (Exception e) {
System.out.println("HelloImpl err: " + e.getMessage());
e.printStackTrace();
}
}
}
prosim če keri vidi kakšno napako naj pove kaj je! Ker se že Fu**m cel dan s tem, čitam toturiale pa nikjer ni opisam ta problem...
lp, Slavc
Rad bi napisal preprost RMI server in Client (no ja, sem jih že). Imam pa problem z zagonom Clienta! Server mi dela! Ko zaženem Client z ukazom:
java -Djava.security.policy="c:\path\"policy Client
mi javi tole izjemo:
HelloImpl err: Error unmarshaling return header; nested exception is:
java.io.EOFException
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception
is:
java.io.EOFException
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
203)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:350)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at Client.main(Client.java:15)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:333)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
189)
... 3 more
kaj to za vraga pomeni?
koda HelloImpl.java:
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.server.RemoteServer;
import java.rmi.server.ServerNotActiveException;
public class HelloImpl extends UnicastRemoteObject implements Hello
{
public HelloImpl() throws RemoteException {
super();
}
public String sayHello(String arg) throws RemoteException {
String client;
try {
client = RemoteServer.getClientHost();
}
catch (ServerNotActiveException e) {
client = "*unknown*";
}
System.out.println("Server received from host " + client + " following message: " + arg);
return "Server says hi!";
}
}
koda Client.java:
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
public class Client
{
public static void main(String args[]) {
// get host where registry is running
String host = args.length>0 ? args[0] : "localhost";
try {
// get reference to registry
Registry registry = LocateRegistry.getRegistry(host, 5001);
// connect to remote object via registry
Hello obj = (Hello)registry.lookup("/HelloServer");
// invoke remote method
String ret_value = obj.sayHello("Hi from client!");
// print return value
System.out.println("Message from server: " + ret_value);
}
catch (Exception e) {
System.out.println("HelloImpl err: " + e.getMessage());
e.printStackTrace();
}
}
}
prosim če keri vidi kakšno napako naj pove kaj je! Ker se že Fu**m cel dan s tem, čitam toturiale pa nikjer ni opisam ta problem...
lp, Slavc
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | Web services - Neveljavni karakterji v XMLOddelek: Programiranje | 4161 (3273) | boolsheat |
» | Java - problem povezave na FTPOddelek: Programiranje | 1190 (1047) | igor0203 |
» | tomcat in datasourceOddelek: Programiranje | 2026 (1783) | infiniteLoop |
» | [JAVA] zaustavitev niti (threadov)Oddelek: Programiranje | 3183 (3183) | morbo |
» | Kako pošiljanje datotek v JAVI.Oddelek: Programiranje | 1844 (1715) | kopernik |