dev@glassfish.java.net

Re: injection-target?

From: Bill Shannon <bill.shannon_at_sun.com>
Date: Fri, 21 Sep 2007 13:37:57 -0700

Peter Williams wrote:
> Is the <injection-target> element supposed to be a valid element in a
> user's JavaEE5 standard descriptor file?
>
> 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. 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)?

It should work. I just tried a simple example and it worked
for me (which is to say that the XML parser and schema verifier
said it was ok.)

Here's the example I tried:

   <service-ref>
     <description>google service ref</description>
     <service-ref-name>service/GoogleSearch</service-ref-name>
     <service-interface>googleclient.GoogleSearchService</service-interface>
     <wsdl-file>GoogleSearch.wsdl</wsdl-file>
     <jaxrpc-mapping-file>googleclient.model</jaxrpc-mapping-file>
     <injection-target>
       <injection-target-class>com.example.MyApp</injection-target-class>
       <injection-target-name>id9</injection-target-name>
     </injection-target>
   </service-ref>

Is there a problem with the JDK version or parser version you're using?