It is my understanding that injection only works after the ctor has run.
Until the ctor finishes, there really isn't an Object on which to work.
If you need something to run before client code can use the object, you
might look at @PostConstruct.
-----
Jason Lee, SCJP
Programmer/Analyst
http://www.iec-okc.com
> -----Original Message-----
> From: Wouter van Reeven [mailto:wouter_at_van.reeven.nl]
> Sent: Monday, November 06, 2006 10:53 AM
> To: ejb_at_glassfish.dev.java.net
> Subject: EntityManager injection question
>
> Hi all,
>
>
> Can someone please enlighten me on this question: I have
> created a stateless session bean in which I inject an
> EntityManager instance:
>
> @PersistenceContext EntityManager em;
>
> When I try to access the EntityManager in the constructor of
> the bean, the em instance always is NULL. When I try to
> access the em instance after the constructor has completed,
> all goed well. Is this behaviour expected?
>
>
> Thanks in advance,
>
> Wouter van Reeven
>
> --
>
> People: "If she weighs the same as a Duck, she's made of wood!"
> Sir Bedevere: "And therefore...?"
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>
>