4 Replies Latest reply on Apr 9, 2004 12:46 AM by tiim

    How to get objects which is binded using NonSerializableFact

    tiim Newbie

      I tried use the NonSerializableFactory 's rebind method to bind a non serializable object into a Jndi name, however , when I try to get it out of jndi in a client program out of the vm which jboss is in , I get a null.
      I've read the NonSerializableFactory's api doc, it says that :The binding will only be valid for the lifetime of the VM in which the JNDI nitialContext lives.
      I'm not sure whether this means that using this NonSerializableFactory you could only access the object binded within the vm ?
      Or I've to do something special to get a object which is binded by this Factory ?
      Any reply will be appreciated !

        • 1. Re: How to get objects which is binded using NonSerializable
          Adrian Brock Master

          This question gets asked a lot. Frankly I'm tired of explaining it. :-)

          NonSerializable means you cannot convert the object into a byte stream - one
          of the requirements for remote access.
          If you look at the implementation it is a cheat. It binds a serializable object
          that knows how to get back to the object referenced (but only inside the same VM).

          There are a number of ways to get remote access to an object:
          1) RMI
          2) EJBs
          3) Corba
          4) JBoss invokers over multiple protocols (see chapter 2 of the admin docs)
          5) Servlets or JMS but you'll have to write your own plumbing code
          6) Poor man's version - Just bind a serializable object into jndi - the client
          gets a copy which when modified does not change the version on the server.


          • 2. Re: How to get objects which is binded using NonSerializable
            tiim Newbie

            Thank you for your reply. I'll try to use other methods to do my job.

            • 3. Re: How to get objects which is binded using NonSerializable
              tiim Newbie

              I 've walked around this problem by write a stateless session bean (in the same vm with the nonserializable object)to delegate the access to the nonserializable object. It works in Jboss now. However when I do the same thing in Websphere AS, when the session bean get the object out from jndi and cast it, there will be a exception ClassCastException: javax.naming.Reference.
              I know actually in NonSerializableFactory it actually bind a reference object to this name, but I don't know why in Jboss it could be cast to the class I desired directly, while in WAS I couldn't. Further How could I get the object in WAS ?
              Thank you.

              • 4. Re: How to get objects which is binded using NonSerializable
                tiim Newbie

                I look into the log , found messages like this:
                A Reference object looked up from the context "localhost/nodes/localhost/servers/server1" with the name "quartz" was sent to the JNDI Naming Manager and was returned unprocessed. Reference data follows:
                Reference Factory Class Name: org.jboss.naming.NonSerializableFactory
                Reference Factory Class Location URLs:
                Reference Class Name: org.quartz.impl.StdScheduler
                Type: nns
                Content: quartz

                I think the problem is that the WAS classloader couldn't find the NonSerializableFactory(The Reference object created with an empty fourth argument which set the url for the location of factory to null). But after I putting the jboss.jar into the WAS 's lib path,and restart the Server it doesn't help.
                Could you give me some help ?
                Or should I specify a url for the jboss.jar ?