geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Santosh Koti" <Santosh_K...@infosys.com>
Subject RE: Unable get datasource reference in bean...
Date Mon, 22 May 2006 04:30:38 GMT



Have a resource reference in ur openejb-jar.xml for ur JNDI lookup.
That should help u.

Thanks,
Santosh.
"Don't talk about yourself; it will be done when you leave. "


-----Original Message-----
From: Varanasi, Ishwara [mailto:Ishwara.Varanasi@fmr.com]
Sent: Monday, May 22, 2006 9:54 AM
To: user@geronimo.apache.org
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

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of
the addressee(s). If you are not the intended recipient, please notify the sender by e-mail
and delete the original message. Further, you are not to copy, disclose, or distribute this
e-mail or its contents to any other person and any such actions are unlawful. This e-mail
may contain viruses. Infosys has taken every reasonable precaution to minimize this risk,
but is not liable for any damage you may sustain as a result of any virus in this e-mail.
You should carry out your own virus checks before opening the e-mail or attachment. Infosys
reserves the right to monitor and review the content of all messages sent to or from this
e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys
e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

Mime
View raw message