Announcement Announcement Module
Collapse
No announcement yet.
IllegalAccessError AbstractPropertyBindingResult.getActualFieldValue BindStatus Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • IllegalAccessError AbstractPropertyBindingResult.getActualFieldValue BindStatus

    Im trying to use spring form tag, but failing i don't know what exactly issue with <form:input path="firstName"/>

    I'm getting following exception.

    Code:
    java.lang.IllegalAccessError: tried to access method org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(Ljava/lang/String;)Ljava/lang/Object; from class org.springframework.web.servlet.support.BindStatus
    	at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:128)
    	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.AbstractHtmlInputElementTag.writeDefaultAttributes(AbstractHtmlInputElementTag.java:177)
    	at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:139)
    	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.editUserDetails_jsp._jspx_meth_form_input_0(editUserDetails_jsp.java:320)
    	at org.apache.jsp.WEB_002dINF.jsp.editUserDetails_jsp._jspx_meth_form_form_0(editUserDetails_jsp.java:236)
    	at org.apache.jsp.WEB_002dINF.jsp.editUserDetails_jsp._jspService(editUserDetails_jsp.java:128)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    JSP code
    Code:
    <%@ page contentType="text/html; charset=UTF-8" %>
    <%@ taglib prefix="c" uri="/WEB-INF/tld/c.tld" %>
    <%@ taglib prefix="spring" uri="/WEB-INF/tld/spring.tld" %>
    <%@ taglib prefix="form" uri="/WEB-INF/tld/spring-form.tld" %>
      
    
    <spring:hasBindErrors name="userDto">
      <c:forEach var="err" items="${errors.allErrors}">
        <spring:message code="${err.code}" arguments="${err.arguments[0]}"/>
      </c:forEach>
    </spring:hasBindErrors>
    
    <form:form method="POST" action="editUser.htm" commandName="userDto">
      <p>Edit User Details</p>
    	  <p>User Name&nbsp;&nbsp;&nbsp;<c:out value="${userDto.username}" /> </p>
    	  <input type="hidden" name="username" value="<c:out value="${userDto.username}" />">
      <p>First Name&nbsp;&nbsp;&nbsp; <form:input path="firstName"/> </p>
      <p>Last Name&nbsp;&nbsp;&nbsp; <form:input path="lastName"/> </p>
      <c:choose>
      	<c:when test='${userDto.active == "Y"}'>
    	  <p>Active&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    	   <input type="checkbox" name="active" checked="checked" ></p>
      	</c:when>
      	<c:otherwise>
    	  <p>Active&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    	  <input type="checkbox" name="active" ></p>
      	</c:otherwise>
      </c:choose>
    	<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
    	<c:forEach items="${roles}" var="role">
    	  <tr>
    	    <c:choose>
    		    <c:when test="${role.selected}">
    			    <td width="50%"><c:out value="${role.roleDesc}" /></td>
    			    <td width="50%"><input type="checkbox" name="${role.role}" value="${role.roleId}" checked="checked"></td>
    		    </c:when>
    		    <c:otherwise>
    	    		<td width="50%"><c:out value="${role.roleDesc}" /></td>
    			    <td width="50%"><input type="checkbox" name="${role.role}" value="${role.roleId}"></td>
    		    </c:otherwise>
    	    </c:choose>
    	  </tr>
    	</c:forEach>			
    	</table>
      <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
    </form:form>

  • #2
    controller class where form backing and referenceData method are implemented.

    Code:
    public class EditUserDetailsController extends BaseSimpleFormController {
    
    	@Override
    	protected Object formBackingObject(HttpServletRequest req) throws Exception {
    		userDto =(UserDto) req.getSession().getAttribute("userProfile");
    		return userDto;		
    	}
    
    	public Map constructViewModelData(HttpServletRequest req,Object command,Errors errors) throws Exception {
    		List<RoleDto> listRoles = getReferenceDataService().getAllRoles();
    		listRoles = userDto.getAllRolesWithSelectedUserRoles(listRoles);
    		referenceData.put("roles", listRoles);
    		return referenceData;		
    	}
    
    	public EditUserDetailsController() {
    		setCommandClass(UserDto.class);
    	}
    
    	public ModelAndView execute(HttpServletRequest request,
    			HttpServletResponse response, Object command, BindException errors)
    			throws Exception {
    		UserDto userDto = (UserDto) command;
    		try{
    			.....................
    		}catch(BusinessException businessException){
    			..................
    		}
    		return new ModelAndView(getSuccessView(), getCommandName(), userDto);
    	}
    
    	// COLLABORATORS
    	
    	private UserService userService;
    	private ReferenceDataService referenceDataService;
    	
    	
    }

    Comment


    • #3
      Reading the explanation for IllegalAccessError I don't think it's related to your particular code but probably is once again a classpath problem.

      Joerg

      Comment


      • #4
        Originally posted by sanjay_jadhav View Post
        Im trying to use spring form tag, but failing i don't know what exactly issue with <form:input path="firstName"/>

        I'm getting following exception.

        Code:
        java.lang.IllegalAccessError: tried to access method org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(Ljava/lang/String;)Ljava/lang/Object; from class org.springframework.web.servlet.support.BindStatus
        	at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:128)
        	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.AbstractHtmlInputElementTag.writeDefaultAttributes(AbstractHtmlInputElementTag.java:177)
        	at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:139)
        	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.editUserDetails_jsp._jspx_meth_form_input_0(editUserDetails_jsp.java:320)
        	at org.apache.jsp.WEB_002dINF.jsp.editUserDetails_jsp._jspx_meth_form_form_0(editUserDetails_jsp.java:236)
        	at org.apache.jsp.WEB_002dINF.jsp.editUserDetails_jsp._jspService(editUserDetails_jsp.java:128)
        	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        JSP code
        Code:
        <%@ page contentType="text/html; charset=UTF-8" %>
        <%@ taglib prefix="c" uri="/WEB-INF/tld/c.tld" %>
        <%@ taglib prefix="spring" uri="/WEB-INF/tld/spring.tld" %>
        <%@ taglib prefix="form" uri="/WEB-INF/tld/spring-form.tld" %>
          
        
        <spring:hasBindErrors name="userDto">
          <c:forEach var="err" items="${errors.allErrors}">
            <spring:message code="${err.code}" arguments="${err.arguments[0]}"/>
          </c:forEach>
        </spring:hasBindErrors>
        
        <form:form method="POST" action="editUser.htm" commandName="userDto">
          <p>Edit User Details</p>
        	  <p>User Name&nbsp;&nbsp;&nbsp;<c:out value="${userDto.username}" /> </p>
        	  <input type="hidden" name="username" value="<c:out value="${userDto.username}" />">
          <p>First Name&nbsp;&nbsp;&nbsp; <form:input path="firstName"/> </p>
          <p>Last Name&nbsp;&nbsp;&nbsp; <form:input path="lastName"/> </p>
          <c:choose>
          	<c:when test='${userDto.active == "Y"}'>
        	  <p>Active&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        	   <input type="checkbox" name="active" checked="checked" ></p>
          	</c:when>
          	<c:otherwise>
        	  <p>Active&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        	  <input type="checkbox" name="active" ></p>
          	</c:otherwise>
          </c:choose>
        	<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
        	<c:forEach items="${roles}" var="role">
        	  <tr>
        	    <c:choose>
        		    <c:when test="${role.selected}">
        			    <td width="50%"><c:out value="${role.roleDesc}" /></td>
        			    <td width="50%"><input type="checkbox" name="${role.role}" value="${role.roleId}" checked="checked"></td>
        		    </c:when>
        		    <c:otherwise>
        	    		<td width="50%"><c:out value="${role.roleDesc}" /></td>
        			    <td width="50%"><input type="checkbox" name="${role.role}" value="${role.roleId}"></td>
        		    </c:otherwise>
        	    </c:choose>
        	  </tr>
        	</c:forEach>			
        	</table>
          <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
        </form:form>
        Did you ever figure this out? I'm having the same problem/error and haven't found a solution yet.

        Thanks!

        Comment


        • #5
          Check your classpath for multiple Spring jars of different versions.

          Joerg

          Comment


          • #6
            I'm having the same problem/error were u able to fix it ????????????????

            Comment


            • #7
              I got the same problems!!! I put the spring.jar (which included all required library, isn't it.) into the WEB-INF/lib already. But the problems is still occur....

              Shouldn't be the classpath problems..... I think......

              Comment


              • #8
                the problem arises if u have spring.jar and spring-webMVC.jar of different versions..make sure that u have both the jars of the sane version in ur classpath... that should fix ur error.. It did for me.

                Comment


                • #9
                  I am facing the same problem. The Spring.jar, spring-webmvc.jar are from the same version.
                  Still i am facing the same problem.
                  Here is my JSP Code:

                  <form:select cssClass="FormFieldEnabled" path="tube_line" disabled=""
                  onchange="javascript:onChangeTubeLine()" id="SeriesDD">

                  <form:options items="${PadShareCommand.tubeLines}"
                  itemValue="id" itemLabel="line" />
                  </form:select>

                  Can some help me out.

                  Thanks

                  Comment

                  Working...
                  X