远程EJB jndi查找失败

时间:2017-03-19 09:39:34

标签: java-ee glassfish ejb jndi

尝试访问glassfish 4服务器上的远程EJB。查找失败。运行在不同的JDK的Glassfish。怎么了? SDK是IntelliJ IDEA。

我在这里:

RobertImpl__3_x_Internal_RemoteBusinessHome__: javax.naming.Reference
PhoenixImpl!robert.phoenix.PhoenixRemote: javax.naming.Reference
RobertImpl!robert.phoenix.PhoenixLocal: com.sun.ejb.containers.JavaGlobalJndiNamingObjectProxy
RobertImpl!robert.phoenix.PhoenixRemote: javax.naming.Reference
PhoenixImpl!robert.phoenix.PhoenixLocal: com.sun.ejb.containers.JavaGlobalJndiNamingObjectProxy
PhoenixImpl__3_x_Internal_RemoteBusinessHome__: javax.naming.Reference
Command list-jndi-entries executed successfully.

ejb模块名称ejbTest

客户代码:

public class Main {
    public static void main(String[] args) throws NamingException {
        Properties props = new Properties();
        props = new Properties();
        props.setProperty("java.naming.factory.initial",
                "com.sun.enterprise.naming.SerialInitContextFactory");
        props.setProperty("java.naming.factory.url.pkgs",
                "com.sun.enterprise.naming");
        props.setProperty("java.naming.factory.state",
                "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
        props.setProperty("org.omg.CORBA.ORBInitialHost", "127.0.0.1");
        props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
        InitialContext ctx = new InitialContext(props);

        PhoenixRemote phoenix = (PhoenixRemote) ctx.lookup("java:global/ejbTest/RobertImpl!robert.phoenix.PhoenixRemote");
        return;
    }
}

堆栈跟踪:

Exception in thread "main" javax.naming.NamingException: Lookup failed for 'java:global/ejbTest/RobertImpl!robert.phoenix.PhoenixRemote' in SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, org.omg.CORBA.ORBInitialHost=127.0.0.1, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacerobert.phoenix.PhoenixRemote [Root exception is java.lang.ClassNotFoundException: robert.phoenix.PhoenixRemote]]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at Main.main(Main.java:23)
Caused by: javax.naming.NamingException: ejb ref resolution error for remote business interfacerobert.phoenix.PhoenixRemote [Root exception is java.lang.ClassNotFoundException: robert.phoenix.PhoenixRemote]
    at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:433)
    at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:75)
    at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
    at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:527)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:487)
    ... 3 more
Caused by: java.lang.ClassNotFoundException: robert.phoenix.PhoenixRemote
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
Disconnected from the target VM, address: '127.0.0.1:60340', transport: 'socket'
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:685)
    at com.sun.ejb.EJBUtils.loadGeneratedRemoteBusinessClasses(EJBUtils.java:462)
    at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:413)
    ... 7 more

0 个答案:

没有答案