Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 58320 invoked from network); 26 Aug 2010 15:26:36 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 26 Aug 2010 15:26:36 -0000 Received: (qmail 44055 invoked by uid 500); 26 Aug 2010 15:26:35 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 43968 invoked by uid 500); 26 Aug 2010 15:26:35 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 43961 invoked by uid 99); 26 Aug 2010 15:26:35 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Aug 2010 15:26:35 +0000 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=FREEMAIL_FROM,HK_RANDOM_ENVFROM,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of rickmcg@gmail.com designates 209.85.216.175 as permitted sender) Received: from [209.85.216.175] (HELO mail-qy0-f175.google.com) (209.85.216.175) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Aug 2010 15:26:26 +0000 Received: by qyk8 with SMTP id 8so6795234qyk.13 for ; Thu, 26 Aug 2010 08:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=zW5jDhKdAeZveIVhfN9mMFoRmolndlXbv0zxvc+9whI=; b=tgFcMRwzeck4o3diGt/csboE21OVbcCMihTk8ixlNTHV7PO+kFsv0FTSFndeVcOOYK S5HS1HicLHBfZIz6AvhZVjc2uAj/H0lljs7dfWcTEaXII2wv91F1pAbtBjZslxfZSGAq plJhla94xyj0/nQ7C56pX8diiBh97IvsZeUP4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=FmWRtJSku6x4TQcPCAMEHJqpqf8uTxfkA6OAiLDfYl+cCPmOkHGdXAP3ZKWeY4+zt+ S/Lkzo+cGAgStdcBq5zqV1CwHgL8+0MfAsXIKh3WUNWqkM8glQNRD93LksGHotbLgJ9q ZP4i7viAHri4hQ/CemlIzMOnqMcdZroNd9XU8= Received: by 10.229.233.80 with SMTP id jx16mr7304996qcb.62.1282836365651; Thu, 26 Aug 2010 08:26:05 -0700 (PDT) Received: from [192.168.1.100] (68-191-49-15.dhcp.nwtn.ct.charter.com [68.191.49.15]) by mx.google.com with ESMTPS id t4sm3126279qcs.28.2010.08.26.08.26.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 26 Aug 2010 08:26:05 -0700 (PDT) Message-ID: <4C76878C.5050606@gmail.com> Date: Thu, 26 Aug 2010 11:26:04 -0400 From: Rick McGuire Reply-To: rickmcg@gmail.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 MIME-Version: 1.0 To: Geronimo Dev Subject: Retrieving the ValidatorFactory JNDI entry for a module context. Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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