dependency injection - @Inject in a Java EE application client does not work? -


problem

injecting enterprise java bean @ejb in application client, launched java web start , glassfish 3.1.2.2 (build 5) server.. works long requirements fulfilled [see note @ bottom]. fails if inject using @inject, despite whatever resource type we're trying inject. , know failed because shall nullpointerexception if try use injected resource. tells me annotation processor has forgot @inject.

not intrigued @ejb work flawlessly @ same time @inject not work @ all, reason "silent failure" of injection must violation of java ee 6 specification. specification says on page 69:

if container fails find resource needed injection, initialization of class must fail, , class must not put service.

this issue could related to, or expression of, bugg in glassfish.

my end goal..

.. separate api implementation easier job trying out different implementations when it's time performance testing , profiling application. take design pattern pretty impossible recreate in application client then? immediate approach create new instances of implementations in main class or use factories. of course best solution of use qualifiers!

note: requirements injection in application clients cdi must enabled component (package must contain file beans.xml, empty if you're used annotations!) , support of cdi in application clients optional, implementation specific. moreover, if cdi enabled , supported, should know application client container can active during boot of client , requires resources injected main class , fields static.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -