EJB Injection and NullPointerExcception Development tools: --------------- Linux Java 6.x JSF 1.2 richfaces-ui-3.3.1.GA JBoss 5.1.0.GA Liferay-5.2.3
Outline: When EJB Stateless bean is injected into JSF/RichFaces managed bean and ran, the result is NullPointerException. I have tried using one of the followings without success: (i) @EJB (ii) @EJB(name = "DataConstraintController") (iii) @javax.ejb.EJB(name = "DataConstraintController", mappedName="odms/DataConstraintDAOImpl/local") (iv) With explicit JNDI lookup: javax.naming.InitialContext initialContext = new javax.naming.InitialContext(); | return (DataConstraintLocal) initialContext.lookup("odms/DataConstraintController/local"); | } catch (Exception e) { | e.printStackTrace(); | throw new RuntimeException("couldn't lookup DataConstraintLocal", e); | } | It is an ongoing project so changes are often made to the java files, but the deployment files have not changed for the past three months and it was runing until two days ago. And no one seem to know why EJB injection is failing. The ejb.jar, ejbClient.jar and *.war are in the same ear. Could it be a corrupt library? Should I re-install JBoss? Help! and thanks in advance. -------------------------------------------------------------------------------------- EJB Local Interface: DataConstraintLocal -------------------------------------------------------------------------------------- @javax.ejb.Local | public interface DataConstraintLocal extends com.xxxxx.xxxx.ejb.intf.DataConstraintService, java.io.Serializable{ | | } -------------------------------------------------------------------------------------- EJB Remote Interface: DataConstraintRemote -------------------------------------------------------------------------------------- @javax.ejb.Local | public interface DataConstraintRemote extends com.xxxxx.xxxx.ejb.intf.DataConstraintService, java.io.Serializable{ | | } | -------------------------------------------------------------------------------------- EJB Session Bean: DataConstraintController -------------------------------------------------------------------------------------- | import com.xxxxx.xxxx.domain.bean.DataConstraintEntity; | import com.xxxxx.xxxx.dao.intf.DataConstraintDAOLocal; | | @javax.ejb.Stateless(name="DataConstraintController") | public class DataConstraintController implements com.xxxxx.xxxx.ejb.intf.DataConstraintRemote, com.xxxxx.xxxx.ejb.intf.DataConstraintLocal{ | | | @javax.ejb.EJB(mappedName="odms/DataConstraintDAOImpl/local") | private DataConstraintDAOLocal delegate; | | public DataConstraintController() { | } | | /** | * Finder method for DataConstraintEntity object held in a database | * | * @return the list of DataConstraintEntity objects in the database | */ | @javax.ejb.TransactionAttribute(javax.ejb.TransactionAttributeType.NOT_SUPPORTED) | public DataConstraintEntity[] findAll() throws com.xxxxx.xxxx.gen.exception.EJBException { | | java.util.List<DataConstraintEntity> retList = delegate.findAll(); | return (DataConstraintEntity[]) retList.toArray(new DataConstraintEntity[retList.size()]); | } | .... | } -------------------------------------------------------------------------------------- Backing Bean: NewUserBkBean -------------------------------------------------------------------------------------- public class NewUserBkBean implements java.io.Serializable{ | | private static final String CRUD_MODE = "all"; | private static final String TABLE_NAME = com.xxxxx.xxxx.domain.bean.UserEntity.TABLE_NAME; | | | public NewUserBkBean(){ | init(); | } | | private void init(){ | java.util.Map<String, Object> propertyValues = new java.util.HashMap<String, Object>(); | propertyValues.put("parentTable", TABLE_NAME); | propertyValues.put("crudMode", CRUD_MODE); | try { | if(dataConstraintController == null){ | //throw new NullPointerException("Null dataConstraintController"); | } | DataConstraintEntity[] retList = dataConstraintController.findAll(); | if(retList == null || retList.length == 0){ | throw new NullPointerException("DataConstraintEntity is empty: common cause is absence of data in the DataConstraint db table"); | } | UserFormBean userFormBean = new UserFormBean(retList, new com.xxxxx.xxxx.web.model.UserCredential(), UserFormBean.class); | if(userFormBean != null){ | setFormBean(userFormBean); | renderUserComponents(); | renderDocumentComponents(); | renderObjectExComponents(); | } | } catch (Exception e) { | e.printStackTrace(); | } | } | -------------------------------------------------------------------------------------- StackTrace -------------------------------------------------------------------------------------- 18:35:05,670 INFO [faces] Process headers request for portlet MainUserPortlet | 18:35:05,675 INFO [faces] Process view request for portlet MainUserPortlet | 18:36:02,257 ERROR [STDERR] java.lang.NullPointerException | 18:36:02,293 ERROR [STDERR] at com.xxxxx.xxxx.web.bean.NewUserBkBean.init(NewUserBkBean.java:230) | 18:36:02,294 ERROR [STDERR] at com.xxxxx.xxxx.web.bean.NewUserBkBean.<init>(NewUserBkBean.java:209) | 18:36:02,294 ERROR [STDERR] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) | 18:36:02,294 ERROR [STDERR] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) | 18:36:02,295 ERROR [STDERR] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) | 18:36:02,295 ERROR [STDERR] at java.lang.reflect.Constructor.newInstance(Constructor.java:513) | 18:36:02,295 ERROR [STDERR] at java.lang.Class.newInstance0(Class.java:355) | 18:36:02,296 ERROR [STDERR] at java.lang.Class.newInstance(Class.java:308) | 18:36:02,296 ERROR [STDERR] at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:186) | 18:36:02,296 ERROR [STDERR] at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:106) | 18:36:02,297 ERROR [STDERR] at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:368) | 18:36:02,297 ERROR [STDERR] at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:230) | 18:36:02,298 ERROR [STDERR] at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:86) | 18:36:02,298 ERROR [STDERR] at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54) | 18:36:02,299 ERROR [STDERR] at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72) | 18:36:02,299 ERROR [STDERR] at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61) | 18:36:02,299 ERROR [STDERR] at org.apache.el.parser.AstValue.getValue(AstValue.java:107) | 18:36:02,300 ERROR [STDERR] at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) | 18:36:02,300 ERROR [STDERR] at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71) | 18:36:02,300 ERROR [STDERR] at | ... | | 18:36:02,321 ERROR [STDERR] at com.xxxxx.xxxx.web.portlet.bean.MainFacesPortlet.doView(MainFacesPortlet.java:84) | 18:36:02,322 ERROR [STDERR] at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328) | 18:36:02,322 ERROR [STDERR] at javax.portlet.faces.GenericFacesPortlet.doDispatch(GenericFacesPortlet.java:445) | 18:36:02,323 ERROR [STDERR] at com.xxxxx.xxxx.web.portlet.bean.MainFacesPortlet.doDispatch(MainFacesPortlet.java:104) | 18:36:02,324 ERROR [STDERR] at javax.portlet.GenericPortlet.render(GenericPortlet.java:233) | 18:36:02,324 ERROR [STDERR] at com.sun.portal.portletcontainer.appengine.filter.FilterChainImpl.doFilter(FilterChainImpl.java:126) | 18:36:02,325 ERROR [STDERR] at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:69) | 18:36:02,325 ERROR [STDERR] at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:100) | ... | 18:36:18,016 INFO [faces] Process resource request for portlet MainUserPortlet | 18:36:19,501 INFO [faces] Process resource request for portlet MainUserPortlet | 18:36:20,319 | View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4261621#4261621 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4261621 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user