3 Replies Latest reply on Nov 23, 2012 1:40 AM by Stefan Block

    Remote EJB Connection to Websphere

    P Shamiri Newbie

      How to lookup EJBs in Websphere from Jboss?

        • 1. Re: Remote EJB Connection to Websphere
          jaikiran pai Master

          That question will most likely be better answered in WebSphere forums. Typically, you'll use JNDI to lookup the EJB hosted on WebSphere and it'll require certain JNDI context properties required for WebSphere.

          • 2. Re: Remote EJB Connection to Websphere
            P Shamiri Newbie

            The following code works for as a standalone client.

                Properties props = new Properties();
                props.put("java.naming.factory.initial", "com.ibm.websphere.naming.WsnInitialContextFactory");
                props.put("java.naming.provider.url", "corbaloc::hostxxx:1031");

                System.out.println("Running IIOP test...");
                Context intCtx = new InitialContext(props);
                System.out.println("Found IIOP InitialContext");
                Object obj = intCtx.lookup( "cell/clusters/Services_Cluster/ejb/FacadeBean") ;
                System.out.println("Context Lookup found ");
                FacadeBeanHome remote = (FacadeBeanHome) javax.rmi.PortableRemoteObject.narrow(obj, FacadeBeanHome.class);
                System.out.println("Found IIOP EJB Remote");
                FacadeBean bean= (FacadeBean) remote.create();


            However, when I used the JNDI context as above in my war project and deploy in Jboss AS 7, I've got an error as below:


            01:01:22,383 ERROR [stderr] (http-- javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory com.ibm.websphere.naming.WsnInitialContextFactory from classloader ModuleClassLoader for Module "deployment.TestWeb-jboss.war:main" from Service Module Loader

            01:01:22,386 ERROR [stderr] (http--  at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)

            01:01:22,388 ERROR [stderr] (http--  at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:664)

            01:01:22,390 ERROR [stderr] (http--  at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

            01:01:22,391 ERROR [stderr] (http--  at javax.naming.InitialContext.init(InitialContext.java:223)



            • 3. Re: Remote EJB Connection to Websphere
              Stefan Block Newbie

              You may for example for WebSphere 7 do following Steps:


              1) Save the current ClassLoader:

              ClassLoader oldCL = Thread.currentThread().getContextClassLoader();


              2) Load IBM Thin Client and ORB jars

              URLClassLoader URLC = new URLClassLoader(U, ClassLoader.getSystemClassLoader());




              3) Setting JNDI-Properties as you did before


              4) Do whatever you have to do


              5) Seeting the ClassLoader to the saved value