users@glassfish.java.net

Glassfish 3.1.1 injection problem

From: <forums_at_java.net>
Date: Fri, 29 Jul 2011 16:02:44 -0500 (CDT)

Hello,

I am trying a very simple injection of one managed bean into another. I have
an Application Scoped bean that I am trying to inject into a Session bean.
For some reason the injection never occurs. I am using Glassfish 3.1.1 build
12 and ubuntu 64 bit. The jre is Open JDK 6. I end up getting a null pointer
exception for the object. I have no problem if I use the older code for
retrieving managed beans in the constructor of the Session bean, which is
context.getApplication().getELResolver().getValue(context.getELContext(),null,beanName).
Any help would be appreciated. Thanks.

The code is as follows:

Application Scoped Bean:

[code]

@Named(value="siteSettings")

@ApplicationScoped

public class SiteSettings

{

.......

}

[/code] 

Session Bean:

[code]

@Named(value="order")

@SessionScoped

public class Order implements Serializable

{

@Inject

private SiteSettings siteSettings; 

.....

}

[/code]


--
[Message sent by forum member 'jimwebguru']
View Post: http://forums.java.net/node/827751