有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在远程GlassFish中查找EJB组件时,我得到了一个本地组件

我对远程接口的JNDI查找有问题 有两台服务器: -第一主服务器; -第二个从属服务器(将不止一个,但现在只有一个); 主服务器应该连接到从服务器以更新元数据,但当它查找远程接口时,会得到一个本地接口(两台服务器具有相同的接口)

接口声明

@Remote
public interface IMetadataRemote {

实施

@Remote(IMetadataRemote.class)
@Stateless(mappedName = "MetadataSync")
public class MetadataRemoteImpl implements IMetadataRemote {

查找代码:

    Properties jndiProps = new Properties();

    jndiProps.put("java.naming.factory.initial", "com.sun.enterprise.naming.impl.SerialInitContextFactory");
    jndiProps.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
    jndiProps.put("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");

    jndiProps.setProperty("org.omg.CORBA.ORBInitialHost", serviceIp);
    jndiProps.setProperty("org.omg.CORBA.ORBInitialPort", servicePort);

    Context ctx = new InitialContext(jndiProps);
    IMetadataRemote metadataRemote = (IMetadataRemote) ctx.lookup("MetadataSync");

我该怎么做才能让它工作


共 (0) 个答案