3 Replies Latest reply on May 18, 2004 10:44 AM by Dan Idoux

    Why do I get a ClassCastException when I use narrow() in

    Dan Idoux Newbie

      This code works in a non-cluster environment, but when I switch to HA-JNDI. I am getting a ClassCastException error on the server. I am using the "all" configuration. Is there something else that I have to do? I am getting this with our Servlets, from our swing Console application the clustering is working fine. Does the servlets need the jboss-all.jar? Thanks in advance.

      Error on server:

      Caused by: java.lang.ClassCastException
      at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
      at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
      at com.metamatrix.common.comm.platform.rmi.apiimpl.PlatformServerConnectionFactory.connectToLogonAPI(PlatformServerConnectionFactory.java:106)
      at com.metamatrix.common.comm.platform.rmi.apiimpl.PlatformServerConnectionFactory.establishConnection(PlatformServerConnectionFactory.java:52)

      Error on the Client:

      Client library may not match server vendor or version for server mm://:. Client code loaded from plugin: null, initial context factory: org.jnp.interfaces.NamingContextFactory.null


      private LogonAPI connectToLogonAPI(Properties props) throws CommunicationException {
       Context ctx = null;
       Hashtable h = new Hashtable();
      
       if ( CommPlatformPlugin.DEBUG ) {
       Object[] params = new Object[]{props};
       CommPlatformPlugin.Util.log(IStatus.INFO,
       MessageFormat.format(
       "PlatformServerConnectionFactory.connectToLogonAPI - connection properties: {0}", //$NON-NLS-1$
       params));
       }
      
       String PROVIDER_URL = props.getProperty(SERVER_URL_PROP);
       if ( PROVIDER_URL == null || PROVIDER_URL.trim().length() == 0 ) {
       throw new CommunicationException(
       CommPlatformPlugin.Util.getString(
       "PlatformServerConnectionFactory.Missing_required_property") + SERVER_URL_PROP); //$NON-NLS-1$
       }
      
       String INITIAL_CTX_FACT = props.getProperty(INIT_CTX_FACT_PROP);
       if ( INITIAL_CTX_FACT == null || INITIAL_CTX_FACT.trim().length() == 0 ) {
       INITIAL_CTX_FACT = NetUtils.getAppserverInitialContextFactoryName();
       props.setProperty(INIT_CTX_FACT_PROP, INITIAL_CTX_FACT);
       }
      
       h.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CTX_FACT);
       h.put(Context.PROVIDER_URL, NetUtils.convertURLByInitailContext(INITIAL_CTX_FACT, PROVIDER_URL));
       try {
       ctx = new InitialContext(h);
       LogonAPIHome home;
       try {
       home = (LogonAPIHome) PortableRemoteObject.narrow(ctx.lookup(LOGON_API_HOME), LogonAPIHome.class);
       } catch (ClassCastException e) {
       throw handleClassCastExceptionFromJndiLookup(PROVIDER_URL, INITIAL_CTX_FACT, e);
       }
       return home.create();
       } catch (java.rmi.RemoteException re) {
       throw new CommunicationException(re,
       CommPlatformPlugin.Util.getString(
       "PlatformServerConnectionFactory.Error_comunicating_with_LogonAPI")); //$NON-NLS-1$
       } catch (javax.naming.NamingException ne) {
       throw new CommunicationException(ne,
       CommPlatformPlugin.Util.getString(
       "PlatformServerConnectionFactory.Error_comunicating_with_LogonAPI")); //$NON-NLS-1$
       } catch (javax.ejb.CreateException ce) {
       throw new CommunicationException(ce,
       CommPlatformPlugin.Util.getString(
       "PlatformServerConnectionFactory.Error_comunicating_with_LogonAPI")); //$NON-NLS-1$
       } finally {
       if ( ctx != null ) {
       try {
       ctx.close();
       } catch (Exception e) {
       }
       }
       }
       }
      


        • 1. Re: Why do I get a ClassCastException when I use narrow() in
          Dan Idoux Newbie

          Getting a ClassCastException trying to access our Stateless Session Beans from within Servlet

          We changed the ports for HA JNDI to the desired port deploy/cluster-service.xml and the JNDI to 1100 jboss-service.xml


          <!-- The listening port for the bootstrap JNP service. Set this to -1
          to run the NamingService without the JNP invoker listening port.
          -->
          1100

          deploy/cluster-service.xml


          jboss:service=DefaultPartition
          <!-- Name of the partition to which the service is linked -->
          MetamatrixPartition
          <!-- bind address of HA JNDI RMI endpoint -->
          ${jboss.bind.address}
          <!-- RmiPort to be used by the HA-JNDI service
          once bound. 0 => auto. -->
          0
          <!-- Port on which the HA-JNDI stub is made available -->
          41484

          Is this the correct configuration for HA JNDI?

          • 2. Re: Why do I get a ClassCastException when I use narrow() in
            Dan Idoux Newbie

            Getting a ClassCastException trying to access our Stateless Session Beans from within Servlet

            We changed the ports for HA JNDI to the desired port deploy/cluster-service.xml and the JNDI to 1100 jboss-service.xml

            <mbean code="org.jboss.naming.NamingService"
             name="jboss:service=Naming">
             <!-- The listening port for the bootstrap JNP service. Set this to -1
             to run the NamingService without the JNP invoker listening port.
             -->
             <attribute name="Port">1100</attribute>


            deploy/cluster-service.xml

            <mbean code="org.jboss.ha.jndi.HANamingService"
             name="jboss:service=HAJNDI">
             <depends>jboss:service=DefaultPartition</depends>
             <!-- Name of the partition to which the service is linked -->
             <attribute name="PartitionName">MetamatrixPartition</attribute>
             <!-- bind address of HA JNDI RMI endpoint -->
             <attribute name="BindAddress">${jboss.bind.address}</attribute>
             <!-- RmiPort to be used by the HA-JNDI service
             once bound. 0 => auto. -->
             <attribute name="RmiPort">0</attribute>
             <!-- Port on which the HA-JNDI stub is made available -->
             <attribute name="Port"> 41484 </attribute>


            Is this the correct configuration for HA JNDI?

            • 3. Re: Why do I get a ClassCastException when I use narrow() in
              Dan Idoux Newbie

              Just noticed that cluster-service.xml has a variable. Should I have 0.0.0.0 or the IP of my machine?


              <attribute name="BindAddress">${jboss.bind.address}</attribute>



              -------------------------------------------------------
              GMS: address is SLWXP120:2343 (additional data: 19 bytes)
              -------------------------------------------------------
              10:22:41,330 INFO [ClusterPartition] Starting channel
              10:22:41,330 INFO [MetamatrixPartition] Number of cluster members: 1
              10:22:41,330 INFO [MetamatrixPartition] Other members: 0
              10:22:41,330 INFO [ClusterPartition] Started ClusterPartition: MetamatrixPartition
              10:22:41,330 INFO [ClusterPartition] Started jboss:service=MetamatrixPartition
              10:22:41,330 INFO [HASessionStateService] Started jboss:service=HASessionState
              10:22:41,330 INFO [HANamingService] Listening on /0.0.0.0:41484
              10:22:41,330 INFO [HANamingService$AutomaticDiscovery] Listening on /0.0.0.0:1102, group=230.0.0.4
              10:22:41,330 INFO [HANamingService] Started jboss:service=HAJNDI
              10:22:41,330 INFO [InvalidationManager] Subscribing a new cache-invalidation bridge
              10:22:41,330 INFO [JGCacheInvalidationBridge] Started jboss.cache:service=InvalidationBridge,type=JavaGroups
              10:22:41,330 INFO [JRMPInvokerHA] Started jboss:service=invoker,type=jrmpha
              10:22:41,345 INFO [MainDeployer] Deployed package: file:/D:/MetaMatrix/s41484/jboss/server/hametamatrix/deploy/cluster-service.xml