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:
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.
Thank you for your reply. I'll try to use other methods to do my job.
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 ?
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
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 ?