WASでEJB。lookupではまる。

結局、別案となるが調べたのでメモ。

    /**
     * WAS EJBリモートアクセスの場合
     */
    public void loginServiceRemote() throws Exception {
        Hashtable<String, String> pdEnv = new Hashtable<String, String>();
        pdEnv.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
        pdEnv.put(Context.PROVIDER_URL, "corbaloc:iiop:localhost:2809");
        Context initialContext = new javax.naming.InitialContext(pdEnv);
        java.lang.Object Obj = (java.lang.Object)initialContext.lookup(
              "ejb/hogeEAR/hogeEJB.jar/HogeServiceImpl#com.hoge.service.IHogeService");
        IHogeService service = (IHogeService)javax.rmi.PortableRemoteObject.narrow(Obj, HogeServiceImpl.class);
        service.exec("arg");
    }
    /**
     * WAS EJBローカルアクセスの場合
     */
    public void loginServiceLocal() throws Exception {
        Hashtable<String, String> pdEnv = new Hashtable<String, String>();
        pdEnv.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
        pdEnv.put(Context.PROVIDER_URL, "iiop://localhost");
        Context initialContext = new javax.naming.InitialContext(pdEnv);
        java.lang.Object Obj = (java.lang.Object)initialContext.lookup(
                "ejblocal:hogeEAR/hogeEJB.jar/HogeServiceImpl#com.hoge.service.IHogeService");
        IHogeService service = (IHogeService)javax.rmi.PortableRemoteObject.narrow(Obj, HogeServiceImpl.class);
        service.exec("arg");
    }