Jboss客户端连接EJB,javax.naming.CommunicationException [Root exception is java.rmi.Co

在使用远程连接,调用ejb过程中,出现异常javax.naming.CommunicationException [java.rmi.ConnectException: Connection refused to host: 127.0.0.1]。远程服务器为Linux,jboss-4.0.3.



2008-05-22 11:07:19 ERROR [http-8080-Processor24] (?:?) - javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
    java.net.ConnectException: Connection refused: connect]
javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
    java.net.ConnectException: Connection refused: connect]
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:663)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:520)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at com.ccit.nwca.webapp.proxy.RemoteServiceLocator.getHome(Unknown Source)
    at com.ccit.nwca.webapp.proxy.CertTabProxy.getCertByCertSn(Unknown Source)
    at com.ccit.neg.node.rawebproxy.business.client.UnitKeyRecoverBl.userentform(UnitKeyRecoverBl.java:42)
    at com.ccit.neg.web.controller.operatorservice.realletter.ResumeKeyAction.execute(ResumeKeyAction.java:67)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

原因:
客户端程序向服务端请求一个对象的时候,返回的stub对象里面包含了服务器的hostname,客户端的后续操作根据这个hostname来连接服务器端。
查看linux的hostname配置。hostname -i,
如果返回的是127.0.0.1,客户端肯定会抛如标题的异常了。

解决办法:
1:修改hostname.
vi /etc/hosts
将 127.0.0.1 改为真实地址,如:192.168.100.72。这样客户端就能得到真实的ip了。
2:在启动jboss时显示指定hostname.
如:nohup ./run.sh --host="192.168.100.72" &

使用1或2即可解决此异常.

你可能感兴趣的:(java,linux,jboss,struts,ejb)