I'm trying to do JSR 303 bean validation with a Spring MVC Controller in WAS 8.5.5.12 Full Profile.
I'm validating just a single @RequestParam, not a full bean:
@RequestMapping(method=RequestMethod.GET)
public String initializeCheckIn(
@Valid @Pattern(regexp = "^[\\p{Alnum}]*$")
@RequestParam("officeid") String officeId, HttpSession session, Model model) {
Before I added some Spring-specific configuration, no validation was occurring, but neither were any errors. Presumably, the validation wasn't being attempted at all.
Now that I've added the necessary @Validated class annotation and bean definition:
<bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor"/>
I get the following error:
[8/9/17 10:33:40:588 CDT] 000000a7 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0014E: Uncaught service() exception root cause Spring MVC Dispatcher: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: org.hibernate.validator.method.MethodConstraintViolationException
...
Caused by: java.lang.NoClassDefFoundError: org.hibernate.validator.method.MethodConstraintViolationException
at org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:152)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
at my.package.web.CheckInController$$EnhancerBySpringCGLIB$$d385737c.initializeCheckIn(<generated>)
Based on
Spring should auto-detect an available JSR-303 provider, which this version of WebSphere (8.5.5.12 full profile) should have. It appears it's failing to find that JSR-303 provider, so it's falling back to a default.
So any ideas why the WebSphere version is not found or how to make it found?
@Validated
produces the Hibernate NoClassDef; not adding it bypasses the JSR validation annotations... – Botfly