Axon Framework + BeanValidationInterceptor in OSGI Environment

Hi All,

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.

Any advice would be greatly appreciated.

Thanks & Regards,
Setya

Just found out that I can pass ValidationFactory to BeanValidationInterceptor’s constructor. Will try this.

Regards,
Setya

Enter code here...

Hi All,

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());}
}
);

return bootstrap.configure().buildValidatorFactory();
}
}

`

And below is my Spring configuration:

`

<axon:command-bus id=“commandBus”>
axon:dispatchInterceptors





</axon:dispatchInterceptors>
</axon:command-bus>

`

Thanks & Regards,
Setya