javax.naming.NameNotFoundException:名称jdbc未绑定在此Context中

时间:2023-01-01 22:48:43

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:

我正在开发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)

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

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

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

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

n i have made settings like below: javax.naming.NameNotFoundException:名称jdbc未绑定在此Context中

我已经进行了如下设置:

And am getting error for below line:

我收到以下错误:

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

Am i missing something....?

我错过了什么......?

Thank you.........

谢谢.........

2 个解决方案

#1


11  

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

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

So in your case try:

所以在你的情况下尝试:

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

That should solve the problem.

那应该可以解决问题。

#2


0  

I also come across with this problem, but in my case I've fixed by adding bellow line:

我也遇到过这个问题,但在我的情况下,我通过添加下面的线来修复:

<ResourceLink global="jdbc/myoracle" name="jdbc/myoracle" type="oracle.jdbc.pool.OracleDataSource"/>

to tomcat conf file -> context.xml.

到tomcat conf文件 - > context.xml。

#1


11  

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

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

So in your case try:

所以在你的情况下尝试:

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

That should solve the problem.

那应该可以解决问题。

#2


0  

I also come across with this problem, but in my case I've fixed by adding bellow line:

我也遇到过这个问题,但在我的情况下,我通过添加下面的线来修复:

<ResourceLink global="jdbc/myoracle" name="jdbc/myoracle" type="oracle.jdbc.pool.OracleDataSource"/>

to tomcat conf file -> context.xml.

到tomcat conf文件 - > context.xml。