Return-Path: Delivered-To: apmail-geronimo-user-archive@www.apache.org Received: (qmail 42007 invoked from network); 22 May 2006 04:39:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 May 2006 04:39:32 -0000 Received: (qmail 6021 invoked by uid 500); 22 May 2006 04:39:29 -0000 Delivered-To: apmail-geronimo-user-archive@geronimo.apache.org Received: (qmail 6004 invoked by uid 500); 22 May 2006 04:39:29 -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 5988 invoked by uid 99); 22 May 2006 04:39:29 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 May 2006 21:39:28 -0700 X-ASF-Spam-Status: No, hits=1.0 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [203.3.176.70] (HELO lngateway.agd.nsw.gov.au) (203.3.176.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 May 2006 21:39:27 -0700 X-SEF-Processed: 5_0_0_910__2006_05_22_14_37_45 X-SEF-530AE5E8-B25C-4600-A8B4-A0AAE4DD4687: 1 Received: from Unknown [10.4.11.2] by lngateway.agd.nsw.gov.au - SurfControl E-mail Filter (5.0); Mon, 22 May 2006 14:37:43 +1000 In-Reply-To: <1ED7A952DFAE70488C8FE8E0A8100F33016D5F48@MSGBANCLA2WIN.DMN1.FMR.COM> To: user@geronimo.apache.org Subject: Re: Unable get datasource reference in bean... MIME-Version: 1.0 X-Mailer: Lotus Notes Release 6.0 September 26, 2002 Message-ID: From: Luke_Chiam@agd.nsw.gov.au Date: Mon, 22 May 2006 14:38:59 +1000 X-MIMETrack: Serialize by Router on GOODMDG1/Server/NSW_AG(Release 6.5.1|January 21, 2004) at 22/05/2006 02:37:46 PM, Serialize complete at 22/05/2006 02:37:46 PM Content-Type: multipart/alternative; boundary="=_alternative 00198A59CA257176_=" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N This is a multipart message in MIME format. --=_alternative 00198A59CA257176_= Content-Type: text/plain; charset="US-ASCII" do you need to declare with jdbc for datasource? ctx.lookup("java:comp/envjdbc//REQUEST"); "Varanasi, Ishwara" 22/05/2006 02:23 PM Please respond to user@geronimo.apache.org To cc Subject Unable get datasource reference in bean... Hi, I am facing a problem with accessing DataSource. I am able to get reference to a declared database pool in JSP and Servlet. But unable to do so in a session bean or class accessed by a session bean. I am getting a NameNotFoundException... any idea why this is happening? The code: InitialContext ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup("java:comp/env/REQUEST"); Connection con = ds.getConnection(); Web.xml: REQUEST javax.sql.DataSource Container Shareable Geronimo-web.xml: REQUEST REQUEST Output and stack trace of exception goes here: Getting ref in Servlet: ========================== 09:46:39,342 INFO [TimeServerServlet] 2. Getting ds ref in Servlet... 09:46:44,764 INFO [TimeServerServlet] Got connection: org.tranql.connector.jdbc.ConnectionHandle@81bb3b 09:46:44,764 INFO [DateTimeFunctions] Date : Mon May 22 09:46:44 IST 2006 09:46:44,764 INFO [DateTimeFunctions] Formatted Date: 22/05/2006 09:46:44.764 In ejbCreate() Error in bean: ========================== 09:46:44,780 INFO [TimeServerBean] 1. Getting ds ref in Bean... 09:46:44,780 ERROR [TimeServerBean] Exception #1: javax.naming.NameNotFoundException: env/REQUEST javax.naming.NameNotFoundException: env/REQUEST at org.apache.geronimo.naming.enc.AbstractReadOnlyContext.lookup(AbstractRe adOnlyContext.jav a:81) at org.apache.geronimo.naming.java.RootContext.lookup(RootContext.java:51) at javax.naming.InitialContext.lookup(InitialContext.java:347) at com.nis.timeserver.ejb.TimeServerBean.getTime(TimeServerBean.java:72) at com.nis.timeserver.ejb.TimeServerBean$$FastClassByCGLIB$$3926a5ec.invoke () at org.openejb.dispatch.AbstractMethodOperation.invoke(AbstractMethodOperat ion.java:90) at org.openejb.slsb.BusinessMethod.execute(BusinessMethod.java:67) at org.openejb.dispatch.DispatchInterceptor.invoke(DispatchInterceptor.java :72) at org.apache.geronimo.naming.java.ComponentContextInterceptor.invoke(Compo nentContextInterc eptor.java:56) at org.openejb.ConnectionTrackingInterceptor.invoke(ConnectionTrackingInter ceptor.java:81) at org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolic y.java:119) at org.openejb.transaction.TransactionContextInterceptor.invoke(Transaction ContextIntercepto r.java:80) at org.openejb.slsb.StatelessInstanceInterceptor.invoke(StatelessInstanceIn terceptor.java:98 ) at org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolic y.java:140) at org.openejb.transaction.TransactionContextInterceptor.invoke(Transaction ContextIntercepto r.java:80) at org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor .java:82) at org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:238) at org.openejb.proxy.EJBMethodInterceptor.intercept(EJBMethodInterceptor.ja va:129) at org.openejb.proxy.SessionEJBObject$$EnhancerByCGLIB$$39d68ea2.getTime() at com.nis.timeserver.web.servlet.TimeServerServlet.doGet(TimeServerServlet .java:88) at javax.servlet.http.HttpServlet.service(HttpServlet.java:595) at javax.servlet.http.HttpServlet.service(HttpServlet.java:688) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica tionFilterChain.j ava:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt erChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv e.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv e.java:178) at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.inv oke(GeronimoStand ardContext.java:272) at org.apache.geronimo.tomcat.valve.TransactionContextValve.invoke(Transact ionContextValve.j ava:53) at org.apache.geronimo.tomcat.valve.ComponentContextValve.invoke(ComponentC ontextValve.java: 47) at org.apache.geronimo.tomcat.valve.InstanceContextValve.invoke(InstanceCon textValve.java:60 ) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java :126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java :105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve. java:107) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:526 ) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1 48) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:85 6) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC onnection(Http11P rotocol.java:744) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint .java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollow erWorkerThread.ja va:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool .java:684) at java.lang.Thread.run(Thread.java:534) Thanks and Regards, Ishwara Bhat V *********************************************************** Please consider our environment before printing this email. This email and any attachments may be confidential and contain privileged information. If you are not the intended recipient you must not use, disclose, copy or distribute this communication. If you have received this message in error please delete and notify the sender. When communicating by email you consent to the monitoring and recording of that correspondence. The Attorney General's Department of NSW promotes a Just and Safe Society. Visit us at http://www.lawlink.nsw.gov.au --=_alternative 00198A59CA257176_= Content-Type: text/html; charset="US-ASCII"
do you need to declare with jdbc for datasource?

ctx.lookup("java:comp/envjdbc//REQUEST");





"Varanasi, Ishwara" <Ishwara.Varanasi@fmr.com>

22/05/2006 02:23 PM
Please respond to
user@geronimo.apache.org

To
<user@geronimo.apache.org>
cc
Subject
Unable get datasource reference in bean...





Hi,
I am facing a problem with accessing DataSource.
I am able to get reference to a declared database pool in JSP and
Servlet.
But unable to do so in a session bean or class accessed by a session
bean. I am getting a NameNotFoundException... any idea why this is
happening?

The code:
InitialContext ctx = new InitialContext();

DataSource ds = (DataSource)
ctx.lookup("java:comp/env/REQUEST");

Connection con = ds.getConnection();

Web.xml:
<resource-ref>

<res-ref-name>REQUEST</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>

</resource-ref>

Geronimo-web.xml:
<naming:resource-ref>

<naming:ref-name>REQUEST</naming:ref-name>
<naming:resource-link>REQUEST</naming:resource-link>

</naming:resource-ref>

Output and stack trace of exception goes here:

Getting ref in Servlet:
==========================
09:46:39,342 INFO  [TimeServerServlet] 2. Getting ds ref in Servlet...
09:46:44,764 INFO  [TimeServerServlet] Got connection:
org.tranql.connector.jdbc.ConnectionHandle@81bb3b
09:46:44,764 INFO  [DateTimeFunctions] Date          : Mon May 22
09:46:44 IST 2006
09:46:44,764 INFO  [DateTimeFunctions] Formatted Date: 22/05/2006
09:46:44.764 In ejbCreate()


Error in bean:
==========================
09:46:44,780 INFO  [TimeServerBean] 1. Getting ds ref in Bean...
09:46:44,780 ERROR [TimeServerBean] Exception #1:
javax.naming.NameNotFoundException: env/REQUEST
javax.naming.NameNotFoundException: env/REQUEST

at
org.apache.geronimo.naming.enc.AbstractReadOnlyContext.lookup(AbstractRe
adOnlyContext.jav
a:81)

at
org.apache.geronimo.naming.java.RootContext.lookup(RootContext.java:51)

at javax.naming.InitialContext.lookup(InitialContext.java:347)
at

com.nis.timeserver.ejb.TimeServerBean.getTime(TimeServerBean.java:72)
at

com.nis.timeserver.ejb.TimeServerBean$$FastClassByCGLIB$$3926a5ec.invoke
(<generated>)

at
org.openejb.dispatch.AbstractMethodOperation.invoke(AbstractMethodOperat
ion.java:90)

at
org.openejb.slsb.BusinessMethod.execute(BusinessMethod.java:67)

at
org.openejb.dispatch.DispatchInterceptor.invoke(DispatchInterceptor.java
:72)

at
org.apache.geronimo.naming.java.ComponentContextInterceptor.invoke(Compo
nentContextInterc
eptor.java:56)

at
org.openejb.ConnectionTrackingInterceptor.invoke(ConnectionTrackingInter
ceptor.java:81)

at
org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolic
y.java:119)

at
org.openejb.transaction.TransactionContextInterceptor.invoke(Transaction
ContextIntercepto
r.java:80)

at
org.openejb.slsb.StatelessInstanceInterceptor.invoke(StatelessInstanceIn
terceptor.java:98
)

at
org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolic
y.java:140)

at
org.openejb.transaction.TransactionContextInterceptor.invoke(Transaction
ContextIntercepto
r.java:80)

at
org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor
.java:82)

at
org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:238)

at
org.openejb.proxy.EJBMethodInterceptor.intercept(EJBMethodInterceptor.ja
va:129)

at
org.openejb.proxy.SessionEJBObject$$EnhancerByCGLIB$$39d68ea2.getTime(<g
enerated>)

at
com.nis.timeserver.web.servlet.TimeServerServlet.doGet(TimeServerServlet
.java:88)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.j
ava:252)

at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:173)

at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:213)

at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:178)

at
org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.inv
oke(GeronimoStand
ardContext.java:272)

at
org.apache.geronimo.tomcat.valve.TransactionContextValve.invoke(Transact
ionContextValve.j
ava:53)

at
org.apache.geronimo.tomcat.valve.ComponentContextValve.invoke(ComponentC
ontextValve.java:
47)

at
org.apache.geronimo.tomcat.valve.InstanceContextValve.invoke(InstanceCon
textValve.java:60
)

at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:126)

at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:105)

at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:107)

at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:526
)

at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1
48)

at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:85
6)

at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC
onnection(Http11P
rotocol.java:744)

at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint
.java:527)

at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollow
erWorkerThread.ja
va:80)

at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
.java:684)

at java.lang.Thread.run(Thread.java:534)


Thanks and Regards,
Ishwara Bhat V





***********************************************************

Please consider our environment before printing this email.

This email and any attachments may be confidential and contain privileged
 information. If you are not the intended recipient you must not use, 
disclose, copy or distribute this communication. If you have received 
this message in error please delete and notify the sender. When communicating 
by email you consent to the monitoring and recording of that correspondence.

The Attorney General's Department of NSW promotes a Just and Safe Society. 
Visit us at http://www.lawlink.nsw.gov.au
--=_alternative 00198A59CA257176_=--