Gunnar,

Thanks for your response and your aid.  John Ament had given a resolution
out-of-band: the Seam validation extension is at the root of the problem.

On Sat, Dec 21, 2013 at 12:31 PM, John D. Ament <john.d.am...@gmail.com>
 wrote:

> John,
>
> I think I found your issue..
>
> So in the Seam Validation extension, they did this:
>
> https://github.com/seam/validation/blob/develop/impl/src/main/java/org/jboss/seam/validation/ValidationExtension.java#L56
> Basically, they try to see if a ValidatorFactory is available, and
> Validator is available.  The problem is ordering.  In this scenario,
> the validator isn't available yet (in CDI 1.1 they clarified that you
> cannot attempt to get a reference to an object), so the extension will
> in fact attempt to install a custom bean, which if I had to guess is
> messing with the default implementation and causing bad things to
> happen.
>
> I would normally tell you to disable the extension, but that won't
> work here since they're loading the extension in the framework (here:
>
> https://github.com/seam/validation/blob/develop/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
> ).  You do have a couple of other solutions:
>
> 1. Create your own org.jboss.seam.validation.ValidationExtension class
> that does not do this.  This will trick the classloader into loading
> yours first (assuming you're packaging a WAR or EAR).  If you're using
> an EAR, make sure the module that has this comes before validation.
> 2. Create a shaded JAR that only includes what you need (if you're not
> using the method validator, based on the code example you sent out,
> you can safely just pull in the constraint validator, but you'll need
> to manually install).
> 3. Switch to DeltaSpike.  I know 0.5 doesn't look final, but in its
> current behavior Seam3 is also not very compatible with the AS7 line.
> Our compatibility is a bit better, now that Arquillian has in fact
> grown to a more robust testing framework.
>
> In order of my preference, I would go 2 then 3 then 1.  1 is the
> hackier solution, and requires classloading witchcraft.  2 is a robust
> solution with minimal impact (build time only).  3 is a more robust
> solution for longevity, but higher impact potentially on code.



On Sat, Dec 21, 2013 at 2:52 PM, Gunnar Morling <gun...@hibernate.org>wrote:

> Hi,
>
> Can you give some more details about the environment and project versions
> you're using?
>
> Are you by any chance declaring a producer method for j.v.Validator? The
> Validator bean contributed by Seam Validation (which you seem to be using)
> is application scoped, so the validator should only be bootstrapped once. I
> don't think it's an issue with Hibernate Validator itself but with the
> integration into CDI and how it is configured.
>
> --Gunnar
>
>
>
> 2013/12/21 John D. Ament <john.d.am...@gmail.com>
>
> John,
>>
>> Hibernate Validator should only be creating a validator factory once
>> for the deployment.  Hence, it should only be reading validation.xml
>> at deployment time.  The fact that you are seeing it multiple times is
>> why I'm thinking its a validator issue (I don't reproduce this on
>> mine, I'm on AS 7.1.1 w/ Validator 4.3.1).  Hence why I'm curious what
>> version you're on.  Hibernate Validator is responsible for the
>> instantiation of the validator factory.
>>
>> Also, I assumed (possibly foolishly) that your rest endpoint is
>> annotated with a CDI or EJB qualifying annotation.  Is that the case?
>>
>> Just as a heads up as well, the InjectingConstraintValidator was
>> recently ported from Seam3 to DeltaSpike.  The code is almost
>> verbatim.
>>
>> On Sat, Dec 21, 2013 at 11:02 AM, John Franey <jjfra...@gmail.com> wrote:
>> > John,
>> >
>> > I'm excellent....thanks.  You?
>> >
>> > Yes, this seems more like a question for weld/hibernate, than
>> resteasy...but
>> > I thought to start at the top :)
>> >
>> > Maybe I misunderstand injection, within the jax-rs environment, or in
>> > general.  I'm not sure which component drives the initialization of the
>> > validator, I guess its weld.  On the other hand, if I have a faulty
>> > understanding of jax-rs integration with cdi, I could be inadvertently
>> > causing multiple initializations.
>> >
>> > Thanks for the response.  I posted a similar question to weld after you
>> > implicitly confirmed my code is not at fault.
>> >
>> > John
>> >
>> >
>> >
>> >
>> >
>> > On Fri, Dec 20, 2013 at 6:50 PM, John D. Ament <john.d.am...@gmail.com>
>> > wrote:
>> >>
>> >> Hey John,
>> >>
>> >> How are you?
>> >>
>> >> It seems like your issue is more Hibernate Validator related.  What
>> >> version are you using?  I don't see that message on the 4.3 branch or
>> >> the 4.1 branch.
>> >>
>> >> - John
>> >>
>> >> On Fri, Dec 20, 2013 at 5:53 PM, John Franey <jjfra...@gmail.com>
>> wrote:
>> >> > Hi,
>> >> >
>> >> > I have a resource that injects the validator, and the rest method
>> >> > invokes
>> >> > the validator.  On every request, I see these entries in the log.
>>  That
>> >> > is
>> >> > 'Parsing XML based configuration by 4 on every request.  Is that
>> >> > reasonable?
>> >> > If not, how do I workaround?
>> >> >
>> >> > 17:38:14,022 INFO
>> >> > [org.hibernate.validator.internal.xml.ValidationXmlParser]
>> >> > (http-localhost/127.0.0.1:8080-1) HV000007: META-INF/validation.xml
>> >> > found.
>> >> > Parsing XML based configurati
>> >> > on.
>> >> > 17:38:14,027 INFO
>> >> > [org.hibernate.validator.internal.xml.ValidationXmlParser]
>> >> > (http-localhost/127.0.0.1:8080-1) HV000003: Using
>> >> > org.jboss.seam.validation.InjectingConstraintValidator
>> >> > Factory as constraint factory.
>> >> > 17:38:14,046 INFO
>> >> > [org.hibernate.validator.internal.xml.ValidationXmlParser]
>> >> > (http-localhost/127.0.0.1:8080-1) HV000007: META-INF/validation.xml
>> >> > found.
>> >> > Parsing XML based configurati
>> >> > on.
>> >> > 17:38:14,051 INFO
>> >> > [org.hibernate.validator.internal.xml.ValidationXmlParser]
>> >> > (http-localhost/127.0.0.1:8080-1) HV000003: Using
>> >> > org.jboss.seam.validation.InjectingConstraintValidator
>> >> > Factory as constraint factory.
>> >> > 17:38:14,068 INFO
>> >> > [org.hibernate.validator.internal.xml.ValidationXmlParser]
>> >> > (http-localhost/127.0.0.1:8080-1) HV000007: META-INF/validation.xml
>> >> > found.
>> >> > Parsing XML based configurati
>> >> > on.
>> >> > 17:38:14,073 INFO
>> >> > [org.hibernate.validator.internal.xml.ValidationXmlParser]
>> >> > (http-localhost/127.0.0.1:8080-1) HV000003: Using
>> >> > org.jboss.seam.validation.InjectingConstraintValidator
>> >> > Factory as constraint factory.
>> >> > 17:38:14,093 INFO
>> >> > [org.hibernate.validator.internal.xml.ValidationXmlParser]
>> >> > (http-localhost/127.0.0.1:8080-1) HV000007: META-INF/validation.xml
>> >> > found.
>> >> > Parsing XML based configuration.
>> >> > 17:38:14,099 INFO
>> >> > [org.hibernate.validator.internal.xml.ValidationXmlParser]
>> >> > (http-localhost/127.0.0.1:8080-1) HV000003: Using
>> >> > org.jboss.seam.validation.InjectingConstraintValidatorFactory as
>> >> > constraint
>> >> > factory.
>> >> >
>> >> >
>> >> >
>> >> > This is a simplification of my code:
>> >> >
>> >> > @Path(....)
>> >> > public class MyResource {
>> >> >
>> >> >   @Inject
>> >> >   private Validator validator;
>> >> >
>> >> >   @PUT
>> >> >   public create(MyObject myObject) {
>> >> >        validator.validate(myObject);
>> >> >   }
>> >> > }
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> ------------------------------------------------------------------------------
>> >> > Rapidly troubleshoot problems before they affect your business. Most
>> IT
>> >> > organizations don't have a clear picture of how application
>> performance
>> >> > affects their revenue. With AppDynamics, you get 100% visibility into
>> >> > your
>> >> > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of
>> >> > AppDynamics
>> >> > Pro!
>> >> >
>> >> >
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>> >> > _______________________________________________
>> >> > Resteasy-users mailing list
>> >> > Resteasy-users@lists.sourceforge.net
>> >> > https://lists.sourceforge.net/lists/listinfo/resteasy-users
>> >> >
>> >
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> Rapidly troubleshoot problems before they affect your business. Most IT
>> organizations don't have a clear picture of how application performance
>> affects their revenue. With AppDynamics, you get 100% visibility into your
>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>> Pro!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Resteasy-users mailing list
>> Resteasy-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>>
>
>
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users

Reply via email to