users@javaserverfaces.java.net

Initial page loading: the managed bean doesn't inject the EJB when called in the constructor.

From: Todd Patrick <Todd.Patrick_at_dtn.com>
Date: Wed, 5 Sep 2007 09:53:33 -0500

Sun Java System Application Server Platform Edition 9.0_01 (build b02-p01) Sun's JavaServer Faces implementation (1.2_04-b10-p01) NetBeans 5.5.1 When a page loads for the first time, the managed bean doesn't know about the injected EJB inside the constructor: public class RoutingRuleBean extends DeviceBasicBean implements Serializable { @EJB private RouteRuleSessionLocal routeRuleSessionLocal; .... public RoutingRuleBean() { ... if(!ObjectUtils.equals(this.selectedRouteDevcRowDetails, null)) { DeviceDetail selectedDeviceDetail = routeRuleSessionLocal.getRouteDevcDetail(this.selectedRouteDevcRowDetail s.getDeviceKey()); this.device.setValue(selectedDeviceDetail); } In the snippet above, the field "routeRuleSessionLocal" holding the injected EJB is null inside the RoutingRuleBean constructor. So, the JSF Lifecycle is probably looking like - when a page loads for the first time: RESTORE_VIEW [constructor] RENDER_RESPONSE Thus, the injected EJB isn't called until the managed bean is completely initialized and pass the RENDER_RESPONSE phase. Looking at the Java EE API, I know of the PostConstruct annotation, but is there something that I could use before the constructor is called? Thanks, --Todd ----------------------------------------- NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.