java.lang.RuntimeException: org.springmodules.validation.valang.ParseException: Encountered ":" at line 2, column 49. Was expecting one of: "BETWEEN" ... "NOT BETWEEN" ... "IN" ... "NOT IN" ... <IS_NULL> ... <IS_NOT_NULL> ... "HAS TEXT" ... "HAS NO TEXT" ... "HAS LENGTH" ... "HAS NO LENGTH" ... "IS BLANK" ... "IS NOT BLANK" ... <IS_UPPER_CASE> ... <IS_NOT_UPPER_CASE> ... <IS_LOWER_CASE> ... <IS_NOT_LOWER_CASE> ... "IS WORD" ... "IS NOT WORD" ... <MORE_THAN_OR_EQUAL> ... ">" ... <LESS_THAN_OR_EQUAL> ... "<" ... <NOT_EQUAL> ... <EQUALS> ... "+" ... "-" ... "*" ... <DIVIDE> ... <MOD> ...

Spring JIRA | Philipp Gaschütz | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    The Valang parser does not correctly recognise/parse HashMaps. For some more information see the springmodules mailinglist archive: https://springmodules.dev.java.net/servlets/ReadMsg?list=dev&msgNo=460 and https://springmodules.dev.java.net/servlets/ReadMsg?list=dev&msgNo=462 (both dated 10th Jan 2006) Demonstration code: Person.java: ============================= import java.util.HashMap; public class Person { private HashMap form; public HashMap getForm() { return form; } public void setForm(HashMap form) { this.form = form; } } Test.java ============================== import java.util.HashMap; import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; import org.springframework.validation.BindException; import org.springframework.validation.Validator; public class Test { public static void main(String[] args) { Resource res = new FileSystemResource("C:\\beans.xml"); XmlBeanFactory factory = new XmlBeanFactory(res); HashMap x = new HashMap(); x.put("name", "Philipp"); x.put("passwd", "goodpasswd"); x.put("passwd2", " badpasswd"); Person z = new Person(); z.setForm(x); BindException e = new BindException(z, "person"); Validator val = (Validator) factory.getBean("myValidator"); val.validate(z,e); System.out.println(e); } } beans-1.xml - WORKING ======================== <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="myValidator" class="org.springmodules.validation.ValangValidatorFactoryBean"> <property name="valang"> <value><![CDATA[ { form[name] : length(?) BETWEEN 4 AND 30 : 'name must be between 4 and 30' } ]]></value> </property> </bean> </beans> beans-2.xml - throws ValangException/org.springframework.beans.InvalidPropertyException ======================== <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="myValidator" class="org.springmodules.validation.ValangValidatorFactoryBean"> <property name="valang"> <value><![CDATA[ { form[name] : length(?) BETWEEN 4 AND 30 : 'name must be between 4 and 30' } { form[passwd] : length(?) BETWEEN 5 AND 20 : 'password must be between 5 and 20' } ]]></value> </property> </bean> </beans> beans-3.xml - throws ParseException ======================== <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="myValidator" class="org.springmodules.validation.ValangValidatorFactoryBean"> <property name="valang"> <value><![CDATA[ { passwdtest : form[passwd] == form[passwd2] : 'passwords dont match' } ]]></value> </property> </bean> </beans> The exception thrown for example 2 is as follows: Exception in thread "main" org.springmodules.validation.ValangException: Invalid property 'form[name][passwd]' of bean class [Person]: Property referenced in indexed property path 'form[name][passwd]' is neither an array nor a List nor a Set nor a Map; returned value was [Philipp]; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'form[name][passwd]' of bean class [Person]: Property referenced in indexed property path form[name][passwd]' is neither an array nor a List nor a Set nor a Map; returned value was [Philipp] at line 4, column 20 org.springframework.beans.InvalidPropertyException: Invalid property 'form[name][passwd]' of bean class [Person]: Property referenced in indexed property path 'form[name][passwd]' is neither an array nor a List nor a Set nor a Map; returned value was [Philipp] at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:697) at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:643) at org.springmodules.validation.functions.BeanPropertyFunction.getResult(BeanPropertyFunction.java:62) at org.springmodules.validation.functions.LengthOfFunction.doGetResult(LengthOfFunction.java:34) at org.springmodules.validation.functions.AbstractFunction$1.execute(AbstractFunction.java:111) at org.springmodules.validation.functions.FunctionTemplate.execute(FunctionTemplate.java:51) at org.springmodules.validation.functions.AbstractFunction.getResult(AbstractFunction.java:109) at org.springmodules.validation.predicates.GenericTestPredicate.evaluate(GenericTestPredicate.java:44) at org.springmodules.validation.predicates.BasicValidationRule.validate(BasicValidationRule.java:105) at org.springmodules.validation.ValangValidatorFactoryBean$1.validate(ValangValidatorFactoryBean.java:420) at Test.main(Test.java:35) The exception thrown for example 3 is as follows: org.springmodules.validation.valang.ParseException: Encountered ":" at line 2, column 49. Was expecting one of: "BETWEEN" ... "NOT BETWEEN" ... "IN" ... "NOT IN" ... <IS_NULL> ... <IS_NOT_NULL> ... "HAS TEXT" ... "HAS NO TEXT" ... "HAS LENGTH" ... "HAS NO LENGTH" ... "IS BLANK" ... "IS NOT BLANK" ... <IS_UPPER_CASE> ... <IS_NOT_UPPER_CASE> ... <IS_LOWER_CASE> ... <IS_NOT_LOWER_CASE> ... "IS WORD" ... "IS NOT WORD" ... <MORE_THAN_OR_EQUAL> ... ">" ... <LESS_THAN_OR_EQUAL> ... "<" ... <NOT_EQUAL> ... <EQUALS> ... "+" ... "-" ... "*" ... <DIVIDE> ... <MOD> ... java.lang.RuntimeException: org.springmodules.validation.valang.ParseException: Encountered ":" at line 2, column 49. Was expecting one of: "BETWEEN" ... "NOT BETWEEN" ... "IN" ... "NOT IN" ... <IS_NULL> ... <IS_NOT_NULL> ... "HAS TEXT" ... "HAS NO TEXT" ... "HAS LENGTH" ... "HAS NO LENGTH" ... "IS BLANK" ... "IS NOT BLANK" ... <IS_UPPER_CASE> ... <IS_NOT_UPPER_CASE> ... <IS_LOWER_CASE> ... <IS_NOT_LOWER_CASE> ... "IS WORD" ... "IS NOT WORD" ... <MORE_THAN_OR_EQUAL> ... ">" ... <LESS_THAN_OR_EQUAL> ... "<" ... <NOT_EQUAL> ... <EQUALS> ... "+" ... "-" ... "*" ... <DIVIDE> ... <MOD> ... at org.springmodules.validation.ValangValidatorFactoryBean$1.<init>(ValangValidatorFactoryBean.java:350) at org.springmodules.validation.ValangValidatorFactoryBean.afterPropertiesSet(ValangValidatorFactoryBean.java:266) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1058) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147) at Test.main(Test.java:24) Caused by: org.springmodules.validation.valang.ParseException: Encountered ":" at line 2, column 49. Was expecting one of: "BETWEEN" ... "NOT BETWEEN" ... "IN" ... "NOT IN" ... <IS_NULL> ... <IS_NOT_NULL> ... "HAS TEXT" ... "HAS NO TEXT" ... "HAS LENGTH" ... "HAS NO LENGTH" ... "IS BLANK" ... "IS NOT BLANK" ... <IS_UPPER_CASE> ... <IS_NOT_UPPER_CASE> ... <IS_LOWER_CASE> ... <IS_NOT_LOWER_CASE> ... "IS WORD" ... "IS NOT WORD" ... <MORE_THAN_OR_EQUAL> ... ">" ... <LESS_THAN_OR_EQUAL> ... "<" ... <NOT_EQUAL> ... <EQUALS> ... "+" ... "-" ... "*" ... <DIVIDE> ... <MOD> ... at org.springmodules.validation.valang.ValangParser.generateParseException(ValangParser.java:1564) at org.springmodules.validation.valang.ValangParser.jj_consume_token(ValangParser.java:1444) at org.springmodules.validation.valang.ValangParser.predicate(ValangParser.java:387) at org.springmodules.validation.valang.ValangParser.expression(ValangParser.java:225) at org.springmodules.validation.valang.ValangParser.predicates(ValangParser.java:165) at org.springmodules.validation.valang.ValangParser.parseValidation(ValangParser.java:100) at org.springmodules.validation.ValangValidatorFactoryBean$1.<init>(ValangValidatorFactoryBean.java:346) ... 6 more

    Spring JIRA | 1 decade ago | Philipp Gaschütz
    java.lang.RuntimeException: org.springmodules.validation.valang.ParseException: Encountered ":" at line 2, column 49. Was expecting one of: "BETWEEN" ... "NOT BETWEEN" ... "IN" ... "NOT IN" ... <IS_NULL> ... <IS_NOT_NULL> ... "HAS TEXT" ... "HAS NO TEXT" ... "HAS LENGTH" ... "HAS NO LENGTH" ... "IS BLANK" ... "IS NOT BLANK" ... <IS_UPPER_CASE> ... <IS_NOT_UPPER_CASE> ... <IS_LOWER_CASE> ... <IS_NOT_LOWER_CASE> ... "IS WORD" ... "IS NOT WORD" ... <MORE_THAN_OR_EQUAL> ... ">" ... <LESS_THAN_OR_EQUAL> ... "<" ... <NOT_EQUAL> ... <EQUALS> ... "+" ... "-" ... "*" ... <DIVIDE> ... <MOD> ...
  2. 0

    The Valang parser does not correctly recognise/parse HashMaps. For some more information see the springmodules mailinglist archive: https://springmodules.dev.java.net/servlets/ReadMsg?list=dev&msgNo=460 and https://springmodules.dev.java.net/servlets/ReadMsg?list=dev&msgNo=462 (both dated 10th Jan 2006) Demonstration code: Person.java: ============================= import java.util.HashMap; public class Person { private HashMap form; public HashMap getForm() { return form; } public void setForm(HashMap form) { this.form = form; } } Test.java ============================== import java.util.HashMap; import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; import org.springframework.validation.BindException; import org.springframework.validation.Validator; public class Test { public static void main(String[] args) { Resource res = new FileSystemResource("C:\\beans.xml"); XmlBeanFactory factory = new XmlBeanFactory(res); HashMap x = new HashMap(); x.put("name", "Philipp"); x.put("passwd", "goodpasswd"); x.put("passwd2", " badpasswd"); Person z = new Person(); z.setForm(x); BindException e = new BindException(z, "person"); Validator val = (Validator) factory.getBean("myValidator"); val.validate(z,e); System.out.println(e); } } beans-1.xml - WORKING ======================== <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="myValidator" class="org.springmodules.validation.ValangValidatorFactoryBean"> <property name="valang"> <value><![CDATA[ { form[name] : length(?) BETWEEN 4 AND 30 : 'name must be between 4 and 30' } ]]></value> </property> </bean> </beans> beans-2.xml - throws ValangException/org.springframework.beans.InvalidPropertyException ======================== <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="myValidator" class="org.springmodules.validation.ValangValidatorFactoryBean"> <property name="valang"> <value><![CDATA[ { form[name] : length(?) BETWEEN 4 AND 30 : 'name must be between 4 and 30' } { form[passwd] : length(?) BETWEEN 5 AND 20 : 'password must be between 5 and 20' } ]]></value> </property> </bean> </beans> beans-3.xml - throws ParseException ======================== <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="myValidator" class="org.springmodules.validation.ValangValidatorFactoryBean"> <property name="valang"> <value><![CDATA[ { passwdtest : form[passwd] == form[passwd2] : 'passwords dont match' } ]]></value> </property> </bean> </beans> The exception thrown for example 2 is as follows: Exception in thread "main" org.springmodules.validation.ValangException: Invalid property 'form[name][passwd]' of bean class [Person]: Property referenced in indexed property path 'form[name][passwd]' is neither an array nor a List nor a Set nor a Map; returned value was [Philipp]; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'form[name][passwd]' of bean class [Person]: Property referenced in indexed property path form[name][passwd]' is neither an array nor a List nor a Set nor a Map; returned value was [Philipp] at line 4, column 20 org.springframework.beans.InvalidPropertyException: Invalid property 'form[name][passwd]' of bean class [Person]: Property referenced in indexed property path 'form[name][passwd]' is neither an array nor a List nor a Set nor a Map; returned value was [Philipp] at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:697) at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:643) at org.springmodules.validation.functions.BeanPropertyFunction.getResult(BeanPropertyFunction.java:62) at org.springmodules.validation.functions.LengthOfFunction.doGetResult(LengthOfFunction.java:34) at org.springmodules.validation.functions.AbstractFunction$1.execute(AbstractFunction.java:111) at org.springmodules.validation.functions.FunctionTemplate.execute(FunctionTemplate.java:51) at org.springmodules.validation.functions.AbstractFunction.getResult(AbstractFunction.java:109) at org.springmodules.validation.predicates.GenericTestPredicate.evaluate(GenericTestPredicate.java:44) at org.springmodules.validation.predicates.BasicValidationRule.validate(BasicValidationRule.java:105) at org.springmodules.validation.ValangValidatorFactoryBean$1.validate(ValangValidatorFactoryBean.java:420) at Test.main(Test.java:35) The exception thrown for example 3 is as follows: org.springmodules.validation.valang.ParseException: Encountered ":" at line 2, column 49. Was expecting one of: "BETWEEN" ... "NOT BETWEEN" ... "IN" ... "NOT IN" ... <IS_NULL> ... <IS_NOT_NULL> ... "HAS TEXT" ... "HAS NO TEXT" ... "HAS LENGTH" ... "HAS NO LENGTH" ... "IS BLANK" ... "IS NOT BLANK" ... <IS_UPPER_CASE> ... <IS_NOT_UPPER_CASE> ... <IS_LOWER_CASE> ... <IS_NOT_LOWER_CASE> ... "IS WORD" ... "IS NOT WORD" ... <MORE_THAN_OR_EQUAL> ... ">" ... <LESS_THAN_OR_EQUAL> ... "<" ... <NOT_EQUAL> ... <EQUALS> ... "+" ... "-" ... "*" ... <DIVIDE> ... <MOD> ... java.lang.RuntimeException: org.springmodules.validation.valang.ParseException: Encountered ":" at line 2, column 49. Was expecting one of: "BETWEEN" ... "NOT BETWEEN" ... "IN" ... "NOT IN" ... <IS_NULL> ... <IS_NOT_NULL> ... "HAS TEXT" ... "HAS NO TEXT" ... "HAS LENGTH" ... "HAS NO LENGTH" ... "IS BLANK" ... "IS NOT BLANK" ... <IS_UPPER_CASE> ... <IS_NOT_UPPER_CASE> ... <IS_LOWER_CASE> ... <IS_NOT_LOWER_CASE> ... "IS WORD" ... "IS NOT WORD" ... <MORE_THAN_OR_EQUAL> ... ">" ... <LESS_THAN_OR_EQUAL> ... "<" ... <NOT_EQUAL> ... <EQUALS> ... "+" ... "-" ... "*" ... <DIVIDE> ... <MOD> ... at org.springmodules.validation.ValangValidatorFactoryBean$1.<init>(ValangValidatorFactoryBean.java:350) at org.springmodules.validation.ValangValidatorFactoryBean.afterPropertiesSet(ValangValidatorFactoryBean.java:266) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1058) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147) at Test.main(Test.java:24) Caused by: org.springmodules.validation.valang.ParseException: Encountered ":" at line 2, column 49. Was expecting one of: "BETWEEN" ... "NOT BETWEEN" ... "IN" ... "NOT IN" ... <IS_NULL> ... <IS_NOT_NULL> ... "HAS TEXT" ... "HAS NO TEXT" ... "HAS LENGTH" ... "HAS NO LENGTH" ... "IS BLANK" ... "IS NOT BLANK" ... <IS_UPPER_CASE> ... <IS_NOT_UPPER_CASE> ... <IS_LOWER_CASE> ... <IS_NOT_LOWER_CASE> ... "IS WORD" ... "IS NOT WORD" ... <MORE_THAN_OR_EQUAL> ... ">" ... <LESS_THAN_OR_EQUAL> ... "<" ... <NOT_EQUAL> ... <EQUALS> ... "+" ... "-" ... "*" ... <DIVIDE> ... <MOD> ... at org.springmodules.validation.valang.ValangParser.generateParseException(ValangParser.java:1564) at org.springmodules.validation.valang.ValangParser.jj_consume_token(ValangParser.java:1444) at org.springmodules.validation.valang.ValangParser.predicate(ValangParser.java:387) at org.springmodules.validation.valang.ValangParser.expression(ValangParser.java:225) at org.springmodules.validation.valang.ValangParser.predicates(ValangParser.java:165) at org.springmodules.validation.valang.ValangParser.parseValidation(ValangParser.java:100) at org.springmodules.validation.ValangValidatorFactoryBean$1.<init>(ValangValidatorFactoryBean.java:346) ... 6 more

    Spring JIRA | 1 decade ago | Philipp Gaschütz
    java.lang.RuntimeException: org.springmodules.validation.valang.ParseException: Encountered ":" at line 2, column 49. Was expecting one of: "BETWEEN" ... "NOT BETWEEN" ... "IN" ... "NOT IN" ... <IS_NULL> ... <IS_NOT_NULL> ... "HAS TEXT" ... "HAS NO TEXT" ... "HAS LENGTH" ... "HAS NO LENGTH" ... "IS BLANK" ... "IS NOT BLANK" ... <IS_UPPER_CASE> ... <IS_NOT_UPPER_CASE> ... <IS_LOWER_CASE> ... <IS_NOT_LOWER_CASE> ... "IS WORD" ... "IS NOT WORD" ... <MORE_THAN_OR_EQUAL> ... ">" ... <LESS_THAN_OR_EQUAL> ... "<" ... <NOT_EQUAL> ... <EQUALS> ... "+" ... "-" ... "*" ... <DIVIDE> ... <MOD> ...

    Root Cause Analysis

    1. org.springmodules.validation.valang.ParseException

      Encountered ":" at line 2, column 49. Was expecting one of: "BETWEEN" ... "NOT BETWEEN" ... "IN" ... "NOT IN" ... <IS_NULL> ... <IS_NOT_NULL> ... "HAS TEXT" ... "HAS NO TEXT" ... "HAS LENGTH" ... "HAS NO LENGTH" ... "IS BLANK" ... "IS NOT BLANK" ... <IS_UPPER_CASE> ... <IS_NOT_UPPER_CASE> ... <IS_LOWER_CASE> ... <IS_NOT_LOWER_CASE> ... "IS WORD" ... "IS NOT WORD" ... <MORE_THAN_OR_EQUAL> ... ">" ... <LESS_THAN_OR_EQUAL> ... "<" ... <NOT_EQUAL> ... <EQUALS> ... "+" ... "-" ... "*" ... <DIVIDE> ... <MOD> ...

      at org.springmodules.validation.valang.ValangParser.generateParseException()
    2. org.springmodules.validation
      ValangValidatorFactoryBean.afterPropertiesSet
      1. org.springmodules.validation.valang.ValangParser.generateParseException(ValangParser.java:1564)
      2. org.springmodules.validation.valang.ValangParser.jj_consume_token(ValangParser.java:1444)
      3. org.springmodules.validation.valang.ValangParser.predicate(ValangParser.java:387)
      4. org.springmodules.validation.valang.ValangParser.expression(ValangParser.java:225)
      5. org.springmodules.validation.valang.ValangParser.predicates(ValangParser.java:165)
      6. org.springmodules.validation.valang.ValangParser.parseValidation(ValangParser.java:100)
      7. org.springmodules.validation.ValangValidatorFactoryBean$1.<init>(ValangValidatorFactoryBean.java:346)
      8. org.springmodules.validation.ValangValidatorFactoryBean.afterPropertiesSet(ValangValidatorFactoryBean.java:266)
      8 frames
    3. Spring Beans
      AbstractBeanFactory.getBean
      1. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1058)
      2. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363)
      3. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
      4. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
      4 frames
    4. Unknown
      Test.main
      1. Test.main(Test.java:24)
      1 frame