geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vamsavardhana Reddy <>
Subject Re: Retrieving the ValidatorFactory JNDI entry for a module context.
Date Thu, 26 Aug 2010 19:41:08 GMT
Hi Rick,

Isn't "javax.faces.validator.beanValidator.ValidatorFactory" attribute
required in the ServletContext only when the web app is using JSF?  Then the
place where this attribute can be added is in MyFacesModuleBuilderExtension
using a RuntimeCustomizer (similar to JasperServletContextCustomizer that
adds "org.apache.tomcat.InstanceManager" attribute to ServletContext).  By
the time the customize() method is called, the ValidatorFactory is available
in the jndiContext at "comp/ValidatorFactory".  I will create a patch for
this for you to review.

On Thu, Aug 26, 2010 at 8:56 PM, Rick McGuire <> wrote:

>  I'm trying to implement the bean validation feature described in section
> EE.6.27 of the Java EE 6 specification.  This requires that the web
> container set a property named
> "javax.faces.validator.beanValidator.ValidatorFactory" in the
> ServletContext.  I know where this should be set, but I'm having problems
> getting access to the ValidatorFactory instance that I need to satisfy this
> requirement.
> For example, I've tried adding the following code to TomcatContainer to set
> this property:
>        // now set the module context ValidatorFactory in a context
> property.
>        try  {
>            javax.naming.Context  ctx  =contextInfo.getJndiContext();
>            Object  validatorFactory
>  =ctx.lookup("java:comp/ValidatorFactory");
>  context.getServletContext().setAttribute("javax.faces.validator.beanValidator.ValidatorFactory",validatorFactory);
>        }catch  (NamingException  e) {
>             // ignore.  We just don't set the property if it's not
> available.
>        }
> This results in a NamingException, which probably means that
> contextInfo.getJndiContext() is not the correct place to retrieve this or
> the context has not yet been set up correctly.  I've also tried using an
> InitialContext to do the lookup with the same result.  I had a similar
> problem with Jetty where I tried using
>        try  {
>            javax.naming.Context  ctx
>  =integrationContext.getComponentContext();
>            Object  validatorFactory
>  =ctx.lookup("java:comp/ValidatorFactory");
> to lookup the factory.  How should I be obtaining this value when setting
> up the container?
> I have a similar issue with passing the ValidatorFactory when setting up
> the JPA provider.  The call to createContainerEntityManagerFactory() is made
> in constructor of the PersistenceUnitGBean.  In that context, how should the
> lookup for the ValidatorFactory instance for the module be performed?
> Rick


View raw message