Thanks Santosh, it is working now. Regards, Ishwara Bhat V
-----Original Message----- From: Santosh Koti [mailto:[EMAIL PROTECTED] Sent: Monday, May 22, 2006 1:41 PM To: [email protected] Subject: RE: Unable get datasource reference in bean... Here is a sample from my app (openejb-jar.xml) Try smething like this. I am bit busy rt nw, give a try Else post back to the forum , me or some1 may help u. -----------Begin---------- <?xml version="1.0" encoding="UTF-8"?> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.0" xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.0" xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0" xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1" xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.0" configId="Appservices/Accounts"> <ejb-ql-compiler-factory>org.tranql.ejbqlcompiler.OracleEJBQLCompilerFac tory</ejb-ql-compiler-factory> <db-syntax-factory>org.tranql.sql.oracle.OracleDBSyntaxFactory</db-synta x-factory> <enterprise-beans> <session> <ejb-name>AccountsInfoEJB</ejb-name> <jndi-name>ejb/AccountsInfoEJB</jndi-name> <ejb-ref> <ref-name>ejb/AccountDetails</ref-name> <ejb-link>AccountDetails</ejb-link> </ejb-ref> <ejb-ref> <ref-name>ejb/CustomerEJB</ref-name> <ejb-link>Customer</ejb-link> </ejb-ref> <resource-ref> <ref-name>testbank</ref-name> <resource-link>testbank</resource-link> </resource-ref> </session> </enterprise-beans> </openejb-jar> ------------End----------- Thanks, Santosh. "Don't talk about yourself; it will be done when you leave. " -----Original Message----- From: Varanasi, Ishwara [mailto:[EMAIL PROTECTED] Sent: Monday, May 22, 2006 10:24 AM To: [email protected] Subject: RE: Unable get datasource reference in bean... Hi Santosh, Thanks for your help. My current openejb-jar looks like this: <?xml version="1.0" encoding="UTF-8"?> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.0" xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.0" configId="TimeServerEJB"> <enterprise-beans> <session> <ejb-name>TimeServer</ejb-name> <jndi-name>ejb/TimeServer</jndi-name> </session> </enterprise-beans> </openejb-jar> Could you please tell me how/where to add resource ref? (thank you very much for your time) Regards, Ishwara Bhat V -----Original Message----- From: Santosh Koti [mailto:[EMAIL PROTECTED] Sent: Monday, May 22, 2006 10:01 AM To: [email protected] Subject: RE: Unable get datasource reference in bean... 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:[EMAIL PROTECTED] Sent: Monday, May 22, 2006 9:54 AM To: [email protected] 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: [EMAIL PROTECTED] 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***
