Ah... the solution seems to be much simpler.... get rid of the "java:" in
the lookup!!
On Thu, Aug 26, 2010 at 8:56 PM, Rick McGuire <rickmcg@gmail.com> 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
>
--
Vamsi
|