This content has been marked as final.
Show 3 replies
-
1. Re: ClassCastException when looking up HAPartition via JNDI
starksm64 Jul 11, 2004 10:44 AM (in response to aggiaggi)This code cannot work outside of the jboss server. The HAPartition implementation is no serializable and able to function outside of the vm in which the partition service was configured. You would have to write your own rpc proxy using the detached invoker framework or interact with the service mbean via a jmx connector.
-
2. Re: ClassCastException when looking up HAPartition via JNDI
aggiaggi Jul 11, 2004 2:16 PM (in response to aggiaggi)Thx for the quick answer.
Best regards
Gerd -
3. Re: ClassCastException when looking up HAPartition via JNDI
spambob Aug 19, 2005 7:14 PM (in response to aggiaggi)I'm seeing the same problem, when upgrading from 3.2.5 to 4.0.2.
My code is:Properties env = new Properties(); env.setProperty(NamingContext.JNP_PARTITION_NAME, "DefaultPartition"); env.setProperty(NamingContext.JNP_DISCOVERY_PORT, "1102"); env.setProperty(NamingContext.JNP_DISCOVERY_GROUP, "230.0.0.4"); env.setProperty(NamingContext.JNP_DISCOVERY_TIMEOUT, "5000"); env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); InitialContext ctx = new InitialContext(env); String partitionName = env.getProperty(NamingContext.JNP_PARTITION_NAME); String partitionJndiName = "/HAPartition/" + partitionName; Object lookup = ctx.lookup(partitionJndiName);
In jboss 4.0.2, this code gives a ClassCastException:HAPartition partition = (HAPartition) ctx.lookup(partitionJndiName);
But this code works:Method method1 = lookup.getClass().getMethod("getCurrentView",null); Vector view = (Vector) method1.invoke(lookup,null); Method method2 = lookup.getClass().getMethod("getNodeName",null); String myNodeName = (String) method2.invoke(lookup,null);
In jboss 3.2.5, the cast would work and then I could just invoke partition.getCurrentView() and partition.getNodeName()