0 Replies Latest reply on Jul 23, 2006 12:43 PM by Kevin J Citron

    Getting a javax.naming.Reference instance instead of actual

    Kevin J Citron Newbie

      JBoss Version: 4-0.3SP1
      OS: Mandrake Linux 2006
      JDK: 1.5

      On the server I have deployed an MBean which binds an object into the JNDI name space
      as follows:

       StdSchedulerFactory schedulerFactory = new StdSchedulerFactory();
       Scheduler scheduler = schedulerFactory.getScheduler();
       InitialContext ctx = new InitialContext();

      On the client side. I attempt to retreive the object from JNDI name space with the
      the following code:
       Properties properties = new Properties();
       properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
       properties.put(Context.PROVIDER_URL, "localhost:1099");
       InitialContext iniCtx = new InitialContext(properties);
       Scheduler schedObj =
       (Scheduler) iniCtx.lookup(SchedulerConstants.DEFAULT_SCHEDULER_NAME);

      This gives me ClassCastException: javax.naming.Reference.

      I have implemented the javax.naming. Referenceable interface.
      With getReference() returning a reference that has been instantiated
      with the name of the class, as well as the factory which creates the class.

       public Reference getReference(){
       Reference retVal = new Reference(
       log.info("Returning reference");
       return retVal;

      The Jar file containing the classes StdScheduler and StdScheduler factory are in the ClassPath for both JBoss (in server/all/lib). And the client.

      What am I doing wrong.