cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gunnar Morling (JIRA)" <>
Subject [jira] [Commented] (CXF-6706) Bean validation seems to not be working in OSGi
Date Wed, 16 Dec 2015 09:05:46 GMT


Gunnar Morling commented on CXF-6706:

Hi, a Hibernate Validator developer here :-)

Sorry to hear you run into issues with using HV in OSGi. We've put a bit of an effort into
making it work, which it actually does in general by now. But I am happy to help ironing out
any remaining glitches.

Some remarks:


Atm. a custom validation provider resolver is needed with OSGi, also if the {{HibernateValidator}}
provider is explicitly used. This is due to a glitch in the BV API JAR, which we've planned
to fix in the next version (see [BVAL-486|]).
Note that the official spec JAR already contains the required manifest entries. So for now
it'd have to be the following:

public static class MyValidationProviderResolver implements ValidationProviderResolver {

    public List<ValidationProvider<?>> getValidationProviders() {
        return Collections.<ValidationProvider<?>>singletonList( new HibernateValidator()

// And using the resolver:
ValidatorFacotry vf = Validation.byProvider( HibernateValidator.class )
    .providerResolver( new MyValidationProviderResolver() )

*User-provided resources*

Whenever we need to load stuff by name or provided by the user in general (classes given in
XML config, message bundles etc.) we do so using a classloader that may explicitly be set
during bootstrap. See {{HibernateValidatorConfiguration#externalClassLoader()}} for the details.

*Karaf Features file*

We provide one already (see [here|])
and I'd love it that'd be "the one". We can fix the issues due to the wrap stuff, [~bmargulies]
offered his help already. Thanks!

*Class-loading issues around EL*

This one is puzzling me, it should suffice if the HV bundle can see EL packages (in the right
version) exported by another bundle. As discussed in [HV-1039|]
we'd need to have some more details on this one (full log/stacktrace).

Please let me know if there is anything else I/we can do to make that integration work smoothly.

> Bean validation seems to not be working in OSGi
> -----------------------------------------------
>                 Key: CXF-6706
>                 URL:
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 3.1.4, 3.2.0
>            Reporter: Benson Margulies
>            Assignee: Benson Margulies
>             Fix For: 3.1.5, 3.2.0
> Using Karaf 4.0.2, 
> if you take this repo:
> and checkout the use-cxf-support branch, it will build you a Karaf assembly that, when
you poke the service (http://localhost:8181/cxf/validate)
> will yield the following backtrace. This assumes that you are up to date with my fix
to cxf-6705 which is on master and the 3.1.x branch.
> {noformat}
> javax.validation.ValidationException: Unable to find a default provider
> 	at javax.validation.Validation$GenericBootstrapImpl.configure(
> 	at javax.validation.Validation.buildDefaultValidatorFactory(
> 	at org.apache.cxf.validation.BeanValidationProvider.<init>(
> 	at com.basistech.ts.impl.TrivialService.validate(
> {noformat}

This message was sent by Atlassian JIRA

View raw message