RMI exception: Error unmarshalling return header; nested exception is:问题
新接触 按照教程 调试了一下午 最后归结到这个错误。。
客户机和server端接口
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Hello extends Remote {
String sayHello() throws RemoteException;
}
服务器端实现类
import java.rmi.registry.*;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;
public class HelloImpl extends UnicastRemoteObject
implements Hello {
public HelloImpl() throws RemoteException {
super();
}
public String sayHello () {
return "Hello World!";
}
public static void main (String args []) {
// Create and install a security manager
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try {
HelloImpl obj = new HelloImpl();
Registry r = LocateRegistry.createRegistry(6566);
r.bind("HelloServer", obj);
// Bind this object instance to the name "HelloServer"
System.out.println("HelloServer bound in registry");
} catch (Exception e) {
System.out.println("HelloImpl err: " + e.getMessage());
e.printStackTrace();
}
}
}
客户端调用类
import java.rmi.* ;
import java.net.* ;
import java.io.*;
import java.rmi.registry.*;
public class HelloApplet {
public static void main(String[] args)
{
Hello obj = null ;
try {
Registry r = LocateRegistry.getRegistry("113.55.35.206", 6566);
obj= (Hello) r.lookup("/HelloServer");
String message = obj.sayHello();
System.out.println("message"+message);
} catch (Exception e) {
System.out.println("HelloApplet exception: " +
e.getMessage());
e.printStackTrace();
}
}
}
客户机和server端接口
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Hello extends Remote {
String sayHello() throws RemoteException;
}
服务器端实现类
import java.rmi.registry.*;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;
public class HelloImpl extends UnicastRemoteObject
implements Hello {
public HelloImpl() throws RemoteException {
super();
}
public String sayHello () {
return "Hello World!";
}
public static void main (String args []) {
// Create and install a security manager
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try {
HelloImpl obj = new HelloImpl();
Registry r = LocateRegistry.createRegistry(6566);
r.bind("HelloServer", obj);
// Bind this object instance to the name "HelloServer"
System.out.println("HelloServer bound in registry");
} catch (Exception e) {
System.out.println("HelloImpl err: " + e.getMessage());
e.printStackTrace();
}
}
}
客户端调用类
import java.rmi.* ;
import java.net.* ;
import java.io.*;
import java.rmi.registry.*;
public class HelloApplet {
public static void main(String[] args)
{
Hello obj = null ;
try {
Registry r = LocateRegistry.getRegistry("113.55.35.206", 6566);
obj= (Hello) r.lookup("/HelloServer");
String message = obj.sayHello();
System.out.println("message"+message);
} catch (Exception e) {
System.out.println("HelloApplet exception: " +
e.getMessage());
e.printStackTrace();
}
}
}
...全文
相关推荐
JAVA_RMI_实例.pdf
(hello.say()); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); e.printStackTrace
rmi使用实例
); } catch (Exception e) { System.out.println("Error: " + e); } }}```#### 四、RMI 实例总结通过上述步骤,我们成功地实现了基于
启动tomcat时 错误: 代理抛出异常 : java.rmi.server.ExportException: Port already in use: 1099的解决办法
"启动tomcat时遇到的端口冲突问题及解决方案"在运行Java应用程序,特别是像Tomcat这样的服务器时,可能会遇到"Port already in use"的错误,这通常表示指定的端口已被其
银海软件java面试题
### 银海软件Java面试题解析#### Error与Exception有什么区别?
Java高级工程师笔试题11.27.doc
Error和Exception的区别: - Error是程序无法恢复的严重问题,如系统崩溃、内存不足等,通常由系统报告。


