我目前正在使用rmi註冊表使用遠程環境。我的服務器是這樣的:RMI註冊表失敗....異常sais null
import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; public class Server { public static void main(String args[]){ if(args.length"); System.exit(-1); } try{ Registry r=LocateRegistry.getRegistry(); MethodsImp methods=new MethodsImp(); //have the object to be remotely accessed so will bind it to the registry System.out.println("Will register on "+args[0]); r.rebind(args[0], methods); } catch(Exception e){ System.out.println("Something went wrong when registring the methods"); System.out.println(e.getMessage()); System.exit(-1); } } }
當我通過運行該程序:
java -classpath /home/outsider/Desktop/RIM/RIM_TP1_correct/src -Djava.rmi.server.codebase=file:/home/outsider/Desktop/RIM/RIM_TP1_correct/src/ Server regsiter_name
我得到這個:
Will register on regsiter_name Something went wrong when registring the methods null
出於某種原因,當我用r.rebind它拋出一個具有消息null的異常。 之前嘗試運行的程序我做
rmiregistry &
外殼上安裝rmiregistry中。 我找不到我做錯了什麼。 如果有人可以幫助將是巨大的
拋出什麼類型的異常....?嘗試'System.out.println(e.getClass()。getSimpleName());' – Finbarr 2010-04-21 20:36:51
它給NullPointerException ....它似乎是r.rebind不工作,因爲它應該....但我不知道爲什麼 – 2010-04-21 20:41:56
你的代碼不能編譯,你沒有提供堆棧跟蹤。目前的形式無法形容。 – EJP 2016-05-22 03:58:37