Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

Am working on web Services... and am a beginner, Am trying to get Oracle Db connection in a service File and am getting below error:

javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
    at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
    at DatabaseConnection.shamDBConn.getShamStage(shamDBConn.java:25)
    at lineItemPrice.itemDetails.getUserId(itemDetails.java:17)
    at ServerSevices.availableServices.useridService(availableServices.java:11)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194)
    at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:102)
    at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
    at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:100)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
    at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:133)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:619)

And refered below link for DB configuration in Apache Tomcat 6.0.32 with Oracle 10g

http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html

n i have made settings like below: enter image description here

And am getting error for below line:

DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");

Am i missing something....?

Thank you.........

like image 513
Warrior Avatar asked Jun 24 '11 12:06

Warrior


1 Answers

Your problem is that you need to prefix your jndi string with java:/comp/env

So in your case try:

DataSource ds = (DataSource)envContext.lookup("java:/comp/env/jdbc/myoracle");

That should solve the problem.

like image 138
stevemac Avatar answered Nov 06 '22 02:11

stevemac