Back Forum Reply New

missing source code of subpackage quot;xx.conf.loader.annotation.xxquot;

hi, can anyone tell how i can get the source code of subpackage quot;xx.conf.loader.annotation.xxquot;, please. i can't find it anywhere inside spring-modules-0.9-with-dependencies.zip.

i was still suffering from the warn below and the validation annotation doesn't seem to work. without source code, i am not able to debug.Code:
2008-04-14 20:19:15,090 WARN  [main] org.springmodules.validation.bean.conf.loader.annotation.AnnotationBeanValidationConfigurationLoader (AnnotationBeanValidationConfigurationLoader.java:203) - No handler is defined for annotation 'org.springmodules.validation.bean.conf.loader.annotation.handler.NotNull'... Annotation will be ignored...
2008-04-14 20:19:15,095 WARN  [main] org.springmodules.validation.bean.conf.loader.annotation.AnnotationBeanValidationConfigurationLoader (AnnotationBeanValidationConfigurationLoader.java:203) - No handler is defined for annotation 'org.springmodules.validation.bean.conf.loader.annotation.handler.NotNull'... Annotation will be ignored...
2008-04-14 20:19:15,200 WARN  [main] org.springmodules.validation.bean.conf.loader.annotation.AnnotationBeanValidationConfigurationLoader (AnnotationBeanValidationConfigurationLoader.java:203) - No handler is defined for annotation 'org.springmodules.validation.bean.conf.loader.annotation.handler.NotEmpty'... Annotation will be ignored...
2008-04-14 20:19:15,201 WARN  [main] org.springmodules.validation.bean.conf.loader.annotation.AnnotationBeanValidationConfigurationLoader (AnnotationBeanValidationConfigurationLoader.java:203) - No handler is defined for annotation 'org.springmodules.validation.bean.conf.loader.annotation.handler.NotNull'... Annotation will be ignored...

Thanks in advance.
Cheng Wei

has anyone got any idea? i wrote a simple unit test to test two annotations quot;@NotEmpty and @NotNullquot;, but from the log outputted, there was no Binding errors. i am using commons-lang-2.4.jar,commons-digester-1.8.jar,commons-logging-1.1.1.jar,commons-beanutils-1.7.0.jar.Code:
public class ValidationTest
{
@Test
public void testValidation()
throws Exception
{
AnnotationBeanValidationConfigurationLoader configurationLoader = new AnnotationBeanValidationConfigurationLoader();
DefaultValidationAnnotationHandlerRegistry handlerRegistry = new DefaultValidationAnnotationHandlerRegistry();
handlerRegistry.registerPropertyHandler(new NotEmptyValidationAnnotationHandler());
handlerRegistry.registerPropertyHandler(new NotNullValidationAnnotationHandler());
handlerRegistry.afterPropertiesSet();
configurationLoader.setHandlerRegistry(handlerRegistry);
configurationLoader.loadConfiguration(BeanToValidate.class);
configurationLoader.afterPropertiesSet();

BeanValidator validator = new BeanValidator();
validator.setConfigurationLoader(configurationLoader);
BeanToValidate validation = new BeanToValidate();
BindException errors = new BindException(validation,quot;orderquot;);
validator.validate(validation, errors);
System.out.println(errors.toString());
}
public static class BeanToValidate
{
private Listlt;Stringgt; collectionOfStrings = new ArrayListlt;Stringgt;();
private String notNull = null;
@NotEmpty
public Collectionlt;Stringgt; getCollectionOfStrings()
{
return collectionOfStrings;
}
public void addString(String str)
{
collectionOfStrings.add(str);
}
@NotNull
public String getNotNull()
{
return notNull;
}
public void setNotNull(String notNull)
{
this.notNull = notNull;
}
}
}

Code:
2008-04-15 14:57:00,563 DEBUG [main] org..beans.CachedIntrospectionResults (CachedIntrospectionResults.java:242) - Getting BeanInfo for class [uk.co.esca.mercury.validation.RestaurantValidationUtilsTest$BeanToValidate]
2008-04-15 14:57:00,590 DEBUG [main] org..beans.CachedIntrospectionResults (CachedIntrospectionResults.java:258) - Caching PropertyDescriptors for class [uk.co.esca.mercury.validation.RestaurantValidationUtilsTest$BeanToValidate]
2008-04-15 14:57:00,591 DEBUG [main] org..beans.CachedIntrospectionResults (CachedIntrospectionResults.java:267) - Found bean property 'class' of type [java.lang.Class]
2008-04-15 14:57:00,599 DEBUG [main] org..beans.CachedIntrospectionResults (CachedIntrospectionResults.java:267) - Found bean property 'collectionOfStrings' of type [java.util.Collection]
2008-04-15 14:57:00,600 DEBUG [main] org..beans.CachedIntrospectionResults (CachedIntrospectionResults.java:267) - Found bean property 'notNull' of type [java.lang.String]
2008-04-15 14:57:00,616 WARN  [main] org.springmodules.validation.bean.conf.loader.annotation.AnnotationBeanValidationConfigurationLoader (AnnotationBeanValidationConfigurationLoader.java:203) - No hanlder is defined for annotation 'org.springmodules.validation.bean.conf.loader.annotation.handler.NotEmpty'... Annotation will be ignored...
2008-04-15 14:57:00,625 WARN  [main] org.springmodules.validation.bean.conf.loader.annotation.AnnotationBeanValidationConfigurationLoader (AnnotationBeanValidationConfigurationLoader.java:203) - No hanlder is defined for annotation 'org.springmodules.validation.bean.conf.loader.annotation.handler.NotNull'... Annotation will be ignored...
2008-04-15 14:57:00,692 DEBUG [main] org.springmodules.validation.bean.BeanValidator (BeanValidator.java:156) - Validating object in path ''
2008-04-15 14:57:00,693 DEBUG [main] org.springmodules.validation.bean.BeanValidator (BeanValidator.java:329) - Validating global rules...
2008-04-15 14:57:00,693 DEBUG [main] org.springmodules.validation.bean.BeanValidator (BeanValidator.java:334) - Validating properties rules...
2008-04-15 14:57:00,694 DEBUG [main] org.springmodules.validation.bean.BeanValidator (BeanValidator.java:339) - Executing custom validator...
org..validation.BindException: org..validation.BeanPropertyBindingResult: 0 errors
Any idea? Thanks in advance.
Cheng Wei

From official reference:

The property validation rules can be defined either on the property setter method or on the associated class field.

Can this be your problem?

thanks, nim, *on the property getter method.
it seems spring-modules is not very active. i have switched to use Hibernate Validator instead.

After i downloaded spring-modules-validation 0.9 and use the sources to debug it, i found that the org.springmodules.validation.bean.conf.loader.anno  tation.handler.NotNull annotation is a field annotation.
Will work when you will annotate the field.

@MaxLength(value = 2, message = quot;wrong.sizequot;)
private String fullName;

I can't seem to find the surces in that package either. Did you find them?

/svn/maven2/org/springmodules/spring-modules-validation/0.9

/svn/maven2/org/springmodules/spring-modules-validation/0.9

For what it's worth, and for a lack of a better place to put this in .. with Spring Modules 0.9 there's the notion of contexts.  For the life of me I wasn't able to figure out how to put in multiple contexts for the @NotNull annotation.  Then I got hold of this code from raisercostin.googlecode.com/svn/maven2/org/springmodules/spring-modules-validation/0.9  which saved the day.

The issue I encountered was that I was configuring my contexts as
  @NotNull(contextsquot;createAccountquot;,quot;updateSecurityIn  foquot;)   private String password;

The expected input parameter is actually:
  @NotNull(contexts={quot;createAccountquot;,quot;updateSecurity  Infoquot;})   private String password;

I was able to figure this out because  in the src code for NotNull.java the signature of contexts() is
   String[] contexts() default {};

Which means that there's no parsing going on for a comma delimited list but rather the method expects a String[]. In Java an anonymous String array is created this way:

{quot;string1quot;, quot;string2quot;} and not this way {quot;string1,string2quot;}

Hope this helps some newbie that searches this forum!!

Thanks for the thread, I've been searching and all of you gave me the answers we've been looking for. Now my programmer can get busy again.
¥
Back Forum Reply New