1 Reply Latest reply on Jan 31, 2017 4:44 AM by Wolf-Dieter Fink

    Is it possible to make local JNDI lookup between different EARs on same Wildfly?

    Oleg Gritsak Newbie

      Hello!

       

      Spent several days with no positive result. Maybe I'm trying to do something impossible? Please, enlighten me, dear sirs!

       

      I want to implement some sort of microservices with EJBs and it should work at full speed, so remote JNDI is unacceptable.

       

      I've make simplest EJB with annotations:

      @LocalBean
      @Singleton

       

      deployed it to Wildfly (tried 10.0 and 10.1), got JNDI names

       

      java:global/empService/EmployeemanagerBean!model.ejbs.EmployeemanagerBean
      java
      :app/empService/EmployeemanagerBean!model.ejbs.EmployeemanagerBean
      java
      :module/EmployeemanagerBean!model.ejbs.EmployeemanagerBean
      java
      :global/empService/EmployeemanagerBean
      java
      :app/empService/EmployeemanagerBean
      java
      :module/EmployeemanagerBean

       

      In second EJB I try to lookup with

       

      try {
        
      final Hashtable jndiProperties = new Hashtable();
         jndiProperties
      .put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        
      final Context context = new InitialContext(jndiProperties);
        
      EmployeemanagerBean sm = (EmployeemanagerBean) context.lookup("java:global/empService/EmployeemanagerBean!model.ejbs.EmployeemanagerBean");
         } catch (NamingException e) {
        
      System.out.println(e.toString());
        
      return;
      }

       

      but only get Class Cast Exceptions.

       

      java.lang.ClassCastException: model.ejbs.EmployeemanagerBean$$$view38 cannot be cast to model.ejbs.EmployeemanagerBean

       

      Am I doing something wrong? Does anybody use this?