commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sébastien GALLET <sebast...@gallet.info>
Subject Re: [commons-validator] Validator outside of Struts
Date Thu, 17 Feb 2005 00:31:04 GMT
Humm, I dont know. ........ Because I've make a copy/paste from 
validator examples.
Now I use the GenericValidator
      <validator name="required"
                 classname="org.apache.commons.validator.GenericValidator"
                 method="isBlankOrNull"
                 
methodParams="java.lang.Object,org.apache.commons.validator.Field"
                 msg="errors.required"/>
And I 've got another error
2005-02-17 01:07:12,132 INFO  [STDOUT] Exception when validating bean 
info.gallet.titandb.person.Person
2005-02-17 01:07:12,132 INFO  [STDOUT] 
org.apache.commons.validator.GenericValidator.isBlankOrNull(java.lang.Object, 
org.apach
e.commons.validator.Field)
2005-02-17 01:07:12,132 INFO  [STDOUT] 
org.apache.commons.validator.ValidatorException: 
org.apache.commons.validator.GenericVa
lidator.isBlankOrNull(java.lang.Object, org.apache.commons.validator.Field)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
org.apache.commons.validator.ValidatorAction.loadValidationMethod(ValidatorAction.j
ava:627)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
org.apache.commons.validator.ValidatorAction.executeValidationMethod(ValidatorActio
n.java:557)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
org.apache.commons.validator.Field.validateForRule(Field.java:811)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
org.apache.commons.validator.Field.validate(Field.java:890)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
org.apache.commons.validator.Form.validate(Form.java:174)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
org.apache.commons.validator.Validator.validate(Validator.java:367)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
info.gallet.marmot.ValidatorTest.validate(ValidatorTest.java:124)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
info.gallet.titandbtest.Test2.processRequest(Test2.java:141)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
info.gallet.titandbtest.Test2.doGet(Test2.java:195)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterC
hain.java:237)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.jav
a:157)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
2005-02-17 01:07:12,133 INFO  [STDOUT]  at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterC
hain.java:186)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.jav
a:157)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
104)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.j
ava:198)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
:
104)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java
:66)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
102)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationVa
lve.java:153)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
102)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:54)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
102)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
2005-02-17 01:07:12,134 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
104)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
102)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:417)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
102)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:535)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
102)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
104)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(H
ttp11Protocol.java:705)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
2005-02-17 01:07:12,135 INFO  [STDOUT]  at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
2005-02-17 01:07:12,136 INFO  [STDOUT]  at 
java.lang.Thread.run(Thread.java:534)


David Graham a écrit :

>Why are you using org.apache.commons.validator.TestValidator?  What is the
>full stack trace for the exception?
>
>David
>
>
>--- Sébastien GALLET <sebastien@gallet.info> wrote:
>
>  
>
>>Hello,
>>I try to use commons validator oustide of struts.
>>I've create a class ValidatorTest with the 2 main following methods :
>>
>>    /** The default construtor
>>    *
>>    */
>>    public ValidatorTest() {
>>
>>        InputStream in = null;
>>        System.out.println("Try to init validator");
>>       
>>        try {
>>            in =
>>this.getClass().getResourceAsStream("validatortest.xml");
>>            resources = new ValidatorResources(in);
>>        } catch (Exception e) {
>>            System.out.println("Exception when initialising validator");
>>            System.out.println(e.getMessage());
>>            e.printStackTrace(System.out);
>>        } finally {
>>            // Make sure we close the input stream.
>>            if (in != null) {
>>                try { in.close();} catch (Exception f) {};
>>            }
>>        }
>>    }
>>   
>>    /** Validate the POJO.
>>    *
>>    */
>>    public boolean validate(Object obj) {
>>        boolean result = true;
>>        System.out.println("Try to validate bean 
>>"+obj.getClass().getName());
>>        try {
>>            Validator _validator = new Validator(resources, 
>>obj.getClass().getName());
>>            _validator.setParameter(Validator.BEAN_PARAM, obj);
>>//            _validator.setOnlyReturnErrors(true);
>>           
>>            results = null;         
>>            results = _validator.validate();
>>        } catch (Exception e) {
>>            result=false;
>>            System.out.println("Exception when validating bean 
>>"+obj.getClass().getName());
>>            System.out.println(e.getMessage());
>>            e.printStackTrace(System.out);
>>        }
>>        return result;
>>    }
>>
>>And a test code which follows :
>>
>>           ValidatorTest   hvalidate = new ValidatorTest();
>>            out.print("<p>Try to validate person (titandb-test 
>>name11,titandb-test name12) : ...");
>>            out.print("<p>Validation must be ok");
>>            try {
>>                Person person = new Person();
>>                person.setName1("titandb-test name11");
>>                person.setName2("titandb-test name12");
>>                boolean res=hvalidate.validate(person);
>>                out.println("......"+res+"</p>");
>>            }
>>            catch (Exception e) {
>>                out.println("</p><h3>Failed.</h3>");
>>                out.println("<p>Exception during tests :</p>");
>>                out.println(e.getMessage());
>>            }         
>>
>>The validator configuration is ok as I can create validator instance.
>>But when I try to validate the data, I've got the following exception
>>2005-02-16 17:36:37,766 INFO  [STDOUT] Exception when validating bean 
>>info.gallet.titandb.person.Person
>>2005-02-16 17:36:37,766 INFO  [STDOUT] No ClassLoaders found for: 
>>org.apache.commons.validator.TestValidator
>>
>>What's wrong in my code ???
>>TIA
>>
>>Sebastien
>>which tries to speak English
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message