Mantis - Resin
|
|||||
Viewing Issue Advanced Details | |||||
|
|||||
ID: | Category: | Severity: | Reproducibility: | Date Submitted: | Last Update: |
952 | minor | always | 02-20-06 08:51 | 03-27-06 14:53 | |
|
|||||
Reporter: | anonymous | Platform: | |||
Assigned To: | ferg | OS: | |||
Priority: | normal | OS Version: | |||
Status: | closed | Product Version: | 3.0.16 | ||
Product Build: | Resolution: | fixed | |||
Projection: | none | ||||
ETA: | none | Fixed in Version: | 3.0.19 | ||
|
|||||
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. |
||||
Steps To Reproduce: | |||||
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... } } |
||||
Relationships | |||||
Attached Files: |
Notes | |||||
|
|||||
|
|