EDIT: This is an ADF application which uses JSF 2.0.
I have an application-scoped managed bean which I am referencing in the managed property of a request-scoped bean. I am getting a NullPointerException when trying to access the app-scoped bean within the PostConstruct method of the request-scoped bean. I am not sure whether I am not understanding some fundamentals about when an app-scoped bean is available to a request-scoped bean, or whether I just have a mistake in my implementation.
App-scoped bean:
@ManagedBean(eager=true)
@ApplicationScoped
public class SecurityApplication {
public String test() {
return "test result";
}
@PostConstruct
public void init() {
System.out.println("In SecurityApplication.init");
}
}
EDIT: This is configured as a request-scoped managed bean in the adfc-config.xml file. This appears to be the problem since I have specified that the bean be managed by ADF, but used the JSF ManagedProperty annotation.
Request-scoped bean:
public class UserSecurityCompanies {
@ManagedProperty(value="#{securityApplication}")
private SecurityApplication securityApplication;
@PostConstruct
public void init() {
System.out.println("In UserSecurityCompanies.init");
System.out.println("SecurityApp.Test():" + getSecurityApplication().test());
}
public SecurityApplication getSecurityApplication() {
return securityApplication;
}
public void setSecurityApplication(SecurityApplication securityApplication) {
this.securityApplication = securityApplication;
}
}
The app-scoped bean is initialized during deployment of the app, but the NPE is thrown when getSecurityApplication().test() is called.
Steve