Hello, I am using EJB with WSAD 5.0, and get problems while looking up local Beans in the JNDI tree (no problems for access for remote Beans). The Bean appears in the UTC (Universal Test Client) under [EJB Beans in local]/ejb/myPackage/myBean, and is testable in the Bean page of the UTC. But I cannot access it through JNDI lookup (using java:comp/env prefix or not), neither with the search engine of the UTC. Does somebody have an idee about how to let it work ? Would be great, I'm getting of my nerves trying to solve this...
I'm confused. You say you can look it up with the UTC, but you can't look it up in code? Am I understanding you correctly? If that's true, that's probably because your client component where your lookup code runs (either a Session EJB or a Servlet) does not implement a local EJB reference to the EJB. However, you also say you can't look it up in the UTC, which is what is confusing me... Can you try to explain a bit more clearly what is happening? I'm not exactly sure from your original post. Kyle
Hi, some explanations about my trouble : actually there are two ways of accessing the Beans in the UTC : - through the JNDI tree, which works correctly - through a search function, which is the one that doesn't work I must own up that I am also a bit confused by this error, and hope this helps you, Theo
Got it. Sorry for the confusion there. Local bean homes cannot be looked up through the search function because they don't have "Real" JNDI names, just local reference id's that are specific to the client that uses them. AFAIK the search function only searches the actual JNDI naming tree. Kyle
In your client component deployment descriptor (either the EJB-JAR.xml file if your client is an EJB, the web.xml if your client is a Servlet or JSP) you must declare a local reference to the EJB (for instance, named something like ejb/YourLocalHomeReference" and then look it up with "java:comp/env/ejb/YourLocalHomeReference". Kyle
Hello, There seem to be a problem in the initialization of the local context : doing so I get an Exception : 'javax.naming.NameNotFoundException: Name comp/env/ejb not found in context "java:"' actually the problem seems to be that the server doesn't know of the 'ejb' local context. the possibility I see is the lack of the JNDI name of CMP container Factory, but it is not needed to access the remote Beans, so why by the local ? thanks for your help, Theo ++++++++++++++++ here is the code of the reference (from ibm-ejb-jar-bnd): <ejbBindings xmi:id="EnterpriseBeanBinding_1070271895609" jndiName="ejb/mich/cmp/FormulaireLocalHome"> <enterpriseBean xmi:type="ejb:ContainerManagedEntity" href="META-INF/ejb-jar.xml#Formulaire"/> <resRefBindings xmi:id="ResourceRefBinding_1070362283266" jndiName="eis/jdbc/ds1_CMP"> <bindingResourceRef href="META-INF/ejb-jar.xml#ResourceRef_1070362283266"/> </resRefBindings> <ejbRefBindings xmi:id="EjbRefBinding_1070273701234" jndiName="ejb/mich/cmp/FormulaireLocalHome"> <bindingEjbRef xmi:type="common:EJBLocalRef" href="META-INF/ejb-jar.xml#EJBLocalRef_1070273701234"/> </ejbRefBindings> </ejbBindings> ++++++++++++++++
Originally posted by theo cocolucci: Hello, I've found out that there is another, less known possibility : the use of 'local:/ejb/ejb/myBean' context. And it works ! thanks for your help, best regards, Theo
I really don't like using the local: prefix because it's outside the J2EE specification. The accepted way to do this is with java:comp/env. Kyle
Theo, I have to go back to the second response I made. What kind of client program are you building? Is your "client" another EJB, a Java application, or a Servlet or JSP? That determines where you put the local EJB reference... Kyle
OK, then the actual "client component" is the Struts Servlet, since that is what kicks things off. So, in the web.xml of your web application you have to add the ejb-local-ref declaration to your EJB. So, for instance, you'd add this to your web.xml: < ejb-local-ref> < ejb-ref-name>ejb/myPackage/myBean</ejb-ref-name> < ejb-ref-type>Session</ejb-ref-type> < local-home>MyBeanHome</local-home> < local>MyBean</local> < ejb-link>MyBean</ejb-link> < /ejb-local-ref> There's a good, complete example of a web.xml with ejb-local-ref entries added at the jonas docs page here: http://jonas.objectweb.org/current/doc/PG_WarDeployment.html#Exampl1 Kyle
Kyle, using the ejb-local-ref assumes that the servlet and ejb containers are running on the same VM. Would your solution still work using the <ejb-ref> tag if they were running on separate VM's? Also, using the <ejb-ref> or <ejb-local-ref> element eliminates namespace collisions. How would this be solved if the client was not a struts action handler, but instead a standalone java application?
Yes, if the EJB is not in the same JVM, you use an ejb-ref, and the EJB you are using must declare a Remote interface. And yes, the same trick works in application clients. You just add the ejb-ref to the applicationclient.xml file instead of the web.xml file. Kyle [ December 06, 2003: Message edited by: Kyle Brown ]
in the web.xml <ejb-local-ref> <ejb-ref-name>ejb/SessionEJB</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>ejb.SessionEJBLocalHome</local-home> <local>ejb.SessionEJBLocal</local> <ejb-link>SessionEJB</ejb-link> </ejb-local-ref>
the web app and ejb are in separate jaf files (war and jar, not packaged up in ear)....
When I deploy the Web App, it keeps complaining:
weblogic.deployment.EnvironmentException: [J2EE:160101]Error: The ejb-link 'SessionEJB' declared in the ejb-ref or ejb-local-ref 'ejb/SessionEJB' in the application module 'sessio Test.war' could not be resolved. The target EJB for the ejb-ref could not be found. Please ensure the link is correct.]
We're all out of roofs. But we still have tiny ads:
SKIP - a book about connecting industrious people with elderly land owners