JBoss Community

Re: JBoss : persistence and EntityManager injection

created by zecas zecas in Beginner's Corner - View the full discussion


Wolf-Dieter Fink wrote:

 

For me it is unclear how you call the method something.

Injection is nothing magic, the container must have a chance to do it.

 

First of all, Thanks for the help.

 

I'm invoking the method in a servlet context listener defined in "web.xml".

 

During the listener execution, I do something like:

 

SimpleMessage sm = new SimpleMessage!
 ();
sm.something();

 

 

If I inject the EntityManagerFactory in the listener class, it is successfully instantiated and available (not NULL), but inside that class, I'm not getting it with a value other than NULL.

 

Since I'm invoking the class from within a listener, which is inside the container, I was hoping (and testing) to get it to work ... to avoid having to pass it to the underlying class I'm invoking, and that will do the work.

 

(Understanding this behaviour will help to clarify some doubts I'm having for some time.)

 

 

Thanks.

Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community