You may use javax.validation.ValidationProvider class directly to lookup spec 
implementation, if you have geronimo-osgi-locator bundle installed. Geronimo 
locator is installed by default in karaf. I was using bval a lot in our tests. 
You can check this repo - it does work with karaf 3.0.4, but 2.x is pretty much 
the same:

https://github.com/Code-House/karaf-validation 
<https://github.com/Code-House/karaf-validation>

Kind regards,
Lukasz
—
[email protected]
Twitter: ldywicki
Blog: http://dywicki.pl
Code-House - http://code-house.org


> Wiadomość napisana przez Benson Margulies <[email protected]> w dniu 23 
> paź 2015, o godz. 22:19:
> 
> I have a pax-exam test of code that uses Apache bval and thus
> javax.validation, and I use the servicemix spec provider.
> 
> The test fails with java.lang.ClassCastException:
> org.apache.bval.jsr.ApacheValidationProvider cannot be cast to
> javax.validation.spi.ValidationProvider.
> 
> When I stop it in the debugger, I see that there are indeed two Class
> objects afloat for ValidationProvider.
> 
> One of them is a sun.misc.Launcher$AppClassLoader. The other is an
> OSGi class loader.
> 
> The sun.misc one is the one for the interface of the class returned by ...
> 
> Class<? extends ValidationProvider> providerClass =
> org.apache.servicemix.specs.locator.OsgiLocator.locate(ValidationProvider.class);

Reply via email to