Announcement Announcement Module
No announcement yet.
Spring 2.x to Spring 3.x upgrade Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 2.x to Spring 3.x upgrade

    Hi All,

    We are upgrading Spring 2.x base web application to 3.x. After upgrade I am getting following exception in Login page it self.

    We have our own taglib which works fine in Spring 2.x where as it throwing exception with Spring 3.x

    Using org.springframework.web.servlet.mvc.UrlFilenameVie wController as the Conroller

    org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/login.jsp at line 49
    46:     </form>
    47:     <br/>
    48:     <br/>
    49:     <security:a href="${app}/user/forgotUserId">Forgot Username</security:a>
    50:     <br/>
    51:     <security:a href="${app}/user/resetPassword">Reset Password</security:a>
    52: </div>
    java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name '' available as request attribute<init>(
    Any help would be great.

    here is my login.jsp

    <%@ page import="org.acegisecurity.AuthenticationServiceException" %>
    <%@ include file="include.jsp" %>
    <!--<body onload="$('user_name').focus();">-->
    <%-- $('x') does not work in Firefox ... --%>
    <body onload="document.getElementById('user_name').focus();">
    <div class="smallCenteredBox">
        <c:if test="${not empty sessionScope.ACEGI_SECURITY_LAST_EXCEPTION and not empty param.login_error}">
            <div class="error">
                <!--Your login attempt was not successful, please try again.<BR/>-->
        <form name="loginForm" action="${ctx}/app/j_security_check" method="POST">
                    <th><label for="user_name">Username:</label></th>
                        <input id="user_name" type='text' name='j_username'
                    <th><label for="password">Password:</label></th>
                        <input id="password" type="password" name="j_password"/>
                        <input type="submit" class="button" name="submit" value="Submit"/>
                        <input type="reset" class="button" name="reset" value="Reset"/>
        <security:a href="${app}/user/forgotUserId">Forgot Username</security:a>
        <security:a href="${app}/user/resetPassword">Reset Password</security:a>
    Last edited by ndhilliprasad; Aug 9th, 2012, 07:26 AM.

  • #2
    I have found the solution.

    The problem here is i don't have model object configured for the form as i am using the normal html form tag instead of <form:form> tag.

    When it tries to render the the custom tag lib it is trying to auto generate the id and name values in

    In spring 3.x This class uses BindStatus to find the model in the request. In my case model is empty. which is resulting in an Exception

    snapshot of code where the exception is thrown in the BindStatus
    139		Object target = requestContext.getModelObject(beanName);
    140		if (target == null) {
    141	                  throw new IllegalStateException("Neither BindingResult nor plain target object for bean name '" +
    142						beanName + "' available as request attribute");
    143	}

    To tweak this I have provide my own implementation for org.springframework.web.servlet.mvc.UrlFilenameVie wController as following

    package com.orbitz.bop.web.controllers;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.springframework.web.servlet.ModelAndView;
    import org.springframework.web.servlet.mvc.UrlFilenameViewController;
    public class UrlFilenameViewModelController extends UrlFilenameViewController{
        protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
            ModelAndView modelView = super.handleRequestInternal(request, response);
            return modelView;
    here i am setting a dummy model object value against the empty model name.

    This problem is not there in the spring 2.x