JNDI ENC lookup returning Remote interface instead of Local?
qwidjibo Jun 23, 2005 11:54 AMAnyone have any idea what is happening here??
I have some entity beans that have local and remote interfaces, they are referenced by a session bean and I have placed the local refs in the deployment desciptor like so;
<ejb-local-ref>
<ejb-ref-name>ejb/FacultyLocalEJB</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.uni.faculty.FacultyHomeLocal</local-home>
com.uni.faculty.FacultyLocal
<ejb-link>FacultyEJB</ejb-link>
</ejb-local-ref>
<ejb-local-ref>
<ejb-ref-name>ejb/StudentLocalEJB</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.uni.student.StudentHomeLocal</local-home>
com.uni.student.StudentLocal
<ejb-link>StudentEJB</ejb-link>
</ejb-local-ref>
<ejb-local-ref>
<ejb-ref-name>ejb/SchoolLocalEJB</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.uni.school.SchoolHomeLocal</local-home>
com.uni.school.SchoolLocal
<ejb-link>SchoolEJB</ejb-link>
</ejb-local-ref>
<ejb-local-ref>
<ejb-ref-name>ejb/AddressLocalEJB</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.uni.address.AddressHomeLocal</local-home>
com.uni.address.AddressLocal
<ejb-link>AddressEJB</ejb-link>
</ejb-local-ref>
But when I try to use them like;
InitialContext jndiContext = new InitialContext();
Object obj = jndiContext.lookup("java:comp/env/ejb/FacultyLocalEJB");
FacultyHomeLocal facultyHome = (FacultyHomeLocal)obj;
obj = jndiContext.lookup("java:comp/env/ejb/StudentLocalEJB");
StudentHomeLocal studentHome = (StudentHomeLocal)obj;
obj = jndiContext.lookup("java:comp/env/ejb/SchoolLocalEJB");
SchoolHomeLocal schoolHome = (SchoolHomeLocal)obj;
obj = jndiContext.lookup("java:comp/env/ejb/AddressLocalEJB");
AddressHomeLocal addressHome = (AddressHomeLocal)obj;
I recieve the following exception;
java.lang.ClassCastException: $Proxy364
at com.uni.dataFiller.DataFillerBean.initialize(DataFillerBean.java:36)
This is because remote interfaces are being returned when Local one should be instead. To make things more irritating I only get the exception with some of the beans that have remote and Local interfaces and not with others and all works fine if I remove the remote interfaces to my entity beans.
Cheers in advance