0 Replies Latest reply on Mar 18, 2015 7:33 AM by Vinay Basavaraj

    Look Up Remote EJB

    Vinay Basavaraj Newbie

      Hi

       

      I want to look up a EJB deployed on JBoss 5 in a different machine, I want to lookup that EJB in my local application deployed on JBoss 6.

       

      I have the jndi name for the Remote EJB. I tried writing the code below unsuccessfully.

       

      public class EJBClient {

       

         

          public static void main(String[] args) throws Exception {

              testRemoteEJB();

       

          }

       

          private static void testRemoteEJB() throws NamingException {

       

             // final SampleBeanRemote ejb = lookupRemoteEJB();

              //String s = ejb.echo("Frank");

              //System.out.println(s);

              lookupRemoteEJB();

          }

       

          @SuppressWarnings({ "unchecked", "unused" })

          private static void lookupRemoteEJB() throws NamingException {

              @SuppressWarnings("rawtypes")

              final Hashtable jndiProperties = new Hashtable();

              jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

               final Context context = new InitialContext(jndiProperties);

       

       

              final String appName = "";

              final String moduleName = "espn-personnelmanager-ejb";

              final String distinctName = "";

              //final String beanName = SampleBeanRemoteImpl.class.getSimpleName();

       

             // final String viewClassName = SampleBeanRemote.class.getName();

              System.out.println("Looking EJB via JNDI ");

               System.out.println(context.lookup("ejb:espn-personnelmanager-ejb/PersonnelManagerBean! com.espn.esc.personnel.ejb.PersonnelManager"));

              PersonnelManager personnelManager = (PersonnelManager)context.lookup("ejb:espn-personnelmanager-ejb/PersonnelManagerBean! com.espn.esc.personnel.ejb.PersonnelManager");

             // return (SampleBeanRemote) context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

       

                }

      }

       

      Please any help or suggestions would be greatly appreciated