I'm now using ServiceMix packaging of hibernate validator and the
javax.validation api. It works when I only have one bundle using the
validation api but when I have two bundles I get the following exception:

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
> se.digia.sts.util.validation.ValidatorUtil.violations(ValidatorUtil.java:18)

at
> se.digia.sts.safekeep.accounttransaction.impl.AccountTransactionService.createAccountTransaction(AccountTransactionService.java:38)

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.apache.aries.blueprint.proxy.Collaborator$1.invoke(Collaborator.java:66)

at
> org.apache.aries.blueprint.proxy.Collaborator.invoke(Collaborator.java:151)

at
> org.apache.aries.blueprint.proxy.CgLibInterceptorWrapper$1.intercept(CgLibInterceptorWrapper.java:125)

at
> se.digia.sts.safekeep.accounttransaction.impl.AccountTransactionService$$EnhancerByCGLIB$$a709c18.createAccountTransaction(<generated>)

at
> se.digia.sts.safekeep.itest.accounttransaction.AccountTransactionServiceTest.createAccountTransactionTest(AccountTransactionServiceTest.java:55)

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:886)

at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

at java.lang.Thread.run(Thread.java:619)


I'm not sure if I'm using the api the correct way. The call (in my code)
that causes this exception is:

    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();


Should I find/create my factory some other way when I use the ServiceMix
packaging? Should I use the OsgiLocator.locate() method?

/Bengt



2010/9/16 Bengt Rodehav <be...@rodehav.com>

> Willem,
>
> Sorry if I appear a bit ignorant but, as I wrote before, I haven't done any
> OSGi wrapping before - I've always found what I needed. Often from
> ServiceMix, sometimes from Geronimo (specs) and from SpringSource. I'm
> trying to get the hang of this...
>
> I don't think I need to try the validator API from ServiceMix - I'm sure it
> works. I just hadn't realised that in order to use the ServiceMix wrapper
> for hibernate validator one must also use the ServiceMix wrapper for the
> validation API.
>
> Furthermore, it seems there is definitely something for me to learn
> regarding exporting of META-INF. I haven't thought about this as a problem
> but realize that I should.
>
> What exactly will happen if many bundles export META-INF/services? I
> realise that it's a non-OSGi way of doing things. In OSGi, an OSGi service
> should be published that others can depend on. I guess that's what the
> ServiceMix wrapper for the validation API does. I bet there is a pattern
> here since the META-INF/services pattern is widely used.
>
> Thanks,
>
> /Bengt
>
> P.S.
> Has ServiceMix published a a newer (4.1.Final) version of hibernate
> validator? Makes sens to use that instead of my own wrapper when the
> wrapping seems to be non-trivial.
> D.S.
>
>
> 2010/9/16 Willem Jiang <willem.ji...@gmail.com>
>
>> On 9/16/10 3:16 PM, Bengt Rodehav wrote:
>>
>>> Willem,
>>>
>>> Not sure what you mean. I solved the problem by exporting the META-INF
>>> and
>>> the META-INF.services "packages". That's all it took.
>>>
>> If you just have one bundle exports META-INF.services, that could be OK.
>> But if you have tens of bundles export that package, you will in a
>> nightmare.
>>
>>
>>
>>> However, your version does not seem to work since no default provider can
>>> be
>>> found
>>>
>>> ...Aha now I see what you wrote in your mail... You mean you need to hack
>>> the VALIDATOR API to get it to work. I just wrapped the validator API
>>> (without hacks) and it works IF you export the META-INF.services package.
>>> Isn't that preferrable to hacking the validator API?
>>>
>> Can you try out the validator API from ServiceMix here[1]?
>>
>> [1]mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jsr303-api-1.0.0/1.5.0
>>
>>
>> Willem
>>
>>
>>> /Bengt
>>>
>>> 2010/9/16 Willem Jiang<willem.ji...@gmail.com>
>>>
>>>  Oh, you need to make sure the bean validator API can find the
>>>> implementor
>>>> jars in OSGi container.
>>>> ServiceMix did some work by introducing the service locator to search
>>>> the
>>>> service from META-INF/services, and you may also need to hack the
>>>> validator
>>>> API by using the locator to find the service from META-INF/services.
>>>>
>>>> If you like you can take a look at the code here[1]
>>>>
>>>> [1]
>>>> https://svn.apache.org/repos/asf/servicemix/smx4/specs/trunk/locator
>>>>
>>>> Willem
>>>>
>>>>
>>>> On 9/16/10 2:39 PM, Bengt Rodehav wrote:
>>>>
>>>>  Willem,
>>>>>
>>>>> I ended up using my own wrapped version mostly for learning reasons.
>>>>> However, I had some problems with my wrapped version. I deployed it in
>>>>> the
>>>>> container but in runtime I got error messages saying that no default
>>>>> provider could be found. I then noticed that I hadn't exported the
>>>>> META-INF/services "package" from the bundle. When I did that, the error
>>>>> message disappeared and the validator worked.
>>>>>
>>>>> I then tested your (ServiceMix) wrapped version of the 4.0.2 version of
>>>>> Hibernate Validator. It seems to have the same problem. Maybe someone
>>>>> should
>>>>> look into this?
>>>>>
>>>>> /Bengt
>>>>>
>>>>> 2010/9/13 Bengt Rodehav<be...@rodehav.com>
>>>>>
>>>>>  Thanks, I'll have a look,
>>>>>
>>>>>>
>>>>>> /Bengt
>>>>>>
>>>>>> 2010/9/13 Willem Jiang<willem.ji...@gmail.com>
>>>>>>
>>>>>> On 9/13/10 3:58 AM, Bengt Rodehav wrote:
>>>>>>
>>>>>>
>>>>>>>  Thanks Cristian,
>>>>>>>
>>>>>>>>
>>>>>>>> I kind of suspected that Servicemix had bundled this. Actually I
>>>>>>>> ended
>>>>>>>> up
>>>>>>>> doing my own bundling anyway since I wanted to use the 4.1.0.Final
>>>>>>>> version.
>>>>>>>> Also wanted to see how easy/hard it was to accomplish.
>>>>>>>>
>>>>>>>> /Bengt
>>>>>>>>
>>>>>>>>
>>>>>>>>  I just created a patch[1] for the hibernate-validator bundle, you
>>>>>>> may
>>>>>>> take
>>>>>>> a look if you want use it.
>>>>>>>
>>>>>>> [1] https://issues.apache.org/activemq/browse/SMX4-592
>>>>>>>
>>>>>>> Willem
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>  2010/9/11 Christian Müller<christian.muel...@gmail.com>
>>>>>>>
>>>>>>>>
>>>>>>>>  Hello Bengt!
>>>>>>>>
>>>>>>>>
>>>>>>>>> Sorry, I overlooked it.
>>>>>>>>> Apache Servicemix provides the OSGI-fied version for us. You can
>>>>>>>>> find
>>>>>>>>> the
>>>>>>>>> released version 4.0.2 here [1]
>>>>>>>>>
>>>>>>>>> [1]
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> http://repo2.maven.org/maven2/org/apache/servicemix/bundles/org.apache.servicemix.bundles.hibernate-validator/4.0.2.GA_2/
>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> Christian
>>>>>>>>>
>>>>>>>>> On Sat, Sep 11, 2010 at 10:23 AM, Bengt Rodehav<be...@rodehav.com>
>>>>>>>>>  wrote:
>>>>>>>>>
>>>>>>>>>  Thanks for your reply Christian.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> However, the JAR you refer to isn't an OSGi bundle either. In fact
>>>>>>>>>> I
>>>>>>>>>>
>>>>>>>>>>  think
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  its the publicly released jar from JBoss which I had problems
>>>>>>>>> with. I
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  tried
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  to use the OSGi wrapped version they use in Glassfish:
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> http://download.java.net/maven/2/org/glassfish/bean-validator/3.0-JBoss-4.0.2/bean-validator-3.0-JBoss-4.0.2.jar
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  But it turns out it requires the packages
>>>>>>>>>> "org.glassfish.api.naming.*"
>>>>>>>>>>
>>>>>>>>>>  that
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  I assume only exist in Glassfish.
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Related to the above, one also needs an OSGi bundle for the API:
>>>>>>>>>> javax.validation. Glassfish wraps it in the same jar I mentioned
>>>>>>>>>> above.
>>>>>>>>>> From
>>>>>>>>>> where does Camel take it?
>>>>>>>>>>
>>>>>>>>>> I don't quite understand how Camel can use the non-OSGi:fied
>>>>>>>>>> version
>>>>>>>>>> of
>>>>>>>>>> hibernate-validator. Have you tried this deployed in an OSGi
>>>>>>>>>> container?
>>>>>>>>>>
>>>>>>>>>> /Bengt
>>>>>>>>>>
>>>>>>>>>> 2010/9/11 Christian Müller<christian.muel...@gmail.com>
>>>>>>>>>>
>>>>>>>>>>  Hello Bengt,
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> we use the following on [1]. I think we could also update to
>>>>>>>>>>> 4.1.0.
>>>>>>>>>>> I
>>>>>>>>>>> opened
>>>>>>>>>>> a JIRA for it [2].
>>>>>>>>>>>
>>>>>>>>>>> Hope this helps,
>>>>>>>>>>> Christian
>>>>>>>>>>>
>>>>>>>>>>> [1]
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> http://repository.jboss.org/nexus/content/groups/public/org/hibernate/hibernate-validator/4.0.2.GA/hibernate-validator-4.0.2.GA.jar
>>>>>>>>>
>>>>>>>>>  [2] https://issues.apache.org/activemq/browse/CAMEL-3115
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Sat, Sep 11, 2010 at 1:07 AM, Bengt Rodehav<be...@rodehav.com
>>>>>>>>>>> >
>>>>>>>>>>>
>>>>>>>>>>>  wrote:
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>   I''m experimenting with the Java Bean Validation API (JSR 303).
>>>>>>>>>>> I'm
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>  not
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>   currently doing it with Camel but thought I might ask for help
>>>>>>>>> here
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>   anyway.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>  I'm deploying in an OSGi context and need OSGi bundles for both
>>>>>>>>>>>> the
>>>>>>>>>>>>
>>>>>>>>>>>>  API
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>   (java.validation) and Hibernate's reference implementation
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>   (preferably
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>   the
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>  latest version which I believe is 4.1). I haven't been able to
>>>>>>>>>>> find
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>  one.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>  The
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>  only one I've found is bundled for Glassfish but has
>>>>>>>>>>>> dependencies
>>>>>>>>>>>> on
>>>>>>>>>>>> Glassfish specific classes and therefore doesn't work outside
>>>>>>>>>>>>
>>>>>>>>>>>>  Glassfish.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>   Since Camel 2.4 contains the camel-bean-validator component I'm
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>  wondering
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>  if
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>  anyone can tell me how this problem was solved in Camel.
>>>>>>>>>>>>
>>>>>>>>>>>> /Bengt
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Reply via email to