I have an RemoteObject which bounds to JBoss AS as XYZServer from Standalone 
java Application.

  | public interface PBORequest extends Remote, Referenceable 
  | {
  | public static final int SERVER_RUNNING = 0;
  | public static final int SERVER_SHUTDOWN_AND_RESTART = 1;
  | public static final int SERVER_SHUTDOWN_AND_EXIT = 2;
  | ....
  | ....
  | }
  | 
  | public class PBORequestServer implements PBORequest
  | {
  | private Connection cn = null;
  | private InitialContext ctx;
  | private DataSource ds;
  | private long lJobId;
  | private Properties configProps, configSettings;
  | private ThreadGroup pboThreadGrp, currThreadGrp, restartedJobThreadGrp;
  | private static Hashtable htThreadGrps = new Hashtable();
  | ......
  | ......
  | 
  |     public Reference getReference() throws NamingException
  |     {
  |         return new Reference(PBORequestServer.class.getName());
  |     }
  | 
  |     public void startup()
  |     {
  |         Hashtable p = getContextProperties()
  |         ctx = new InitialContext(p);
  |         try
  |         {
  |             ctx.rebind(XYZServer, this);
  |          }
  |      }
  |     private Hashtable getContextProperty()
  |     {
  |         Hashtable h = new Hashtable();
  |         h.put (Context.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
  |         h.put(Context.PROVIDER_URL,  "localhost:1099");
  |         return h;
  |     }
  | }
  | 

Now we have a StatelessSessionBean deployed on JBoss AS, which lookup for this 
XYZServer as 

  | private PBORequest getPBO() throws NamingException
  | {
  |     PBORequest pbo = null;
  |     try
  |      {
  |             Hashtable property = getContextProperty();
  |             InitialContext ic = new InitialContext(property);
  |             Object obj = ic.lookup(XYZServer); 
  |             pbo = (PBORequest) obj; // Throws ClassCastException
  |       }
  |       catch (NamingException ne)
  |       {
  |             ne.printStackTrace();
  |        }
  |        return pbo;
  | }
  | 

Now, while casting the obj in above code to PBORequest it gives a 
ClassCastException. Now, my question is :
a) Why is the code throwing the ClassCastException.

b) Since "PBORequestServer" contains InitialContext as an element which is not 
Serializable, so we cant extend Serializable to "PBORequest" class. Other wise 
the server gives the error while binding the PBORequestServer object to context 
that "InitialContext not serialized". So, how to proceed with "Referenceable" 
Interface. That is , how to bind/lookup for the object.

c) How NonSerializableFactory works? Can I use this, if my PBORequest doesn't 
extends Serializable/Referential? If yes, how?Is there any example given for 
bind/unbind/lookup/getObjectInstance for the remote object. 

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3885917#3885917

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3885917


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to