Why do I get a ClassCastException when I use narrow() in
didoux May 10, 2004 6:24 PMThis 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) { } } } }