4 Replies Latest reply on Jun 23, 2004 5:27 AM by sedj

    Problems binding JNDI references to non-serializable objects

    sedj

      Hi,

      I am having trouble binding a non-serializable object under the JNDI context java:comp/env. I have tried local EJB, JCA, from a webapp, and using jboss-compliant mbeans.

      Every time I try to bind the object, and intialize it, JBoss trys to serialize it, and then errors with a NotSerializableException.

      What is the best way to bind a non-serializable object to a JNDI context ?

      Thanks for any help

      sedj.

        • 1. Re: Problems binding JNDI references to non-serializable obj
          mikefinn

          I assume your need to to bind it into the 'local' or in-JVM tree (otherwise it will need to serialize/deserialize). Check out NonSerializableObjectFactory in jboss naming.

          mike

          • 2. Re: Problems binding JNDI references to non-serializable obj
            sedj

            Hi mikefinn.

            Thankyou for your reply ...

            Yes I have no wish to serialize this object, or export it over some connector/RMI etc to another JVM.

            I looked for NonSerializableObjectFactory on the web, and only found one link for it :
            http://www.mail-archive.com/jboss-development@lists.sourceforge.net/msg05393.html//www.mail-archive.com/jboss-development@lists.sourceforge.net/msg05393.html

            I am a little confused on how I should use this object. Would you be able to give me a pointer towards how I should implement the use of this class - ie how I should configure the deployment - there seems to be a wealth of .xml config files involved in JBoss, and even if you are a fairly competent Java programmer, I find the config files hard going if you step outside the standard deployment examples (in the purchased JBoss manual).

            To give you an idea of how I configured Tomcat(4 & 5), for this kind of thing to work, I implemented javax.naming.spi.ObjectFactory, and then added under the server.xml tag a which fired this implemented factory class. This was the kind of thing I was looking for in JBoss, and the NonSerializableObjectFactory you mentioned seems to be along those lines, but I am unsure of the config files involved (I had tried adding these tag settings in the embedded tomcat config, but it seemed to ignore them) ...

            Thanks again for any pointers.

            • 3. Re: Problems binding JNDI references to non-serializable obj
              sedj

              Hi,

              I just did a search for NonSerializableObjectFactory in the jboss distribution (JBoss 3 and also 2), and can find no reference to that class at all ...

              • 4. Re: Problems binding JNDI references to non-serializable obj
                sedj

                Hi,

                Just in case anyone runs into this prblem, I managed to fix it by :

                Its not NonSerializableObjectFactory you need to use but NonSerializableFactory :

                http://www.thecortex.net/clover/eg/jboss/report/org/jboss/naming/NonSerializableFactory.html

                JBoss seems to maintain two JNDI trees - one in which objects bound to it must be serializable - this is the "normal" context returned by a "new InitialContext()" type call (from within the container). The other tree is a non-serializable map, on which you may bind objects via the helper class NonSerializableFactory. The two trees a separate, so if you bind an object under the non-serializable tree, these cannot be accessed via the normal JNDI tree.

                Thanks to mikefinn who nudged in the right direction !