5 Replies Latest reply on Aug 13, 2009 9:17 AM by jaikiran

    JNDI names with a leading /

    jaikiran

      I have a fix for https://jira.jboss.org/jira/browse/EJBTHREE-1884 in which, i now bind the remote ProxyFactory to the JNDI. A local testsuite run after this fix, has exposed a couple of other issues, one of which is in the testcases. The other one is related to clustered stateful beans loadbalancing which is have to investigate a bit more (to understand why it was expected to work the way its currently configured).

      The testsuite issue i am talking about is in the org.jboss.ejb3.test.jms.managed.unit.ManagedTestCase which deploys a JMSTestBean with a remote jndi binding for the session bean:

      <session>
       <ejb-name>JMSTest</ejb-name>
      
       <resource-ref>
       <res-ref-name>jms/MyConnectionFactory</res-ref-name>
       <resource-name>connectionfactoryref</resource-name>
       </resource-ref>
       <resource-ref>
       <res-ref-name>jms/MyQueue</res-ref-name>
       <resource-name>queueref</resource-name>
       </resource-ref>
      
       <jndi-name>/jms-test-ejbs/JMSTest</jndi-name>
       </session>
      


      Notice the leading / in the JNDI name. This results in our proxy-impl generating the jndi name for the default business interface as:

      /jms-test-ejbs/JMSTest - EJB3.x Default Remote Business Interface


      And the remote proxyfactory being bound in JNDI and registered in MC with the following key:

      ProxyFactory/jms-managed/JMSTest//jms-test-ejbs/JMSTest


      Notice the double // in the name. This binds fine in JNDI:

      +- ProxyFactory (class: org.jnp.interfaces.NamingContext)
       |
       +- jms-managed (class: org.jnp.interfaces.NamingContext)
       | | +- JMSTest (class: org.jnp.interfaces.NamingContext)
       | | | +- jms-test-ejbs (class: org.jnp.interfaces.NamingContext)
       | | | | +- JMSTest (proxy: $Proxy257 implements interface


      But when the ProxyFactory is looked up in the JNDI, it fails with NameNotFoundException:

      10:10:31,701 ERROR [STDERR] javax.naming.NameNotFoundException: not bound
      10:10:31,701 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
      10:10:31,701 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)


      While doing the lookup, it internally splits the names on the / and obviously runs into this exception because of the double //.

      IMO, we should fix this by our jndi binding logic (JNDISessionRegistrarBase) to strip any leading /. But what do others think? Possible options are:

      1) Change the testcase to not use the leading / in the jndi-name. (Not an ideal fix, since end users too might end up with this exception if they do something similar).

      2) Fix our jndi binding code. I think this is the ideal solution

      3) Change the name lookup code (in jboss-naming) to parse this differently. I guess, this should not even be an option, since its not the responsibility of that piece of code to do the cleaning :)



        • 1. Re: JNDI names with a leading /
          alrubinger

          So it binds something it cannot lookup. :)

          We haven't documented any support for absolute JNDI references (everything goes into global JNDI anyway), so I don't think we much need to worry about backwards compatibility for breaking user's cases (like our test is). My personal opinion is that we should throw some descriptive error if the first character of the jndiName is '/'.

          However, if we wanna be nice, we could just as easily remove all leading "/" from the String (recursively until done).

          S,
          ALR

          • 2. Re: JNDI names with a leading /
            jaikiran

             

            "ALRubinger" wrote:

            My personal opinion is that we should throw some descriptive error if the first character of the jndiName is '/'.

            However, if we wanna be nice, we could just as easily remove...


            Maybe a combination of both - Log a WARN message telling the user that the jndi name will be stripped of the leading / and we then go ahead remove those leading / while binding.

            "ALRubinger" wrote:

            all leading "/" from the String (recursively until done).



            Good point - Hadn't thought of the multiple leading / case :)




            • 3. Re: JNDI names with a leading /
              alrubinger

              Yeah, warn of idiocy, then correct them :)

              S,
              ALR

              • 4. Re: JNDI names with a leading /
                wolfc

                A leading '/' is allowed (http://java.sun.com/j2se/1.5.0/docs/api/javax/naming/CompositeName.html), but we got it implemented horrible wrong.

                The easiest fix is removing the leading '/' before binding the ProxyFactory.

                At the end of the day nobody should use a leading '/', unless they really really want to. :-)

                • 5. Re: JNDI names with a leading /
                  jaikiran

                   

                  "wolfc" wrote:


                  At the end of the day nobody should use a leading '/', unless they really really want to. :-)


                  It's just a part of the real issue :-) Until we fix the handling of the CompositeNames in our jboss naming impl to follow the http://java.sun.com/j2se/1.5.0/docs/api/javax/naming/CompositeName.html specification, no one (even end-users) can specify their bindings of the form:

                  abc//xyz


                  Adjacent "/" are expected to be handled as empty components. The naming impl fails to do that currently.