Announcement Announcement Module
Collapse
No announcement yet.
Spring MVC: BindStatus IllegalStateException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring MVC: BindStatus IllegalStateException

    I'm getting the following exception:
    Code:
    java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'queryDepositSummary' available as request attribute
    	org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141)	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:172)
    (...)
    I have the following bean declaration(QueryController extends SimpleFormController):
    Code:
        <bean id="queryController" class="nisc.gateway.proc.reporting.controller.QueryController" >
            <property name="commandName" value="queryDepositSummary" />
            <property name="commandClass" value="controller.command.QueryDepositSummary" />
            <property name="formView" value="depositSummaryReport.html"/>
            <property name="successView" value="depositSummaryReport.html"/>
    		<property name="sessionForm" value="true" />
        </bean>
    The commandName reference to queryDepositSummary is this bean declaration (currently a simple data bean with hard-coded field values):
    Code:
    <bean id="queryDepositSummary" class="controller.command.QueryDepositSummary" />
    After referencing the Spring MVC docs and reading several other forum posts re: BindStatus IllegalStateException, I expected to resolve this exception by implementing certain methods in my SimpleFormController (QueryController), like formBackingObject():
    Code:
        protected Object formBackingObject(HttpServletRequest request) {
            QueryDepositSummary queryDepSum = new QueryDepositSummary();
            return queryDepSum;
        }
    and onSubmit(), also overridden in my QueryController:
    Code:
      public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command) throws ServletException {
            QueryDepositSummary queryDepositSummary = (QueryDepositSummary) command;
            WebUtils.setSessionAttribute(request, getFormSessionAttributeName(), command);
            return new ModelAndView(getSuccessView());
        }
    The IllegalStateException is being thrown before methods of QueryController are called, so the problem lies somewhere else.

    Any suggestions?

  • #2
    To clarify, I'm using Spring 2.5.6.
    The related JSP file is this:
    Code:
    <%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
    <%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
    <%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
    
        <form:form action="depositSummaryReport.html" commandName="queryDepositSummary" method="post">
          <table>
              <tr>
                  <td>Transaction Type:</td>
                  <td><form:select path="transTypeList" items="queryDepositSummary.transTypeList" /></td>
              </tr>
              <tr>
                  <td colspan="2">
                      <input type="submit" value="Query" />
                  </td>
              </tr>
          </table>
        </form:form>
        <hr/>
    This is the relevant portion of the exception message:

    Code:
    java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'queryDepositSummary' available as request attribute
    	org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141)
    	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:172)
    	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:192)
    	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:158)
    	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:145)
    	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:136)
    	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:120)
    	org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:379)
    	org.springframework.web.servlet.tags.form.SelectTag.writeTagContent(SelectTag.java:198)
    	org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:90)
    	org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:77)
    (...)
    Feedback is appreciated.
    Thank you.

    Comment


    • #3
      Could you post your configuration with your URL handler mapping ?
      It seems you're accessing your JSP directly, without going through the controller first.

      Comment


      • #4
        Sure -- here is the URL handler mapping:
        Code:
          <bean id="publicUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
                <property name="mappings">
                    <value>
                        **/depositSummaryReport.html=queryController
                    </value>
                </property>                       
            </bean>
        Merci beaucoup pour l'assistance, mlarchet...

        Comment


        • #5
          The SimpleUrlHandlerMapping is simple -- nothing to go wrong there (shown earlier in thread...).
          Although I am not using annotations, is an explicitly configured modelAttribute required somewhere that I have not implemented?

          Any other thoughts?

          Comment

          Working...
          X