Return-Path: Delivered-To: apmail-geronimo-user-archive@www.apache.org Received: (qmail 43674 invoked from network); 5 May 2009 20:29:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 May 2009 20:29:05 -0000 Received: (qmail 32866 invoked by uid 500); 5 May 2009 20:29:04 -0000 Delivered-To: apmail-geronimo-user-archive@geronimo.apache.org Received: (qmail 32809 invoked by uid 500); 5 May 2009 20:29:04 -0000 Mailing-List: contact user-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: user@geronimo.apache.org List-Id: Delivered-To: mailing list user@geronimo.apache.org Received: (qmail 32801 invoked by uid 99); 5 May 2009 20:29:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 May 2009 20:29:04 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 May 2009 20:28:54 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1M1RFh-0000Ck-76 for user@geronimo.apache.org; Tue, 05 May 2009 13:28:33 -0700 Message-ID: <23395324.post@talk.nabble.com> Date: Tue, 5 May 2009 13:28:33 -0700 (PDT) From: govinda To: user@geronimo.apache.org Subject: JNDI context MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: baskar.govinda@gmail.com X-Virus-Checked: Checked by ClamAV on apache.org Thanks all for your valuable answers. I'm a WebSphere user, new to geronimo. I'm migrating applications from websphere to geronimo. I thought I could avoid modifying the code with Context envContext = (Context)initContext.lookup("java:comp/env"); . I have specified "jdbc/LiferayPool" for an example, not seeking help with liferay. ------------------------------------------------------------------------------------ This message was accepted by the dev@geronimo.apache.org mailing list. How do I connect to a datasource thru code without context "java:comp/env" Context envContext = (Context)initContext.lookup("java:comp/env"); I just want to connect to DB like this DataSource ds = (DataSource)initContext.lookup("jdbc/LiferayPool"); Is it possible, if so where do I specify java jndi context ("java:comp/env") outside the code? Thanks Re: JNDI context by djencks May 04, 2009; 07:08pm :: Rate this Message: - Use ratings to moderate (?) Reply | Reply to Author | Print | View Threaded | Show Only this Message This is a user list question. If you have further questions on this subject pleas ask there and only there. On May 4, 2009, at 8:19 AM, govinda wrote: > > How do I connect to a datasource thru code without context > "java:comp/env" > > Context envContext = (Context)initContext.lookup("java:comp/env"); > > I just want to connect to DB like this > > DataSource ds = (DataSource)initContext.lookup("jdbc/LiferayPool"); Any such jndi name is going to be container specific. The java:comp/ stuff is there specifically so you can use the same jndi name in every container, so you don't have to recompile your app for every container. For information on the geronimo absolute jndi names, see http://cwiki.apache.org/GMOxDOC21/jndi.html Basically what you should do is deploy your datasource, restart geronimo, and look in var/log/geronimo.log for the log message telling you what the jndi location is. > > > Is it possible, if so where do I specify java jndi context > ("java:comp/env") > outside the code? As far as I understand what you are asking for in this sentence, it is not possible. thanks david jencks > > > Thanks > -- > View this message in context: > http://www.nabble.com/JNDI-context-tp23370580s134p23370580.html > Sent from the Apache Geronimo - Dev mailing list archive at > Nabble.com. > Re: JNDI context by Jack Cai May 04, 2009; 10:59pm :: Rate this Message: - Use ratings to moderate (?) Reply | Reply to Author | Print | View Threaded | Show Only this Message What's your real purpose behind this (not specifying "java:comp/env")? If it is just that you hate this string, you can use the "@Resource" annotation to inject the datasource in container-managed artifacts (Servlet, EJB, etc.). @Resource (name="jdbc/LiferayPool") private DataSource ds; -Jack 2009/5/5 David Jencks This is a user list question. If you have further questions on this subject pleas ask there and only there. On May 4, 2009, at 8:19 AM, govinda wrote: How do I connect to a datasource thru code without context "java:comp/env" Context envContext = (Context)initContext.lookup("java:comp/env"); I just want to connect to DB like this DataSource ds = (DataSource)initContext.lookup("jdbc/LiferayPool"); Any such jndi name is going to be container specific. The java:comp/ stuff is there specifically so you can use the same jndi name in every container, so you don't have to recompile your app for every container. For information on the geronimo absolute jndi names, see http://cwiki.apache.org/GMOxDOC21/jndi.html Basically what you should do is deploy your datasource, restart geronimo, and look in var/log/geronimo.log for the log message telling you what the jndi location is. Is it possible, if so where do I specify java jndi context ("java:comp/env") outside the code? As far as I understand what you are asking for in this sentence, it is not possible. thanks david jencks Thanks -- View this message in context: http://www.nabble.com/JNDI-context-tp23370580s134p23370580.html Sent from the Apache Geronimo - Dev mailing list archive at Nabble.com. Re: JNDI context by Peter Petersson-2 May 05, 2009; 03:10am :: Rate this Message: - Use ratings to moderate (?) Reply | Reply to Author | Print | View Threaded | Show Only this Message govinda wrote: > How do I connect to a datasource thru code without context "java:comp/env" > > Context envContext = (Context)initContext.lookup("java:comp/env"); > > I just want to connect to DB like this > > DataSource ds = (DataSource)initContext.lookup("jdbc/LiferayPool"); > > Is it possible, if so where do I specify java jndi context > ("java:comp/env") > outside the code? > ...[show rest of quote] If I have not misunderstood you last question and although I am not a G developer I hope no one minds I jump in an try to help out. In Liferay there are several ways to set up a database connection but you probably want to use Geronimo:s connection pool and sins Liferay 5.2.2 it is ones again possible to set up the application server connection pools JNDI name by specify the following line in your portal-ext.properties file. ###application server connection pools JNDI name jdbc.default.jndi.name=jdbc/LiferayPool I am not sure the following is required but I also have this in the end of the web.xml file. jdbc/LiferayPool javax.sql.DataSource Container Shareable Hope this helps. For more information about this take a look at http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Database%20Configuration regards peter petersson > Thanks > -- View this message in context: http://www.nabble.com/JNDI-context-tp23395324s134p23395324.html Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.