9 Replies Latest reply on Aug 4, 2015 10:11 AM by Prasanth Reddy

    Resource Injection in ServletContextListener

    Prasanth Reddy Newbie

      I have a ServletContextListener into which a DataSource has to be injected. It works fine in Jboss7.1 but does not work in 8.2 or 8.2.1 or 9.01. I have created a sample project to test it and seems like the injection is working if the class is a HttpServlet but doesn't work if the class is just a ServletContextListener. Am I missing something or is there a bug in wildfly?






      <?xml version="1.0" encoding="UTF-8"?>












      public class ContextListener implements ServletContextListener {



          private DataSource dataSource;



          public void contextDestroyed(ServletContextEvent arg0) {

              // TODO Auto-generated method stub





          public void contextInitialized(ServletContextEvent arg0) {

              // TODO Auto-generated method stub




          public DataSource getDataSource() {

              return dataSource;