could not dereference object when running the EJB
Hi,
I'm using jboss4.0.3. I want to reference my jsp page to EJB but get a "could not dereference object" upon running the jsp with this as it went into the catch exception instead of looking up to the EJB:
Part of my jsp codes in jspinit( ):
try {
objref = initial.lookup("java:comp/env/ejb/MyMusicCart");
System.out.println("lookup success for ejb/MyMusicCart");
// a reference to the home interface is shareable
cartHome = (MusicCartHome)PortableRemoteObject.narrow(objref, MusicCartHome.class);
System.out.println("created MusicCartHome object");
} catch (Exception ex) {
System.out.println("Unexpected Exception: " +ex.getMessage());
My web.xml
Code:
<ejb-ref>
<ejb-ref-name>ejb/MyMusicCart</ejb-ref-name>
<ejb-ref-type>Session
]]>asg.MusicCartEJB.MusicCartHome
]]>asg.MusicCartEJB.MusicCart </remote>
<ejb-link>ejb-jar-ic.jar#MusicCartBean</ejb-link>
</ejb-ref>
anyone encounter this problem before? Please help.. I have attach the jsp file, web.xml file and a bean xml *.jar for your perusal.
I can produce more of my files if you guys feel that is not enough
Attachment(s):
web.xml
musicCart.jsp
ejb-jar.xml
MusicCart.ear
请先登录再写评论。
Shirley,
The problem is the line <ejb-link>ejb-jar-ic.jar#MusicCartBean</ejb-link> which isn't understood by JBoss. Just change it to <ejb-link>MusicCartBean</ejb-link>.
- Martin
Hi Martin,
Thanks for your reply. However i have changed according to your solution. The result is still the same. The error "Could not dereference object".
Any other possible solutions?
Another error is in ejb-jar.xml of ejb-jar-iterator.jar where the line <ejb-link>MusicPageBean</ejb-link> is missing for the ejb-ref. After correcting you should be able to load the bean. (I then get another error because I don't have the correct database configured, but that's another story.)
If you need further assistance I would be glad to get a snapshot of the whole project. It's quite hard to find errors without any debug possibility... :)
Wow.. thanks .. Your solution have really help me.
Thanks for your help.
Regards ChongMing