I am having issues with the retrieval of beans using JNDI. I have a bean which implements a remote interface
public class MyBean implements MyInterface
Its JNDI binding is
java:global/jndinaming/MyBean!learning.jndinaming.MyInterface
That is OK.
Now I want it to extend an Abstract class:
public abstract class MyAbstractClass implements MyInterface
public class MyBean extends MyAbstractClass
So the JNDI binding becomes
java:global/jndinaming/MyBean!learning.jndinaming.MyBean
That is ok, I adjusted the string and my code which was this:
(MyInterface) ctx.lookup("java:global/jndinaming/MyBean!learning.jndinaming.MyInterface");
Becomes this:
(MyInterface) ctx.lookup("java:global/jndinaming/MyBean!learning.jndinaming.MyBean");
And I get a Class Cast exception:
ClassCastException: Cannot cast MyBean$$$view68 (id=938) to MyInterface
The interface file is in a project which is accessible by both the client and wirker project.
The client project contains the code that calls the lookup method.
The worker project has the bean implementation and abstract class.
The projects are in separate ear files but in the same wildfly container.
Why does adding the new "layer" with the abstract class causes this class cast exception? What can I do to solve it?
Aucun commentaire:
Enregistrer un commentaire