Can anyone help with the following - thanks.
I'm trying to share an object between a custom JBoss MBean and an Axis service running in the same JBOSS JVM.
When I look up the object ( JNDI) in the axis service, and call object.getClass(). I get the same name as the class that I am trying to cast to. If I look at both classes in a debugger, they look identical.
BUT, when I cast the object, I get a class cast exception. Any ideas - I am completely stumped!
e.g.
// **** JNDI binding ****
// Some class that does not implement Serializable
Object nonserializable = new com.NonSerializable("Test class");
// An arbitrary key to use in the StringRefAddr. The best key is the jndi
// name that the object will be bound under.
String key = "abc";
// This places nonserializable into the NonSerializableFactory hashmap under key
NonSerializableFactory.rebind(key, nonserializable);
Context ctx = new InitialContext();
// Bind a reference to nonserializable using NonSerializableFactory as the ObjectFactory
String className = nonserializable.getClass().getName();
String factory = NonSerializableFactory.class.getName();
StringRefAddr addr = new StringRefAddr("nns", key);
Reference memoryRef = new Reference(className, addr, factory, null);
ctx.rebind(key, memoryRef);
// **** Axis Service lookup ****
Object obj = _context.lookup("abc");
System.out.println(obj.getClass().getName());
// Outputs "com.NonSerializable"
System.out.println("Casting " + (com.NonSerializable) obj);
// throws ClassCastException