servicemix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johan Edstrom <seij...@gmail.com>
Subject Re: org.apache.servicemix.bundles.hibernate-validator: Unable to find a default provider
Date Fri, 08 Oct 2010 22:54:30 GMT
If you look under seijoed on github, I have a test there I started working on where I attach
the validation. XML as a fragment to hit the right classloaders.

I think that test is only missing student in a separate bundle both validation and camel can
see.


On Oct 8, 2010, at 15:41, Bengt Rodehav <bengt@rodehav.com> wrote:

> I'm using the servicemix packaging of hibernate-validator and jsr303:
> 
> *    <dependency>*
> *      <groupId>org.apache.servicemix.specs</groupId>*
> *      <artifactId>org.apache.servicemix.specs.jsr303-api-1.0.0</artifactId>
> *
> *      <version>1.5.0</version>*
> *    </dependency>*
> *
> *
> *    <dependency>*
> *      <groupId>org.apache.servicemix.bundles</groupId>*
> *
> <artifactId>org.apache.servicemix.bundles.hibernate-validator</artifactId>*
> *      <version>4.1.0.Final_1</version>*
> *    </dependency>*
> 
> I use the validator "manually" (not automatically via JPA) as follows:
> *
> *
> 
>> *public static Set<ConstraintViolation<?>> violations(Object theObject,
>> Class<?>... theGroups)*
> 
> *      throws ConstraintViolationException {*
> 
> *    /**
> 
> *     * Perform bean validation*
> 
> *     */*
> 
> *    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
>> // Throws exception*
> 
> *    Validator validator = factory.getValidator();*
> 
> *    return (Set) validator.validate(theObject, theGroups);*
> 
> *  }*
> 
> 
> The line that creates the ValidatorFactory throws an exception when called
> from wihin OSGi:
> 
> 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 validator.test1.impl.ServiceOne.createEntityOne(ServiceOne.java:17)
> 
> at validator.test.itest.OsgiTest.createTest(OsgiTest.java:29)
> 
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 
> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 
> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 
> at java.lang.reflect.Method.invoke(Method.java:597)
> 
> at
>> org.ops4j.pax.exam.junit.extender.impl.internal.CallableTestMethodImpl.injectContextAndInvoke(CallableTestMethodImpl.java:143)
> 
> at
>> org.ops4j.pax.exam.junit.extender.impl.internal.CallableTestMethodImpl.call(CallableTestMethodImpl.java:105)
> 
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 
> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 
> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 
> at java.lang.reflect.Method.invoke(Method.java:597)
> 
> at
>> org.ops4j.pax.exam.rbc.internal.RemoteBundleContextImpl.remoteCall(RemoteBundleContextImpl.java:80)
> 
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 
> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 
> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 
> at java.lang.reflect.Method.invoke(Method.java:597)
> 
> at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
> 
> at sun.rmi.transport.Transport$1.run(Transport.java:159)
> 
> at java.security.AccessController.doPrivileged(Native Method)
> 
> at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
> 
> at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
> 
> at
>> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
> 
> at
>> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
> 
> at
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
> 
> at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
> 
> at java.lang.Thread.run(Thread.java:619)
> 
> 
> When I run the same code outside of OSGi everything works. What am I doing
> wrong?
> 
> The test above used Pax-Exam with Felix 3.0.2 but it doesn't seem to matter
> what OSGi container I use. I've tried different versions of Felix and
> Equinox but I get the same exception. I suspect I'm doing something wrong
> but I cannot see what. Can someone help me out?
> 
> /Bengt

Mime
View raw message