I use the @Resource annotation in the class created in the ServletContextListener method contextInitialized(...), but the member is always zero. Here is my sample code.
LISTENER:
public void contextInitialized(ServletContextEvent sce) {
System.err.println("In contextInitialised");
new ResourceListenerTargetTest().executeMe();
}
ResourceListenerTargetTest:
@Resource(name="MyJDBCResource")
private DataSource source;
public void executeMe() {
System.err.println("source is " + source);
}
If I switch comments and run a manual resource search, it works fine.
If the @Resource annotation works like this when used in the context of the initialized method?
Appserver is WAS 7.0.0.5, if it works, I think this is a bug? Can anyone confirm?
source
share