是什么导致“NoSuchMethodError:org.springframework.beans.BeanWrapper.setAutoGrowCollectionLimit(I)V?”

时间:2011-10-04 08:23:06

标签: java hibernate spring jsp maven

我有一个使用Spring和Hibernate的Maven项目。当我编译项目时它没问题,但是当我在tomcat中运行它时发现了这些错误:

   org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/contact.jsp at line 16

    13:  
    14:     <table>
    15:     <tr>
    16:         <td><form:label path="firstname"><spring:message code="label.firstname"/></form:label></td>
    17:         <td><form:input path="firstname" /></td>
    18:     </tr>
    19:     <tr>


    Stacktrace:
        org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
        org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
        org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    root cause

    javax.servlet.ServletException: java.lang.NoSuchMethodError: org.springframework.beans.BeanWrapper.setAutoGrowCollectionLimit(I)V
        org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
        org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
        org.apache.jsp.WEB_002dINF.jsp.contact_jsp._jspService(contact_jsp.java:99)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
        org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
        org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    root cause

    java.lang.NoSuchMethodError: org.springframework.beans.BeanWrapper.setAutoGrowCollectionLimit(I)V
        org.springframework.validation.BeanPropertyBindingResult.getPropertyAccessor(BeanPropertyBindingResult.java:94)
        org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:98)
        org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:225)
        org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:120)
        org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:174)
        org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:194)
        org.springframework.web.servlet.tags.form.LabelTag.autogenerateFor(LabelTag.java:129)
        org.springframework.web.servlet.tags.form.LabelTag.resolveFor(LabelTag.java:119)
        org.springframework.web.servlet.tags.form.LabelTag.writeTagContent(LabelTag.java:89)
        org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
        org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
        org.apache.jsp.WEB_002dINF.jsp.contact_jsp._jspx_meth_form_005flabel_005f0(contact_jsp.java:208)
        org.apache.jsp.WEB_002dINF.jsp.contact_jsp._jspx_meth_form_005fform_005f0(contact_jsp.java:130)
        org.apache.jsp.WEB_002dINF.jsp.contact_jsp._jspService(contact_jsp.java:83)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
        org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
        org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

我认为最重要的问题是:

org.springframework.beans.BeanWrapper.setAutoGrowCollectionLimit(I)V

但我不明白它的起源。请问有人帮帮我吗?

谢谢!

1 个答案:

答案 0 :(得分:6)

错误说明了一切:方法setAutoGrowCollectionLimit在加载到内存中的类BeanWrapper的版本中不存在。通常这是类路径问题,这是由类路径上较旧或不兼容的JAR版本引起的。

在这种情况下,查看WEB-INF / lib中的spring-core.jar文件,您的EAR(如果有的话)以及应用服务器的各种库目录。确保您只有一个副本,并且它与您编译的版本相同。