Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the asciidoc in the repository:

Bean Validator Component

Available as of Camel 2.3

The Validator component performs bean validation of the message body using the Java Bean Validation API (JSR 303). Camel uses the reference implementation, which is Hibernate Validator.

Maven users will need to add the following dependency to their pom.xml for this component:

URI format


Where label is an arbitrary text value describing the endpoint.
You can append query options to the URI in the following format, ?option=value&option=value&...

URI Options






The custom validation group to use.


Depends on JSR303 jar provided.

Camel 2.13.0: Reference to a custom javax.validation.ValidationProviderResolver in the Registry.



Reference to a custom javax.validation.MessageInterpolator in the Registry.



Reference to a custom javax.validation.TraversableResolver in the Registry.



Reference to a custom javax.validation.ConstraintValidatorFactory in the Registry.

OSGi deployment

To use Hibernate Validator in the OSGi environment use dedicated ValidationProviderResolver implementation, just as org.apache.camel.component.bean.validator.HibernateValidationProviderResolver. The snippet below demonstrates this approach. Keep in mind that you can use HibernateValidationProviderResolver starting from the Camel 2.13.0.

Using HibernateValidationProviderResolver

If no custom ValidationProviderResolver is defined and the validator component has been deployed into the OSGi environment, the HibernateValidationProviderResolver will be automatically used.


Assumed we have a java bean with the following annotations

and an interface definition for our custom validation group

with the following Camel route, only the @NotNull constraints on the attributes manufacturer and licensePlate will be validated (Camel uses the default group javax.validation.groups.Default).

If you want to check the constraints from the group OptionalChecks, you have to define the route like this

If you want to check the constraints from both groups, you have to define a new interface first

and then your route definition should looks like this

And if you have to provide your own message interpolator, traversable resolver and constraint validator factory, you have to write a route like this

It's also possible to describe your constraints as XML and not as Java annotations. In this case, you have to provide the file META-INF/validation.xml which could looks like this


and the constraints-car.xml file


See Also

© 2004-2015 The Apache Software Foundation.
Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram