Alright, so I figured out how to fix the naming code so that it will work for business interfaces as well as references from servlets to ejb for business interfaces. Dain is hacking it in now.

On Jan 23, 2007, at 11:49 AM, Prasad Kashyap wrote:

The easiest way to reference a 3.0 EJB is by dependency injection
(@EJB). But we don't have annotations working in servlets yet. So if
we go back to doing the traditional way of a lookup, we would have to
declare a <ejb-ref> in the web.xml

Even if the annotations are processed, they write an <ejb-ref> element
in the web.xml.

However for a 3.0 EJB, the interface elements like <home>, <local> etc
are not applicable inside a <ejb-ref>. So they are (should be)
omitted. Here is the schema:
http://java.sun.com/xml/ns/javaee/javaee_5.xsd

This isn't exactly right. Those elements are still very applicable. For a proper ejb-ref to an EJB 3.0 bean (i.e. a business interface) it *must* have the <remote> or <local> and must *not* have the <home> or <local-home>.

These can only be omitted in the case of dependency injection where the code using the @EJB to generate a metadata-complete ejb-ref should *always* fill in the <remote> element of the <ejb-ref> element. If the user does not specify the 'beanInterface' attribute of the @EJB annotation, then the code building the reference must use the class type of the field or method as the value of '<remote>'.

There is an edge case where you truly do not know if the @EJB is pointing to a local object or a remote object and therefore don't know whether to build a ejb-ref or an ejb-local-ref. For OpenEJB we build an ejb-ref and flag it as being "ambiguous", then in the jndi building code we try to resolve it against the full list of available ejbs. We'll have to figure out some way to communicate this edge case to the ejb naming builder so we can deal with it.

But our deployer has a hard requirement on those interfaces. It fails
to deploy the module.
Here is the stack trace excerpt: http://rifers.org/paste/show/3344

Dain should have this code fixed up soon. It'll work as long as the code building the ejb-ref for the servlet follows the rules I state above.

Here is the jira for this problem:
http://issues.apache.org/jira/browse/GERONIMO-2778

Thanks. I'm going to change the description of that jira issue to reflect that <local> or <remote> *should* be filled in before the ejb naming builder is invoked. I don't know where that code is, perhaps Tim knows.

-David

Reply via email to