I have a xhtml page and in it i use informations that stored in a backing bean. but i need do some operation in bean construction before xhtml use thats. the operation consist retrieve data from database.
then i use a method for this operation and called it as search
and annotated it with @PostConstruct. but when i call my xhtml page i get following Exception :
type Exception report
message An error occurred performing resource injection on managed bean MemberSearchControler
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: An error occurred performing resource injection on managed bean MemberSearchControler
javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
root cause
com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean MemberSearchControler
com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:227)
com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:103)
com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:69)
org.apache.el.parser.AstValue.getValue(AstValue.java:112)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
javax.faces.component.UIData.getValue(UIData.java:732)
javax.faces.component.UIData.getDataModel(UIData.java:1811)
javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:484)
javax.faces.component.UIData.setRowIndex(UIData.java:473)
com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:82)
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:864)
javax.faces.component.UIData.encodeBegin(UIData.java:1133)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1894)
javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1896)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:451)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
org.apache.myfaces.tomahawk.application.ResourceViewHandlerWrapper.renderView(ResourceViewHandlerWrapper.java:169)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
root cause
com.sun.faces.spi.InjectionProviderException: java.lang.IllegalArgumentException: Invalid PostConstruct annotation
com.sun.faces.vendor.Tomcat6InjectionProvider.invokePostConstruct(Tomcat6InjectionProvider.java:120) com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:221) com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:103) com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409) com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269) com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244) com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116) com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:69) org.apache.el.parser.AstValue.getValue(AstValue.java:112) org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) javax.faces.component.UIData.getValue(UIData.java:732) javax.faces.component.UIData.getDataModel(UIData.java:1811) javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:484) javax.faces.component.UIData.setRowIndex(UIData.java:473) com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:82) javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:864) javax.faces.component.UIData.encodeBegin(UIData.java:1133) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1894) javax.faces.render.Renderer.encodeChildren(Renderer.java:176) javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1896) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899) com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:451) com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) org.apache.myfaces.tomahawk.application.ResourceViewHandlerWrapper.renderView(ResourceViewHandlerWrapper.java:169) com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219) javax.faces.webapp.FacesServlet.service(FacesServlet.java:647) root cause
java.lang.IllegalArgumentException: Invalid PostConstruct annotation org.apache.catalina.util.DefaultAnnotationProcessor.postConstruct(DefaultAnnotationProcessor.java:85) com.sun.faces.vendor.Tomcat6InjectionProvider.invokePostConstruct(Tomcat6InjectionProvider.java:118) com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:221) com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:103) com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409) com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269) com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244) com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116) com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:69) org.apache.el.parser.AstValue.getValue(AstValue.java:112) org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) javax.faces.component.UIData.getValue(UIData.java:732) javax.faces.component.UIData.getDataModel(UIData.java:1811) javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:484) javax.faces.component.UIData.setRowIndex(UIData.java:473) com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:82) javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:864) javax.faces.component.UIData.encodeBegin(UIData.java:1133) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1894) javax.faces.render.Renderer.encodeChildren(Renderer.java:176) javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1896) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899) com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:451) com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) org.apache.myfaces.tomahawk.application.ResourceViewHandlerWrapper.renderView(ResourceViewHandlerWrapper.java:169) com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219) javax.faces.webapp.FacesServlet.service(FacesServlet.java:647) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.37 logs.
and this is my backing bean :
ManagedBean(name="MemberSearchControler")
@SessionScoped
public class MemebrSearchControl {
public MemebrSearchControl(){
System.out.println("Test");
}
private String text;
private List<Member> members;
//For Create CheckBox
private int[] membersId;
public int[] getMembersId() {
return membersId;
}
//For get Selected Member Id
private int[] selectedMembers;
public void setSelectedMember(int[] ids) {
selectedMembers=ids;
}
public List<Member> getMembers() {
return members;
}
public int getMembersCount() {
return membersCount;
}
private int membersCount;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
@PostConstruct
public String search() throws DaoImplNotFoundException, DataSourceException{
MemberDao dao=(MemberDao) Factory.getDao(ConfigReader.getConfig().getProperty("dao.member"));
members=dao.list(1, 10);
membersId=new int[members.size()];
for(int i=0;i<members.size();i++)
membersId[i]=members.get(i).getId();
return "member";
}
}