java.lang.NoSuchMethodError: org.apache.commons.validator.Validator.setParameter(Ljava/lang/String;Ljava/lang/Object;)V解决方法

ERROR 2009-07-16 11:29:49 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/zxtest].[action] Servlet.service() for servlet action threw exception
java.lang.NoSuchMethodError: org.apache.commons.validator.Validator.setParameter(Ljava/lang/String;Ljava/lang/Object;)V
 at org.apache.struts.validator.Resources.initValidator(Resources.java:304)
 at org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:106)
 at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:921)
 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:206)
 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
 at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
 at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
 at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
 at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
 at java.lang.Thread.run(Thread.java:595)

解决方法:
1、查看jar包版本是否正确,将“commons-validator.jar”替换为“commons-validator-1.1.4.jar”


ERROR 2009-07-16 11:31:53 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/zxtest].[action] Servlet.service() for servlet action threw exception
java.lang.IllegalArgumentException: Resources cannot be null.
 at org.apache.commons.validator.Validator.<init>(Validator.java:188)
 at org.apache.struts.validator.Resources.initValidator(Resources.java:299)
 at org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:106)
 at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:921)
 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:206)
 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
 at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
 at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
 at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
 at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
 at java.lang.Thread.run(Thread.java:595)


2、修改 配置文件“struts-config.xml”,添加

    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
  <set-property property="pathnames"
   value="/WEB-INF/classes/config/validation.xml,
           /WEB-INF/classes/config/validator-rules.xml" />
  </plug-in>
 
  并在对应的目录添加:validation.xml 和 validator-rules.xml
 
  ERROR 2009-07-16 11:37:04 org.apache.commons.digester.Digester Parse Error at line 2 column 17: Document root element "form-validation", must match DOCTYPE root "null".
org.xml.sax.SAXParseException: Document root element "form-validation", must match DOCTYPE root "null".
 at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
          .
          .
          .
          .
3、修改 “validation.xml”,添加

<!DOCTYPE form-validation PUBLIC
          "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
          "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
         
 OK,问题解决

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值