javax.naming.NameNotFoundException:无法解析"MyDB".已解决''Weblogic 12.1.3. C [英] javax.naming.NameNotFoundException: Unable to resolve 'MyDB'. Resolved '' Weblogic 12.1.3. c

查看:263
本文介绍了javax.naming.NameNotFoundException:无法解析"MyDB".已解决''Weblogic 12.1.3. C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Tomcat迁移到Weblogic 12.1.3时,出现此异常javax.naming.namenotfoundexception while trying to look up 然后我尝试了以下方法: NameNotFoundException:仅尝试查找"jdbc"时从Eclipse Kepler而不是从Indigo发布时如何访问在weblogic 10.3.6

While migrating from Tomcat to Weblogic 12.1.3 I got this exception javax.naming.namenotfoundexception while trying to look up then I have tried the following : NameNotFoundException: While trying to lookup 'jdbc' only when publishing from Eclipse Kepler but not Indigo and How to access JNDI data source defined in weblogic 10.3.6

我现在遇到标题错误

我的查询代码

ds = (DataSource) initContext.lookup("MyDB");

在Weblogic JNDI名称

in weblogic JNDI Name

MyDB

请帮忙吗?

推荐答案

与Tomcat不同,weblogic创建了多台服务器(通常是一台Admin Server,再加上至少一台其他服务器).必须为每个服务器分配数据源.在集群环境中,您需要将数据源应用于集群服务器.

Unlike Tomcat, weblogic creates multiple servers (Usually an Admin Server, plus at least one other). Each server has to be allocated the data source. In a clustered environment, you need to apply the datasource to the cluster servers.

  1. 登录到Weblogic控制台,并检查数据源JNDI名称(不要将其与数据源名称混淆,这纯粹是为了使控制台列表看起来很漂亮). JNDI名称应类似于jdbc/MyDB
  2. 检查数据源的"目标"标签,并确保将其应用于要部署Web应用程序的服务器/群集.
  3. 重新启动Weblogic.我发现数据源有时需要使用它,然后它们才能对应用程序代码可见.
  4. 将您的Web应用程序部署到正确的服务器/集群.
  1. Log into the Weblogic console, and check the datasource JNDI name (don't confuse this with the datasource name, which is purely to keep the console listing looking pretty). The JNDI name should be something like jdbc/MyDB
  2. Check the datasource Targets tab, and make sure it is applied to the server/cluster you are going to deploy your web app to.
  3. Restart Weblogic. I find that data sources sometimes need this before they become visible to application code.
  4. Deploy your web app to the correct server/cluster.

您应该正常连接到数据源.我总是使用Spring JNDI bean,因此我无法提供确切的语法. @Maas的建议看起来不错.

You should be to connect to the datasource as normal. I always use a Spring JNDI bean, so I can't help with the exact syntax. The suggestions by @Maas look good.

这篇关于javax.naming.NameNotFoundException:无法解析"MyDB".已解决''Weblogic 12.1.3. C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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