访问jboss上EJB远程接口问题

05-01-17 daquan198163
jboss4.0所在的服务器配双网卡,一个ip:10.75.109.78链接hub供局域网浏览器访问,一个ip:192.168.0.1用来与数据库服务器双机互连,问题是局域网上一个客户端程序试图通过远程接口连接jboss上的EJB时,报错:

javax.naming.CommunicationException. Root exception is java.rmi.ConnectExceptio

n: Connection refused to host: 192.168.0.1; nested exception is:

java.net.ConnectException: Connection refused: connect

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)

。。。。。。。。。。

代码如下:

environment.put(Context.INITIAL_CONTEXT_FACTORY,
                      "org.jnp.interfaces.NamingContextFactory");
      environment.put(Context.URL_PKG_PREFIXES,
                      "org.jboss.naming:org.jnp.interfaces");
      environment.put("java.naming.provider.url",
                      "jnp://" +
                      "10.75.109.78"
                      + ":1099"
                      );
      InitialContext ctx = new InitialContext(environment);
      System.out.println("ctx.lookup(WorkListManager):==========" +
                         "WorkListManager");

而如果把192.168.0.1的网卡禁用掉,就能够正常连接并调用EJB,

请问如何配置jboss才能通过特定的IP连接EJB

daquan198163
2005-01-17 22:22

environment.put(Context.INITIAL_CONTEXT_FACTORY,
                      "org.jnp.interfaces.NamingContextFactory");
      environment.put(Context.URL_PKG_PREFIXES,
                      "org.jboss.naming:org.jnp.interfaces");
      environment.put("java.naming.provider.url",
                      "jnp://" +
                      remoteHost
                      + ":1099"
                      );
      InitialContext ctx = new InitialContext(environment);
      System.out.println("ctx.lookup(WorkListManager):==========" +
                         "WorkListManager");
      Object obj = ctx.lookup("WorkListManager");

      wlManager =
          ((WorkListManagerHome) PortableRemoteObject.narrow(obj,
          WorkListManagerHome.class)).create();

banq
2005-01-20 13:52
代码没什么问题,确认服务器端1099端口打开否?了解一下RMI访问调用机制,需要客户端安全授权;注意有无防火墙屏蔽1099口等。

猜你喜欢