You'll need to create a producer (@Produces) for the entity in question as directly injecting an entity which the BeanManager instantiates is not a good idea.
Injections happen with @Inject.
thanks for the answer.
I´m already working with a producer. But this only works as long as I have my ActionBean marked as @SessionScoped.
As soon as I change it to somewhat like @RequestScoped I always receive an error, when I enter the page.
SessionScope is actually not what I want, as the user should not be put into the session, but always stay within the scope of the form and has to disappear as soon as the form has been submitted successfully. Or how would I clear the session variable?
How would I proceed this way?
What error occures?
Currently I would receive a LazyInitializationException on my entity-collections during page-load.
What's the producer for the EntityManager scoped?
Well if you inject a dao class to load the entity you will have to load the entity collections on your own. I think the entity is not attached to the entitymanager any more which produces the LazyInitializationException. If you load the entity from the entitymanager in the same bean they will fetch during the process.
All depends if the instance of the EntityManager from which the entity was originally retrieved is still around (attached entity). You could debug and see if it's the same EM.