Classes initiaed with new MyClass() - can i use @EJB in MyClass
posted 1 year ago
Im working on a system that has no injections. All classes instantiated using new. We want to change dao layer from jdbc commit/rollback code and use JTA
So I want to inject MyDAOClass classes have
I can only inject MyDaoClass by looking up the context. I want to use @EJB for MyDaoClass injection. Parent class (business layer class) is instantiated with new. i dont want to rewrite everything and have every class injected.Can i use a annotation like @SessionScoped for business class to get JBOSS 6 to inject dao class?
Injection is supported only for "managed" instances. Using new() to instantiate doesn't allow injection to happen since the object is no longer managed by the container(s). So you will have to use the techniques specified by the Java EE spec to instantiate them (like using JNDI lookups or injection).