2 Replies Latest reply on May 23, 2012 6:02 AM by michael_gronau

    JNDI Referenceable objects are not resolved

    michael_gronau

      Hi,

      I'm still trying to port our application from Jboss 5 to 7. I'm currently using 7.1.2 Final (current 7.2 has some bugs, so I cannot use it at the moment) and in our app we are using the Referenceable/Reference support of the jndi context. What I mean is, in JBoss 5 i can bind an object to the JNDI context, which implements the javax.naming.Referenceable interface. When i lookup this object the getReference() method is invoked and then an object instance will be created with the given ObjectFactory of the Reference. All this doesnt work in JBoss 7, is this a bug or what do i have to do in JBoss 7.x?

       

      With best regards,

       

      Michael Gronau

        • 1. Re: JNDI Referenceable objects are not resolved
          jaikiran

          Michael Gronau wrote:

           

           

          I'm currently using 7.1.2 Final (current 7.2 has some bugs, so I cannot use it at the moment)

          Can you please tell us what those bugs are?

           

           

          Michael Gronau wrote:

           

          What I mean is, in JBoss 5 i can bind an object to the JNDI context, which implements the javax.naming.Referenceable interface. When i lookup this object the getReference() method is invoked and then an object instance will be created with the given ObjectFactory of the Reference. All this doesnt work in JBoss 7, is this a bug or what do i have to do in JBoss 7.x?

           

          Can you post some relevant code and exception stacktrace if any which shows what the issue is? More specifically, what do you mean by "doesn't work"?

          • 2. Re: JNDI Referenceable objects are not resolved
            michael_gronau

            The bug, stopping me from using it, is a problem with infinispan 5.1.4 and higher together with JBoss. I have reported this bug to the infinispan team and its on the way to fix it.

             

            The following pseude code would work with JBoss 5 but not with JBoss 7:

             

            public class TestObjectReferenceable

                implements Referenceable, Serializable

            {

                private static final long serialVersionUID = 1L;

             

                private String nameOfTheObject;

             

                public TestObjectReferenceable(String nameOfTheObject)

                {

                    this.nameOfTheObject = nameOfTheObject;

                }

             

                @Override

                public Reference getReference() throws NamingException

                {

                    System.out.println("GET REFERENCE...!!!!!!!!!");       

                    Reference ref = new Reference(TestObject.class.getName(), new StringRefAddr("name", this.nameOfTheObject), TestObjectFactory.class.getName(), null);

                    return ref;

                }

             

            }

             

            When I bind an instance of this class to the jndi context, the getReference() method is not invoked.

             

            EDIT: I have tried to directly bind the Reference object to the jndi context. Now when I lookup this object on the server side the instance is correctly resolved and created, but this is not done on the client side. There I just get a javax.naming.Reference object.