1 Reply Latest reply on Mar 9, 2006 7:06 AM by jim burton

    JSF managed bean problem: javax.faces.FacesException: Can't

    jim burton Newbie

      I have a problem with a managed bean in a JSF app deployed on JBoss 4.0.3. When I refer to it in a jsp like:

      <h:outputText value="#{correspondor.newCorrespondence}"/> <% /* for side effect */%>
      

      this exception is thrown:
      javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.faces.FacesException: javax.faces.FacesException: Can't instantiate class: 'uk.gov.brightonhove.adaptability.CorrespondenceBean'.. class uk.gov.brightonhove.adaptability.CorrespondenceBean : java.lang.NullPointerException
       org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:844)
       org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
       org.apache.jsp.jsp.formLetter_jsp._jspService(org.apache.jsp.jsp.formLetter_jsp:202)
       org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
       org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
       com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
       com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
       com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
       com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
       uk.gov.brightonhove.FilterLogin.doFilter(FilterLogin.java:48)
       org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
       org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      


      The bean compiles fine and is in the classpath of the war file when it's deployed. It is referenced in faces-config like:
      <managed-bean>
       <managed-bean-name>correspondor</managed-bean-name> <managed-bean-class>uk.gov.brightonhove.adaptability.CorrespondenceBean</managed-bean-class>
       <managed-bean-scope>request</managed-bean-scope>
       </managed-bean>
      

      the bean looks like
      package uk.gov.brightonhove.adaptability;
      
      import java.util.Date;
      import java.util.Iterator;
      import java.util.List;
      
      import javax.faces.application.FacesMessage;
      import javax.faces.context.FacesContext;
      import javax.faces.model.SelectItem;
      
      import uk.gov.brightonhove.adaptability.dao.CorrespondenceDao;
      import uk.gov.brightonhove.adaptability.dao.ProjectTaskDao;
      import uk.gov.brightonhove.adaptability.dao.TaskTemplateDao;
      import uk.gov.brightonhove.adaptability.pojo.Correspondence;
      import uk.gov.brightonhove.adaptability.pojo.ProjectA;
      import uk.gov.brightonhove.adaptability.pojo.ProjectTask;
      import uk.gov.brightonhove.adaptability.pojo.TaskTemplate;
      
      public class CorrespondenceBean extends BaseBean {
      
       private Correspondence correspondence;
       private ProjectTask task;
       private boolean disabled;
       private HomeBean home;
       private ProjectA project;
      
       public CorrespondenceBean() {
       home = (HomeBean)getAdaptBeanBinding("#{homer}");
       newCorrespondence();
       }
      
       protected void newCorrespondence() {
       disabled = false;
       correspondence = new Correspondence();
       task = home.getChosenTask();
       project = task.getProject();
       getFormLettersForTask();
       correspondence.setTemplateid((Short)formLettersForTask[0].getValue());
       if (task.getDate_completed() == null) {
       correspondence.setProjecttaskid(task.getProjectTaskId());
       } else {
       disabled = true;
      // correspondence = new CorrespondenceDao().getCorrespondence()
       System.out.println("todo");
       }
       }
       //snip
      }
      


      why is my bean not found? TIA