users@glassfish.java.net

Problem with resource injection in ServletContexListener

From: Winzinger, Ralph <ralph.winzinger_at_senacor.com>
Date: Wed, 25 Nov 2009 11:50:15 +0100

 
Hi there,
 
I do have a little problem with resource injection into a ServletContextListener. As long as the listener was part of my webapp (thus located in WEB-INF/classes) everything was fine. Then I decided to extract it into a separate module (located in WEB-INF/lib/xyz.jar) and the resource won't get injected anymore.
 
To track down the problem, I put a slightly renamed copy of the listener back into the webapp - exactly the same code - and declared both listeners in web.xml. One is getting the resource injected, the other one not.
 
I tried field-based and method-based - no difference.
 
Is there any logging that can be enabled to have a look on what's actually happening?
 
 
my web.xml is very small:
 
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
 
  <listener>
    <listener-class>senacor.hd.sharedservices.infrastructure.GlassfishContextLoaderListener</listener-class>
  </listener>
  <listener>
    <listener-class>senacor.hd.sharedservices.infrastructure.GlassfishContextLoaderListener2</listener-class>
  </listener>
 
  <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
 
  <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.htm</url-pattern>
  </servlet-mapping>
 
  <welcome-file-list>
    <welcome-file>redirect.jsp</welcome-file>
  </welcome-file-list>
</web-app>