cxf-issues mailing list archives

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

    [ https://issues.apache.org/jira/browse/CXF-6706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15059727#comment-15059727
] 

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:

*Bootstrap*

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|https://hibernate.atlassian.net/browse/BVAL-486]).
Note that the official spec JAR already contains the required manifest entries. So for now
it'd have to be the following:

{code}
public static class MyValidationProviderResolver implements ValidationProviderResolver {

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

// And using the resolver:
ValidatorFacotry vf = Validation.byProvider( HibernateValidator.class )
    .providerResolver( new MyValidationProviderResolver() )
    .configure()
    .buildValidatorFactory();
				
{code}

*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|https://github.com/hibernate/hibernate-validator/blob/master/osgi/karaf-features/src/main/features/features.xml])
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|https://hibernate.atlassian.net/browse/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: https://issues.apache.org/jira/browse/CXF-6706
>             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:
> git@github.com:benson-basis/cxf-karaf-validation-tc.git
> 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(Validation.java:264)
> 	at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)
> 	at org.apache.cxf.validation.BeanValidationProvider.<init>(BeanValidationProvider.java:45)
> 	at com.basistech.ts.impl.TrivialService.validate(TrivialService.java:50)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message