users@glassfish.java.net

Dependency Injection not working for JSP-injected Beans

From: <glassfish_at_javadesktop.org>
Date: Mon, 09 Aug 2010 02:50:03 PDT

Hello,

I have 2 beans, which get injected into
a) a Servlet
b) a JSP.

Let's start w/ option a).

The first bean is referenced by the Servlet through

@EJB private TestIF test;

Inside TestIF's implementation (class Test), another dependency injection takes place:

@EJB private BeanIF bean;

This class does something.

In the context of example a), everything is working fine (i.e., Test is getting a reference to Bean and therefore it succeeds to do its operational task).

Now, I'm switching to option b), getting TestIF injected into my JSP using:

<jsp:useBean id="Test" class="Test" />

I get a reference to the bean, but inside Test, the reference to bean Bean does not get injected. I tried several combinations
- <jsp:useBean id="Test" class="Test" />
- <jsp:useBean id="Test" class="Test" scope="application" /> (following http://forums.sun.com/thread.jspa?threadID=5320624 )
- <jsp:useBean id="Test" class="Test" scope="session" />

I also added an empty WEBAPP.war/Web-INF/beans.xml, but that did not change the behavior (found this one at http://forums.java.net/jive/thread.jspa?messageID=472450&#472450 ).

What's wrong here?

Please do not hesitate to ask for any further information required.

Thanks and have a nice week.

kniffte
[Message sent by forum member 'kniffte']

http://forums.java.net/jive/thread.jspa?messageID=479658