On 24. juni 2010, at 10.42, Kaj Hejer wrote:
> 
> I'm working on an application where HibernateValidator does not work as 
> excpected when running on Resin 4.0.7 but just fine when running on jetty 
> 6.1.22 with "mvn jetty:run".


Hi!

Some more info on this issue. 

When submiting a form where a required (annotated @NotEmpty) field is empty the 
last line in following gives me a Set with the validation errors 
(ConstraintViolations) when running under jetty (as expected) BUT when running 
under Resin 4.0.7 I get a empty set. Strange?

   @RequestMapping(value = "/edit.html", method = RequestMethod.POST)
    public ModelAndView submit(@ModelAttribute("commandObject") @Valid final T 
commandObject,
            final BindingResult result, final HttpServletRequest request, final 
ModelMap modelMap,
            @RequestParam(value = "cancel", required = false) final String 
cancel) {

        logger.debug("result before: " + result);
        LocalValidatorFactoryBean localValidatorFactoryBean = 
(LocalValidatorFactoryBean) applicationContext
                
.getBean("org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0");
        Validator validator = localValidatorFactoryBean.getValidator();
        logger.debug("validator class: " + validator.getClass().getName()); // 
gives org.hibernate.validator.engine.ValidatorImpl
        logger.debug("validate: " + validator.validate(commandObject)); 


A maybe even stranger thing is that the when the BeanValidationEventListener 
kicks in before save is does find a validation error:

javax.validation.ConstraintViolationException: validation failed for classes 
[no.uio.webapps.medark.domain.Diagnosis] during update time for groups 
[javax.validation.groups.Default, ]
        at 
org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(BeanValidationEventListener.java:132)
        at 
org.hibernate.cfg.beanvalidation.BeanValidationEventListener.onPreUpdate(BeanValidationEventListener.java:79)
        at 
org.hibernate.action.EntityUpdateAction.preUpdate(EntityUpdateAction.java:236)
        at 
org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:87)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:180)
        at 
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
        at 
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
        at 
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
        at 
org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656)
        at 
org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
        at 
org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
        at 
org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:375)
        at 
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
        at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at 
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
        at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy82.store(Unknown Source)


Why does the last validation find errors but not the one Spring calles for me 
(because of the @Valid annotation) or the one I call manually?


-Kaj :)




_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest

Reply via email to