users@glassfish.java.net

Re: AW: Problem with resource injection in ServletContexListener

From: Sahoo <Sahoo_at_Sun.COM>
Date: Wed, 25 Nov 2009 18:28:23 +0530

The behavior you are observing sounds very strange to me. Are you
deploying a plain web app or a web app as an OSGi bundle? Does it happen
any kind of resource or only for OSGi service? Can you try injecting
something like
@Resource DataSource(name="jdbc/__default");
? Can you attach a simple test case?

Thanks,
Sahoo

Winzinger, Ralph wrote:
> I forgot to mention that I'm using V3 b 72
>
> And I just tried one more thing ... even though, the resource (which is an OSGi Service) doesn't get injected, I'm able to look it up via JNDI ...
>
> ________________________________
>
> Von: Winzinger, Ralph [mailto:ralph.winzinger_at_senacor.com]
> Gesendet: Mi 25.11.2009 11:50
> An: users_at_glassfish.dev.java.net
> Betreff: Problem with resource injection in ServletContexListener
>
>
>
>
> 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>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>