tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr_di <>
Subject Re: TomEE and CDI
Date Fri, 09 May 2014 11:37:37 GMT

I think you misunderstand CDI. CDI runs in a container and this container
manages the Beans you want to inject and inject other beans in this. If you
use the "new" Keyword from Java, then you instantiate the Bean/Class by
yourself and the container won't see it.

If you don't want to inject "Exam" then you need to use the BeanManager from
the container and "ask" for the Bean you want to get. It's possible to
programmatically get Beans. But to be honest it wouldn't make any sense to
use it for your example. You need the programmatically way if you have to
build the object you want to manage with CDI by yourself and set some values
from outside. But that would be a complex example. Most of the time simple
injecting of a bean is better.

best regards

View this message in context:
Sent from the OpenEJB User mailing list archive at

View raw message