dev@glassfish.java.net

Re: injection-target?

From: Hong Zhang <Hong.Zhang_at_Sun.COM>
Date: Fri, 21 Sep 2007 16:47:23 -0400

Hi, Peter

> Is the <injection-target> element supposed to be a valid element in a
> user's JavaEE5 standard descriptor file?
>
Yes.

> The spec is somewhat vague, but near as I can tell this should be
> legal and in fact is the correct way for the deployer role to override
> an annotated injection dependency without recompiling.
>
> The javaee5_xsd includes a definition of this type but the various
> type definitions for the reference types for which this ought to be
> valid do not include it as a child.

Take a look at this one (it's one of the ejb unit tests), it has an
ejb-ref which uses injection-target element.
http://fisheye5.cenqua.com/browse/~raw,r=1.4/glassfish/appserv-tests/devtests/ejb/ejb30/hello/session2full/descriptor/application-client.xml

> The end result is that if you use this in a project (say inside
> NetBeans), the XML parser will declare your descriptor file as invalid
> with an error. For example, a service-ref with an injection-target
> node, the error is "cvs-complex-type.2.4.a: Invalid context was found
> starting with element 'injection-target'. One of
> '{"http://java.sun.com/xml/ns/javaee":port-component-ref,
> "http://java.sun.com/xml/ns/javaee":handler,
> "http://java.sun.com/xml/ns/javaee":handler-chains}' is expected."
>
> An application using this will pass the verifier though.
>
> So, are the descriptor schemas for JavaEE5 broken? Is the JDK's XML
> schema based validating parser broken? Or is there some other spec
> weirdness going on here (such as this entry is only for use by the
> server)?

Maybe you can send me your application so I can try it from my side to
see what happens? Can you try with ejb-ref or other reference type to
see if that works for you?

Thanks,

- Hong