Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000952 [Resin] minor always 02-20-06 08:51 03-27-06 14:53
Reporter anonymous View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version 3.0.16
Summary 0000952: @EJB injection and inheritance
Description The @EJB injection code is not handling annotations specified in a base class.

I have a little code I have been playing with where I have a series of servlets derived from a custom base class. The base class contains a reference to an EJB that all of my servlets need. I tried to configure this by adding an @EJB method in the base class but the injection never happens.

I found two workarounds for now:
- Do the injection from each derived class. Then things work correctly, but I end up with a lot of duplicate code.
- Manually do the lookup in init() of the base class.
Additional Information Example:

public class BaseServlet extends ...
{
   protected MyEJB ejb = null;

   ...

   @EJB
   public void setMyEJB(MyEJB ejb) ...
}


public class ConcreteServlet extends BaseServlet
{
   ...

   public void service(...)
   {
        this.ejb.method(); // NPE here - injection is not being done
   }
   ...
}


WORKAROUND: Do the injection from the concrete class rather than the base class

public class ConcreteServlet extends BaseServlet
{
   ...
   @EJB
   public void setMyEJB(MyEJB ejb) { ... }
   ...

   public void service(...)
   {
        this.ejb.method(); // Works fine now...
   }

}
Attached Files

- Relationships

- Notes
(0000952)
ferg
03-27-06 14:53

ejb/0f24
 

- Issue History
Date Modified Username Field Change
02-20-06 08:51 anonymous New Issue
03-27-06 14:53 ferg Note Added: 0000952
03-27-06 14:53 ferg Assigned To  => ferg
03-27-06 14:53 ferg Status new => closed
03-27-06 14:53 ferg Resolution open => fixed
03-27-06 14:53 ferg Fixed in Version  => 3.0.19


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
28 total queries executed.
25 unique queries executed.
Powered by Mantis Bugtracker