ShaleValidator

HomePage | RecentChanges | Preferences

Shale Commons Validator Integration

Shale Validator - Missing message params (20060926)

If you leave out the <arg position="0" name="message" key="submittedValue" resource="false"/>'s, there are no errors, you just see {0} in the message.

Shale Validator - Missing method params (20060926)

This happens when you do not pass any <arg position="0" name="parameter" key="submittedValue" resource="false"/>'s

Can we do a better job of error handling?

[INFO] [talledLocalContainer] SEVERE: Servlet.service() for servlet faces threw exception
[INFO] [talledLocalContainer] java.lang.RuntimeException: Error initializing commons validator for rule type "evenInteger" on component id "priority".
[INFO] [talledLocalContainer]   at org.apache.shale.validator.CommonsValidator.validate(CommonsValidator.java:859)
[INFO] [talledLocalContainer]   at javax.faces.component._ComponentUtils.callValidators(_ComponentUtils.java:157)
[INFO] [talledLocalContainer]   at javax.faces.component.UIInput.validateValue(UIInput.java:312)
[INFO] [talledLocalContainer]   at javax.faces.component.UIInput.validate(UIInput.java:353)
[INFO] [talledLocalContainer]   at javax.faces.component.UIInput.processValidators(UIInput.java:183)
[INFO] [talledLocalContainer]   at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:624)
[INFO] [talledLocalContainer]   at javax.faces.component.UIForm.processValidators(UIForm.java:70)
[INFO] [talledLocalContainer]   at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:624)
[INFO] [talledLocalContainer]   at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:146)
[INFO] [talledLocalContainer]   at org.apache.myfaces.lifecycle.LifecycleImpl.processValidations(LifecycleImpl.java:262)
[INFO] [talledLocalContainer]   at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)
[INFO] [talledLocalContainer]   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
[INFO] [talledLocalContainer]   at org.apache.shale.faces.ShaleApplicationFilter.doFilter(ShaleApplicationFilter.java:267)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
[INFO] [talledLocalContainer]   at net.wsmoak.acctmtce.LocalhostFilter.doFilter(LocalhostFilter.java:98)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
[INFO] [talledLocalContainer]   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
[INFO] [talledLocalContainer]   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
[INFO] [talledLocalContainer]   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
[INFO] [talledLocalContainer]   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
[INFO] [talledLocalContainer]   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
[INFO] [talledLocalContainer]   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
[INFO] [talledLocalContainer]   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
[INFO] [talledLocalContainer]   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
[INFO] [talledLocalContainer]   at java.lang.Thread.run(Thread.java:595)
[INFO] [talledLocalContainer] Caused by: java.lang.IllegalArgumentException: wrong number of arguments
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[INFO] [talledLocalContainer]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[INFO] [talledLocalContainer]   at java.lang.reflect.Method.invoke(Method.java:585)
[INFO] [talledLocalContainer]   at org.apache.shale.validator.CommonsValidator.validate(CommonsValidator.java:852)
[INFO] [talledLocalContainer]   ... 32 more

Shale Validator problem with a custom rule (20060925)

Solution: Add the missing the <formset><form> in custom-rules.xml

We should handle this better. Instead of the assertion, (or NPE if assertions are turned off) check for null and throw a descriptive error message.

custom-rules.xml

<!DOCTYPE form-validation PUBLIC
          "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.3.0//EN"
          "http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd">
<form-validation>
   <global>
       <validator name="evenInteger"
             classname="net.wsmoak.acctmtce.ValidationUtil"
             method="isEven"
             methodParams="int"
             msg="errors.even">
       </validator>
   </global>
</form-validation>

accessRequest.jsp

...
        <h:outputText value="#{messages['prompt.priority']}"/>
        <h:inputText     id="priority"
                      value="#{priority}">
            <s:commonsValidator
                        type="required"
                        arg="#{messages['prompt.priority']}"
                     server="true"
                     client="false"/>
            <s:commonsValidator
                     type="evenInteger"
                   server="true"
                   client="false"/>
        </h:inputText>
...

~/svn/wsmoak/current/acctmtce/webapp
$ ls target/acctmtce/WEB-INF/lib
commons-beanutils-1.7.0.jar  commons-validator-1.3.0.jar
commons-chain-1.1.jar        jstl-1.1.0.jar
commons-codec-1.3.jar        myfaces-api-1.1.4.jar
commons-collections-3.1.jar  myfaces-impl-1.1.4.jar
commons-digester-1.6.jar     oro-2.0.8.jar
commons-el-1.0.jar           shale-core-1.0.4-SNAPSHOT.jar
commons-lang-2.1.jar         xml-apis-1.0.b2.jar
commons-logging-1.0.4.jar

[INFO] [talledLocalContainer] SEVERE: Servlet.service() for servlet faces threw exception
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer]   at org.apache.shale.validator.CommonsValidator.getArgs(CommonsValidator.java:659)
[INFO] [talledLocalContainer]   at org.apache.shale.validator.CommonsValidator.getMethodParamNames(CommonsValidator.java:623)
[INFO] [talledLocalContainer]   at org.apache.shale.validator.CommonsValidator.loadMethodParamValues(CommonsValidator.java:757)
[INFO] [talledLocalContainer]   at org.apache.shale.validator.CommonsValidator.validate(CommonsValidator.java:846)
[INFO] [talledLocalContainer]   at javax.faces.component._ComponentUtils.callValidators(_ComponentUtils.java:133)
[INFO] [talledLocalContainer]   at javax.faces.component.UIInput.validateValue(UIInput.java:254)
[INFO] [talledLocalContainer]   at javax.faces.component.UIInput.validate(UIInput.java:269)
[INFO] [talledLocalContainer]   at javax.faces.component.UIInput.processValidators(UIInput.java:144)
[INFO] [talledLocalContainer]   at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:417)
[INFO] [talledLocalContainer]   at javax.faces.component.UIForm.processValidators(UIForm.java:68)
[INFO] [talledLocalContainer]   at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:417)
[INFO] [talledLocalContainer]   at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:142)
[INFO] [talledLocalContainer]   at org.apache.myfaces.lifecycle.LifecycleImpl.processValidations(LifecycleImpl.java:240)
[INFO] [talledLocalContainer]   at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)
[INFO] [talledLocalContainer]   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
[INFO] [talledLocalContainer]   at org.apache.shale.faces.ShaleApplicationFilter.doFilter(ShaleApplicationFilter.java:271)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
[INFO] [talledLocalContainer]   at net.wsmoak.acctmtce.LocalhostFilter.doFilter(LocalhostFilter.java:98)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
[INFO] [talledLocalContainer]   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
[INFO] [talledLocalContainer]   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
[INFO] [talledLocalContainer]   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
[INFO] [talledLocalContainer]   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
[INFO] [talledLocalContainer]   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
[INFO] [talledLocalContainer]   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
[INFO] [talledLocalContainer]   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
[INFO] [talledLocalContainer]   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
[INFO] [talledLocalContainer]   at java.lang.Thread.run(Thread.java:595)

Enhancements


Please address questions about Shale's Commons Validator integration to the [shale-user] list.

HomePage | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited September 26, 2006 9:54 am by WendySmoak (diff)
Search: