» »

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


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

Web services - Neveljavni karakterji v XML

Oddelek: Programiranje
314127 (3239) boolsheat
»

Java - problem povezave na FTP

Oddelek: Programiranje
101181 (1038) igor0203
»

tomcat in datasource

Oddelek: Programiranje
131984 (1741) infiniteLoop
»

[JAVA] zaustavitev niti (threadov)

Oddelek: Programiranje
223170 (3170) morbo
»

Kako pošiljanje datotek v JAVI.

Oddelek: Programiranje
141833 (1704) kopernik

Več podobnih tem