Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 87815 invoked from network); 9 Feb 2011 14:23:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Feb 2011 14:23:06 -0000 Received: (qmail 8546 invoked by uid 500); 9 Feb 2011 14:23:02 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 8425 invoked by uid 500); 9 Feb 2011 14:22:58 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 8416 invoked by uid 99); 9 Feb 2011 14:22:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Feb 2011 14:22:56 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [213.131.255.80] (HELO ks101.cryonhost.eu) (213.131.255.80) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Feb 2011 14:22:48 +0000 Received: from [192.168.1.194] (axivion1.tz.uni-stuttgart.de [129.69.226.21]) (Authenticated sender: web39p11) by ks101.cryonhost.eu (Postfix) with ESMTPSA id 91A216E0F5B for ; Wed, 9 Feb 2011 15:21:04 +0100 (CET) Message-ID: <4D52A307.4040403@axivion.com> Date: Wed, 09 Feb 2011 15:21:59 +0100 From: Stephan Beutel User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.9) Gecko/20100825 Thunderbird/3.1.3 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Context.xml for multiple datasources References: <4D525B8B.5080900@axivion.com> <4D526331.7010702@axivion.com> <4D526886.8090806@axivion.com> <4D527F40.2000009@axivion.com> <99C8B2929B39C24493377AC7A121E21F9A47DCCAEC@USEA-EXCH8.na.uis.unisys.com> In-Reply-To: <99C8B2929B39C24493377AC7A121E21F9A47DCCAEC@USEA-EXCH8.na.uis.unisys.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Am 09.02.2011 15:02, schrieb Caldarale, Charles R: >> From: Stephan Beutel [mailto:beutel@axivion.com] >> Subject: Re: Context.xml for multiple datasources >> But I thought it could be defined by a map in >> context.xml like in Spring. > Even if you did, that wouldn't solve your problem. You would still have to stop and restart the webapp every time an additional datasource was added to the element. > > You could provide a element nested inside the that specifies the names of the entries, but there's no automatically created list of elements. > > - Chuck > > > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > Restarting the webapp is no problem. Rebuilding the war file is a problem. At the moment I solved it in this was: Spring looks for the two environment vars (dataSourceNames, dataSourceList) and inject them into my RoutingDataSource class: And in my java class I do the lookup with JNDI: private void createDataSourceMap() { if (this.dataSourceList != null && this.dataSourceNames != null && this.dataSourceList.size() > 0 && this.dataSourceNames.size() > 0 && dataSourceList.size() == this.dataSourceNames.size()) { this.dataSources = new HashMap(); for (int i = 0; i < dataSourceList.size(); i++) { Context initCtx; Object dataSource = null; try { initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); dataSource = envCtx.lookup(dataSourceList.get(i)); if(i==0){ setDefaultTargetDataSource(dataSource); } } catch (NamingException e) { e.printStackTrace(); } dataSources.put(dataSourceNames.get(i), dataSource); } setTargetDataSources(dataSources); } } If someone has a better solution, please let me know. Regards Stephan --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org