gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 03:21:27 25 4
gpt4 key购买 nike

我正在从事Web服务...并且是一个初学者,
我正在尝试在服务文件中获取Oracle Db连接,并且出现以下错误:

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)

并引用下面的链接,了解使用Oracle 10g在Apache Tomcat 6.0.32中进行数据库配置

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

n我已经进行了如下设置:

并在以下行出现错误:
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");

我错过了什么吗?

谢谢.........

最佳答案

您的问题是您需要在jndi字符串前面加上java:/comp/env

因此,在您的情况下,请尝试:

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

那应该解决问题。

关于web-services - javax.naming.NameNotFoundException : Name jdbc is not bound in this Context,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6468109/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com