tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Russo <jru...@genscape.com>
Subject Re: injection bug
Date Tue, 02 Feb 2010 14:45:45 GMT
Pardon me for chiming in, but I would think that java rules ought to
prohibit you from declaring variable em in class B, since it is declared
private in class A.  Shouldn't you declare em as protected in class A
instead?



Jason Russo

Application Developer

Genscape– See the Energy

445 E. Market St, Suite 200

Louisville, KY 40202

Tel: 502-583-2091

www.genscape.com



On Mon, 2010-02-01 at 17:23 -0500, Christian Bourque wrote:

> Hi,
> 
> I have a weird problem with injection and I would like to confirm
> whether or not it is a bug:
> 
> -----------------------------------------------------------------------------------------------------------------------------------
> public abstract class A
> {
>   private EntityManager em;
> 
>   public EntityManager getEntityManager() { return em; }
>   public void setEntityManager(EntityManager em) { this.em = em; }
> }
> 
> @Stateless
> public class B extends A implements IB
> {
>   @PersistenceContext
>   private EntityManager em;
> 
>   @PostConstruct
>   public void init()
>   {
>     System.out.println("*** Entity Manager: " + em);
> 
>     setEntityManager(em);
>   }
> }
> -----------------------------------------------------------------------------------------------------------------------------------
> 
> In B the injected entity manager is always null! And If I simply
> change the variable name to say "em2" then it works!
> 
> Tested on OpenEJB 3.1.2...
> 
> Thanks
> 
> Christian

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message