users@glassfish.java.net

Re: EntityManager in EJB not injected in overloaded method

From: <forums_at_java.net>
Date: Thu, 15 Dec 2011 03:23:29 -0600 (CST)

  I've been having problems with this issue for the last few days with
glassfish 3.1.1. I have an abstract base class extended by my stateless ejbs.
In the base class I have an overloaded merge method:   public abstract class
EjbBackingBean {    @PersistenceContext(unitName = "TestPU")    protected
EntityManager em;      public <T extends AbstractEntity> T merge(T ae) {
... }    public <T> T merge(T t) { ... } }   I @Inject my concrete
@Stateless ejbs into JSF backing beans. I /seem /to be able to get a build
which always works (the entity manager is not null), or a build which never
does. This problem started when I changed the signature of <T extends
AbstractEntity> T merge(T ae) from <T extends AbstractEntity> T merge(T ae,
UserCredentials details). Prior to using CDI I was using JSF managed beans
and EJBs, and needed a way to pass details of the current user into the ejb
merge() method. With CDI I simply @Inject a session scoped bean into the
ejb backing bean, meaning that the UserCredentials parameter is no longer
required.   So presumably this is a type erasure related issue, weld
related? This has been horrible to debug because I've been using
@PersistenceContext in the same code for 2 years to successfully inject a
container managed transaction scoped entity manager, and it took me quite a
while to realise that it had suddenly stopped working - I was looking at
everything else but this.   If anyone can suggest a workaround I'd very much
appreciate it.   PedroKowalski: what did you end up doing about this, did
you log a JIRA?

--
[Message sent by forum member 'oversteer']
View Post: http://forums.java.net/node/836240