For those looking at the log: the error messages start at around line 214.

On 10/28/2013 05:06 PM, Kay Wrobel wrote:
Interesting that this topic has come up. I just tried to roll out a change to my project where I have following situation: Currently, I have an AbstractController and then a Controller for each entity class. On the EJB side of things, I have an AbstractFacade and an entity Facade for each entity, each annotated with @Stateless. Right now, I am injecting an EntityFacade object into an EntityController and then hand off the actual object to a variable that sits inside the AbstractController. I wanted to change that behavior and perform the injection right inside the abstract controller class. To give you a more concrete example, this is how it looks like now:

AbstractController.java:
public abstract class AbstractController<T> {

    private AbstractFacade<T> ejbFacade;

    public AbstractController() {
    }

    protected AbstractFacade<T> getFacade() {
        return ejbFacade;
    }

    protected void setFacade(AbstractFacade<T> ejbFacade) {
        this.ejbFacade = ejbFacade;
    }
}

CustomerController.java:
@Named(value = "discountCodeController")
@ViewAccessScoped
public class DiscountCodeController extends AbstractController<DiscountCode> implements Serializable {

*    @Inject**
**    private DiscountCodeFacade ejbFacade;**
*
    @PostConstruct
    public void init() {
        super.setFacade(ejbFacade);
    }

}
Now for the change that I had already tested out with Glassfish 3.1.2:

AbstractController.java:
public abstract class AbstractController<T> {

*    @Inject**
**    private AbstractFacade<T> ejbFacade;**
*
    public AbstractController() {
    }

    public AbstractController(Class<T> itemClass) {
        this.itemClass = itemClass;
    }
}
DiscountController.java:
@Named(value = "discountCodeController")
@ViewAccessScoped
public class DiscountCodeController extends AbstractController<DiscountCode> implements Serializable {

    public DiscountCodeController() {
        super(DiscountCode.class);
    }

}
Notice how I am injecting an AbstractFacade<T> inside AbstractController<T>. This works in Glassfish but fails in Tomee/OpenEJB.

Attached is the the deployment log of TomEE: http://pastebin.com/iZHZqy5d

Any input from you guys?


On 10/28/2013 04:29 PM, Romain Manni-Bucau wrote:
I needed it for other reasons. Globally while not using producers it should
work.
Le 28 oct. 2013 22:21, "Chris Owens" <[email protected]> a
écrit :

Thank you, that code is very helpful.  I was hoping to be able to do it
without the use of an additional qualifier.



--
View this message in context:
http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665766.html
Sent from the OpenEJB User mailing list archive at Nabble.com.




Reply via email to