I’ve tried to use BeanValidationInterceptor and run Axon in OSGI environment. I’ve included Hibernate Validator bundle, but still keep getting the following exception:
javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
Hibernate Validator is known to have problems with OSGI and the workaround is outlined here. But I need help to integrate the WA into Axon configuration in Spring.
It works. Below is the snippet for those interested:
`
public final class ValidatorFactoryBuilder
{
public final static ValidatorFactory buildValidatorFactory()
{
GenericBootstrap bootstrap = Validation.byDefaultProvider();
bootstrap = bootstrap.providerResolver
(
new ValidationProviderResolver()
{ @SuppressWarnings({ “rawtypes”, “unchecked” }) @Override
public List getValidationProviders(){return Arrays.asList(new HibernateValidator());}
}
);