on 11-10-2005 5:01 PM
This code:
Object o = ctx.lookup("java:comp/env/ejb/AdderEJB");
AdderLocalHome home = (AdderLocalHome)o;
generates a ClassCastException. The object returned from the JNDI lookup is something like com.example.ejb.AdderLocalHomeImpl0@1374bef, and I'm trying to cast it to the interface com.example.ejb.AdderLocalHome.
The local reference to the EJB is as follows:
<server-component-ref>
<description>
</description>
<name>ejb/AdderEJB</name>
<type>interface</type>
<jndi-name>localejbs/example.com/test-ear/AdderBean</jndi-name>
</server-component-ref>
Why am I getting a casting exception? I believe I'm following the documented methods correctly, but I must be doing something wrong.
BTW, this EJB has also been exposed via a web service, and that functions correctly, so I know the EJB is correctly configured and deployed.
Ideas?
Hi Ken,
This is not the correct way to declare local EJB references. Please, try to follow this documentation:
<a href="http://help.sap.com/saphelp_nw04s/helpdata/en/38/3e5a4201301453e10000000a155106/frameset.htm">http://help.sap.com/saphelp_nw04s/helpdata/en/38/3e5a4201301453e10000000a155106/frameset.htm</a>
The server-component-ref element can be used to access functionality provided by a J2EE Engine service for example, but should not be used to access another EJB.
Best regards,
Viliana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ken,
From where are you calling EJB?
If you are calling this EJB from another EJB of the same project then it is fine. But, if you are calling from another application then try to use Remote interface of your EJB home instead of using local interface.
Regards,
Bhavik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.