title: Spring BindingResult Error
body: <p>I am getting following error message:</p>
  
  <pre><code>java.lang.IllegalStateException: Neither BindingResult 
  nor plain target object for bean name 'billingInfoCommand' 
  available as request attribute
  </code></pre>
  
  <p>My JSP looks like:</p>
  
  <pre><code>    &lt;form:form commandName="billingInfoCommand" method="post" 
  onsubmit="return checkVals()"&gt;
  </code></pre>
  
  <p>My controller looks like:</p>
  
  <pre><code>public class BillingInfoController extends FusionFormController {
      protected final Log logger = LogFactory.getLog(getClass());
      private FieldAccessService fieldAccessService;
  
          public BillingInfoController(){
          setCommandClass(CommonCommand.class);
          setCommandName("billingInfoCommand");
      }
  
     protected Map referenceData(HttpServletRequest request,Object command, Errors errors) throws Exception {
  
          CommonCommand commonCommand=(CommonCommand)command;
          HashMap&lt;String,Object&gt; refDataMap=new HashMap&lt;String,Object&gt;();
          refDataMap.put("billingTypes",this.getLookupValsAsMap("getBillingTypes"));
          Long stageId=commonCommand.getEmeaMain().getStageId();
          refDataMap.put("requiredFields",requiredFields);
          return refDataMap;
      }
  
  
    public Object formBackingObject(HttpServletRequest request){
          BillingInfo billingInfoObj=null;
          Long cepWorkItemNo=null;
          CommonCommand billingInfoCommand=new CommonCommand();
          try{
           cepWorkItemNo=new Long(request.getParameter("cep_work_item_no"));
          }catch(NumberFormatException e){
          }
          if(cepWorkItemNo==null){
             billingInfoObj=new BillingInfo();
          }else{
            billingInfoObj=(BillingInfo)domainService.getDomainObject(BillingInfo.class,cepWorkItemNo);
          }
          if(billingInfoCommand.getBillingInfo()==null)
             billingInfoCommand.setBillingInfo(billingInfoObj);
          if(billingInfoCommand.getEmeaMain()==null)
              billingInfoCommand.setEmeaMain(emeaMain);
          return billingInfoCommand;
     }
  }
  </code></pre>
  
  <p>My Pojo class looks like:</p>
  
  <pre><code>public class BillingInfo {
  
      private Integer billingId;
  
      public Integer getBillingId() {
          return billingId;
      }
      public void setBillingId(Integer billingId) {
          this.billingId = billingId;
      }
  }
  </code></pre>
  
  <p><strong>Note</strong></p>
  
  <p>I have posted only relevant pieces of code here. I am not sure as to why am I getting mentioned error about IllegalStateException and some useful pointers would be appreciated. </p>
  
  <p>Also, what are normal reason for getting <code>Neither BindingResult nor plain target object for bean name x available as request attribute</code> errors ?</p>
  
  <p><strong>Full Stack Trace</strong></p>
  
  <pre><code> - java.lang.IllegalStateException:
     Neither BindingResult nor plain
     target object for bean name
     'billingInfoCommand' available as
     request attribute
         java.lang.IllegalStateException: Neither BindingResult nor plain
     target object for bean name
     'billingInfoCommand' available as
     request attribute at
     org.springframework.web.servlet.support.BindStatus.(BindStatus.java:148)
     at
     org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:179)
     at
     org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.resolveCssClass(AbstractHtmlElementTag.java:404)
     at
     org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:380)
     at
     org.springframework.web.servlet.tags.form.LabelTag.writeTagContent(LabelTag.java:89)
     at
     org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:90)
     at
     org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:77)
     at
     org.apache.jsp.WEB_002dINF.jsp.globalecep.ap.billing_005finfo_jsp._jspx_meth_form_005flabel_005f0(billing_005finfo_jsp.java:1243)
     at
     org.apache.jsp.WEB_002dINF.jsp.globalecep.ap.billing_005finfo_jsp._jspService(billing_005finfo_jsp.java:363)
     at
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
     at
     javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
     at
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
     at
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
     at
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
     at
     javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
     at
     org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
     at
     org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
     at
     org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:659)
     at
     org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:565)
     at
     org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:493)
     at
     org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:965)
     at
     org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:600)
     at
     org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:137)
     at
     org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:177)
     at
     org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:756)
     at
     org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:881)
     at
     org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:473)
     at
     org.apache.jsp.WEB_002dINF.fusion.jsp.tab_005ftemplate_jsp._jspx_meth_tiles_005finsert_005f2(tab_005ftemplate_jsp.java:1807)
     at
     org.apache.jsp.WEB_002dINF.fusion.jsp.tab_005ftemplate_jsp._jspService(tab_005ftemplate_jsp.java:307)
     at
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
     at
     javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
     at
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
     at
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
     at
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
     at
     javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
     at
     org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
     at
     org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
     at
     org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:659)
     at
     org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:457)
     at
     org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:395)
     at
     org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311)
     at
     org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:145)
     at
     org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:251)
     at
     org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1144)
     at
     org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:880)
     at
     org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:793)
     at
     org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
     at
     org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
     at
     javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
     at
     javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
     at
     org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
     at
     org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
     at
     org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
     at
     org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
     at
     org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
     at
     org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
     at
     org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
     at
     org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
     at
     org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:879)
     at
     org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
     at
     org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
     at
     org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
     at
     org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
     at
     java.lang.Thread.run(Thread.java:595)
  </code></pre>
  
  <p>Servlet Config Mapping File:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:aop="http://www.springframework.org/schema/aop"
         xsi:schemaLocation="http://www.springframework.org/schema/beans
                             http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                             http://www.springframework.org/schema/aop
                             http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"&gt;
  
  
      &lt;bean id="apbillingInfoController" class="ap.BillingInfoController"&gt;
        &lt;property name="queryService" ref="queryService" /&gt;
        &lt;property name="domainService" ref="domainService" /&gt;
        &lt;property name="formView" value="ap_billinginfo"/&gt;
        &lt;property name="validator" ref="apbillingInfoValidator" /&gt;
        &lt;property name="fieldAccessService"  ref="fieldAccessService"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="apbillingInfoValidator"  class="validator.ap.BillingInfoValidator"&gt;
             &lt;property name="queryService" ref="queryService" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="apcompanyBillingInfoController" class="ap.company.COMPANYBillingInfoController"&gt;
        &lt;property name="commandName"   value="companyBillingInfoBean"/&gt;
        &lt;property name="commandClass"  value="command.ap.company.COMPANYCommonCommand"/&gt;
        &lt;property name="queryService" ref="queryService" /&gt;
        &lt;property name="domainService" ref="domainService" /&gt;
        &lt;property name="formView" value="ap_companybillinginfo"/&gt;
        &lt;property name="validator" ref="apcompanyBillingInfoValidator" /&gt;
        &lt;property name="fieldAccessService"  ref="fieldAccessService"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="apcompanyBillingInfoValidator"  class="validator.ap.company.COMPANYBillingInfoValidator"&gt;
          &lt;property name="fieldAccessService"  ref="fieldAccessService"/&gt;
         &lt;property name="queryService" ref="queryService" /&gt;
      &lt;/bean&gt;
        &lt;property name="mappings"&gt;
          &lt;props&gt;
            &lt;prop key="/ap_billing.htm"&gt;apbillingInfoController&lt;/prop&gt;
          &lt;/props&gt;
        &lt;/property&gt;
      &lt;/bean&gt;
  
        &lt;property name="mappings"&gt;
          &lt;props&gt;
            &lt;prop key="/company_ap_billing.htm"&gt;apcompanyBillingInfoController&lt;/prop&gt;
          &lt;/props&gt;
        &lt;/property&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>Thanks. </p>