1 Reply Latest reply on Jan 24, 2008 3:19 PM by serac

    NameNotFoundException for SLSB Visible in JNDIView

    serac

      We have deployed a service MBean in a SAR within an EAR that needs to perform a JNDI lookup to get resources in both a "Manager" JAR and a "Query" JAR. Simplified package structure:

      EAR
      +- Service SAR
       +- MBean
      +- Manager JAR (JNDI lookup for these resources succeeds)
      +- Query JAR (JNDI lookup fails)
      


      The following code generates a NameNotFoundException when called from our service MBean:

      final InitialContext jndiContext = this.getJndiContext();
      obj = (T) jndiContext.lookup(jndiName);
      


      where jndiName = vt-ejb/PersonQuery/local. This resource is clearly registered in JNDI as shown by the following output from JNDIView:

      Global JNDI Namespace
      
       +- vt-ejb (class: org.jnp.interfaces.NamingContext)
       | +- PersonQuery (class: org.jnp.interfaces.NamingContext)
       | | +- local (proxy: $Proxy215 implements interface edu.vt.middleware.registry.query.person.PersonQueryLocal,interface org.jboss.ejb3.JBossProxy)
       | | +- remote (proxy: $Proxy214 implements interface edu.vt.middleware.registry.query.person.PersonQueryRemote,interface org.jboss.ejb3.JBossProxy)
       | +- EmailManager (class: org.jnp.interfaces.NamingContext)
       | | +- local (proxy: $Proxy134 implements interface edu.vt.middleware.registry.manage.email.EmailManagerLocal,interface org.jboss.ejb3.JBossProxy)
       | | +- remote (proxy: $Proxy133 implements interface edu.vt.middleware.registry.manage.email.EmailManagerRemote,interface org.jboss.ejb3.JBossProxy)
      


      Stack trace:
      javax.naming.NameNotFoundException: vt-ejb/PersonQuery/local
       at org.jboss.ha.jndi.TreeHead.lookup(TreeHead.java:242)
       at org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:155)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java:312)
      ...
      


      What's interesting is that the error message for a NameNotFoundException typically reads "x not bound" for query on a non-existent name; the "not bound" text is conspicuously missing, which suggests that it's not a name resolution problem.

      We are puzzled that a similar JNDI lookup as above, from the same calling context (an MBean), succeeds if we do a lookup on the EmailManager bean using the name vt-ejb/EmailManager/local.

      We are using EJB3 annotations to mark up the beans and register them in JNDI, and the two beans above have exactly the same annotations except EmailManager has a @RunAs(...) annotation. They also occur in different JARs within the same EAR.

      For reference, the annotations on PersonQueryBean follow:
      @Stateless
      @SecurityDomain("EDClient")
      @WebService(name = "PersonQuery",
       endpointInterface =
       "edu.vt.middleware.ed.query.PersonQueryEndpoint")
      @WebContext(contextRoot = "/registryquery",
       transportGuarantee = "CONFIDENTIAL",
       authMethod = "CLIENT-CERT")
      @LocalBinding(jndiBinding = PersonQuery.LOCAL_JNDI_NAME)
      @RemoteBinding(jndiBinding = PersonQuery.REMOTE_JNDI_NAME)
      public class PersonQueryBean extends AbstractQuery
       implements PersonQueryLocal, PersonQueryRemote
      ...
      


      public interface PersonQuery extends PersonQueryEndpoint
      {
       /** local jndi name */
       String LOCAL_JNDI_NAME = "vt-ejb/PersonQuery/local";
      
       /** remote jndi name */
       String REMOTE_JNDI_NAME = "vt-ejb/PersonQuery/remote";
      ...
      




      We would appreciate any suggestions for resolving this issue or investigating it further.

      Thanks,
      Marvin

        • 1. Re: NameNotFoundException for SLSB Visible in JNDIView
          serac

          After careful examination of logger timestamps across several log files, we discovered this was a deployment timing issue. Our MBean JNDI lookup code was executing after the Manager JAR deployed but before the Query JAR deployed, so a lookup on beans in the former succeeded but a lookup on beans in the latter failed. This happened because we missed a dependency in the MBean definition in jboss-service.xml.