2 Replies Latest reply on Apr 13, 2003 7:24 PM by slaboure

    ClassCastException Error on HAPartition

    cecil

      Dear all,

      Forgive my stupid question. I am trying to use the example in JBoss Clustering Page 51.

      My code is as follows,

      private static javax.naming.Context getJBossInitialContext() throws NamingException {
      Properties p = new Properties();
      p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
      p.put(Context.PROVIDER_URL, "localhost:1100"); // HA-JNDI port.
      return new InitialContext(p);
      }

      context = getJBossInitialContext();
      Object ref = context.lookup("/HAPartition/DefaultPartition");
      HAPartition partition = (HAPartition) ref;

      I always get a ClassCastException when I try to cast ref into partition, but the context.lookup is successful because I can see the className of ref is "HAPartitionImpl".

      Can someone tell me what's wrong? Thanks.