我有一个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

但我不了解它的起源。有人可以帮我吗?

谢谢!

最佳答案

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

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

10-08 07:33