• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error looking up EJB LocalHome (in web.xml)

 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all-
I'm having a problem looking up a Local Home in my web app (using WSADIE 5.01).
1. I have a CMP entity bean generated by WSADIE. It works fine in the EJB test client which lets me navigate to it as:
[Local EJB beans] ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome

but I can't look it up in a JSP with:
String EJBHOME ="java:comp/env/ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome";
UserPoolEntityLocalHome home =
(UserPoolEntityLocalHome) ctxt.lookup(EJBHOME);
The error I get is:
[11/2/03 22:41:22:364 PST] 1e38aa74 SystemErr R com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. Root exception is javax.naming.NameNotFoundException: ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome

2. The CMP Bean's ejb-jar.xml:
<ejb-local-ref id="EJBLocalRef_1067839434401">
<description></description>
<ejb-ref-name>ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.b1.bll.userpool.ejb.UserPoolEntityLocalHome</local-home>
<local>com.b1.bll.userpool.ejb.UserPoolEntityLocal</local>
<ejb-link>UserPoolEntity</ejb-link>
</ejb-local-ref>
3. ibm-ejb-jar-bnd.xmi:
<ejbBindings xmi:id="EnterpriseBeanBinding_1067823339758" jndiName="ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome">
<enterpriseBean xmi:type="ejb:ContainerManagedEntity" href="META-INF/ejb-jar.xml#UserPoolEntity"/>
<ejbRefBindings xmi:id="EjbRefBinding_1067839434401" jndiName="ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome">
<bindingEjbRef xmi:type="common:EJBLocalRef" href="META-INF/ejb-jar.xml#EJBLocalRef_1067839434401"/></ejbRefBindings>
</ejbBindings>
4. web.xml:
<ejb-local-ref id="EJBLocalRef_1067827938211">
<ejb-ref-name>ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.b1.bll.userpool.ejb.UserPoolEntityLocalHome</local-home>
<local>com.b1.bll.userpool.ejb.UserPoolEntityLocal</local>
<ejb-link>UserPoolEJB.jar#UserPoolEntity</ejb-link>
</ejb-local-ref>
5. The webapp's ibm-web-bnd.xmi:
<ejbRefBindings xmi:id="EjbRefBinding_1067827938211" jndiName="ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome">
<bindingEjbRef xmi:type="common:EJBLocalRef" href="WEB-INF/web.xml#EJBLocalRef_1067827938211"/>
</ejbRefBindings>
I think that's it,
many thanks
Max Tomlinson
 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Darn...for some reason, my XML snippets did not display.
Let me try that again:
Descriptor
<ejb-local-ref id="EJBLocalRef_1067839434401">
<description></description>
<ejb-ref-name>ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.b1.bll.userpool.ejb.UserPoolEntityLocalHome</local-home>
<local>com.b1.bll.userpool.ejb.UserPoolEntityLocal</local>
<ejb-link>UserPoolEntity</ejb-link>
</ejb-local-ref>

EJB BND FILE:
<ejbBindings xmi:id="EnterpriseBeanBinding_1067823339758" jndiName="ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome">
<enterpriseBean xmi:type="ejb:ContainerManagedEntity" href="META-INF/ejb-jar.xml#UserPoolEntity"/>
<ejbRefBindings xmi:id="EjbRefBinding_1067839434401" jndiName="ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome">
<bindingEjbRef xmi:type="common:EJBLocalRef" href="META-INF/ejb-jar.xml#EJBLocalRef_1067839434401"/>
</ejbRefBindings>
</ejbBindings>

WEB.XML:
<ejb-local-ref id="EJBLocalRef_1067827938211">
<ejb-ref-name>ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.b1.bll.userpool.ejb.UserPoolEntityLocalHome</local-home>
<local>com.b1.bll.userpool.ejb.UserPoolEntityLocal</local>
<ejb-link>UserPoolEJB.jar#UserPoolEntity</ejb-link>
</ejb-local-ref>

IBM-WEB-BND:
<ejbRefBindings xmi:id="EjbRefBinding_1067827938211" jndiName="ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome">
<bindingEjbRef xmi:type="common:EJBLocalRef" href="WEB-INF/web.xml#EJBLocalRef_1067827938211"/>
</ejbRefBindings>
 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
crap, can't paste xml
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like your code is OK, so I'm wondering if the Entity bean is actually starting. Look through your standard out log carefully and make sure that the EJB container started with no errors. Also, can you use the UTC to get to that Entity bean?
Kyle
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
Error Message clearly indicating that problem is with EJB Reference from Web.xml. Can you just make sure when you did the Reference from web.xml to ejb, you did mention the JNDI Name in the JNDi name column in web.xml?
And before you do anything else, can you do this to make sure JSP is able to invoke EJB without using java:comp/env?
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mahesh Chalil:
Hello
Error Message clearly indicating that problem is with EJB Reference from Web.xml. Can you just make sure when you did the Reference from web.xml to ejb, you did mention the JNDI Name in the JNDi name column in web.xml?
And before you do anything else, can you do this to make sure JSP is able to invoke EJB without using java:comp/env?


Manesh, it's a local bean. There is no way to invoke it without using java:comp/env.
Also, there is no "JNDI Name" column in Web.xml. Read this article for an explanation of why.
Kyle
 
Mahesh Chalil
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kyle,
Are you sure about JNDI name for EJB in web Deployment descriptor screen in WSAD5? I have been doing it for sometime the same. Please open your web deployment descriptor and go to references and then select ejb tab. Look at there. Finally these entries go to the bind file. ibm-web-bnd.xmi.
Hope I didnt confuse you. I would like to paste the image out here but I dont know how.
 
Mahesh Chalil
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kyle
I am pasting the content from ibm-web.bnd.xmi and web.xml file here. I did this reference from the web deployment descriptor by opening web.xml. It was my fault I used to do it from web.xml but thats the way WSAD is now a days refer things not to confuse developers as everything originates from that file. You will see the jndi name down in the ejb-reference
1. from bind file
<?xml version="1.0" encoding="UTF-8"?>
<webappbnd:WebAppBinding xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:webappbnd="webappbnd.xmi" xmlns:webapplication="webapplication.xmi" xmlns:commonbnd="commonbnd.xmi" xmlns:common="common.xmi" xmi:id="WebAppBinding_1" virtualHostName="default_host">
<webapp href="WEB-INF/web.xml#WebApp"/>
<ejbRefBindings xmi:id="EjbRefBinding_1067970272572" jndiName="ejb/ApplicationsListingEJB">
<bindingEjbRef href="WEB-INF/web.xml#EjbRef_1067970272572"/>
</ejbRefBindings>
</webappbnd:WebAppBinding>
2. From web.xml file
<ejb-ref id="EjbRef_1067970272572">
<ejb-ref-name>ejb/ejbA</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.wellpoint.isg.ies.sessionbean.ApplicationsListingEJBHome</home>
<remote>com.wellpoint.isg.ies.sessionbean.ApplicationsListingEJB</remote>
<ejb-link>ejb_ApplicationsListingEJB</ejb-link>
</ejb-ref>
 
Mahesh Chalil
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Max,
Here is what you wrote:
1. I have a CMP entity bean generated by WSADIE. It works fine in the EJB test client which lets me navigate to it as:
[Local EJB beans] ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome
but I can't look it up in a JSP with:
String EJBHOME ="java:comp/env/ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome";
UserPoolEntityLocalHome home =
(UserPoolEntityLocalHome) ctxt.lookup(EJBHOME);
"
Please make sure that "ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome" is the name you gave while making the reference entry from the web.xml/web deployment descriptor page in your Web project. For example, in my case I have a Local Entity Bean referring from my Servlet, please look at the web.xml reference
<ejb-local-ref id="EJBLocalRef_1067971833446">
<ejb-ref-name>ejb/TestEntity</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.test.ejb.TestEntityLocalHome</local-home>
<local>com.test.ejb.TestEntityLocal</local>
<ejb-link>TestEJB.jar#TestEntity</ejb-link>
</ejb-local-ref>
Now look at the ibm-web-bnd.xmi reference with the real jndi name,
<ejbRefBindings xmi:id="EjbRefBinding_1067971833446" jndiName="ejb/com/test/ejb/TestEntityLocalHome">
<bindingEjbRef xmi:type="common:EJBLocalRef" href="WEB-INF/web.xml#EJBLocalRef_1067971833446"/>
</ejbRefBindings>
In your case why it is not working is bcos, you gave the name in the bind file along with java:comp/env and it should be the name in the <ejb-ref-name>
Please let me know if it didnt make sense to you or if it confused you.
 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of, thanks for all your replies. I really do appreaciate it.
This was caused, I believe, to a compiled JSP being cached in my WSAD environment. I shut down WSADIE 5 and when I restarted next day, it worked:
String EJBHOME ="java:comp/env/ejb/com/b1/bll/userpool/ejb/UserPoolEntityLocalHome";
UserPoolEntityLocalHome home =
(UserPoolEntityLocalHome) ctxt.lookup(EJBHOME);
thanks again
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic