javax.naming.NameNotFoundException:名称jdbc在此上下文中未绑定 [英] javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

查看:228
本文介绍了javax.naming.NameNotFoundException:名称jdbc在此上下文中未绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在网络服务工作...而且是一个初学者,
尝试在服务文件中获取Oracle Db连接,并且下降错误:

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)

并且在Apache Tomcat 6.0.32中使用O的以下链接指向DB配置racle 10g

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

ni have设置如下:

n i have made settings like below:

而且在下面显示错误:

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

我错过了什么....?

Am i missing something....?

谢谢.........

Thank you.........

推荐答案

你的问题是你需要在你的jndi字符串前面使用java:/ comp / env

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");

应该可以解决问题。

这篇关于javax.naming.NameNotFoundException:名称jdbc在此上下文中未绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆