I had to set the context class loader.
On Fri, Oct 23, 2015 at 10:19 PM, Benson Margulies <ben...@basistech.com> wrote: > 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);