javax.naming.NameNotFoundException:无法解析“MyDB”。解决了''Weblogic 12.1.3。C
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25258461/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
javax.naming.NameNotFoundException: Unable to resolve 'MyDB'. Resolved '' Weblogic 12.1.3. c
提问by Dunken
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 Indigoand
How to access JNDI data source defined in weblogic 10.3.6
在从 Tomcat 迁移到 Weblogic 12.1.3 时,我遇到了这个异常,javax.naming.namenotfoundexception while trying to look up
然后我尝试了以下操作:
NameNotFoundException:仅在从 Eclipse Kepler 而不是 Indigo 发布时尝试查找 'jdbc'以及
如何访问 weblogic 10.3 中定义的 JNDI 数据源。 6
I got the in titled error now
我现在收到了标题错误
My lookup code
我的查找代码
ds = (DataSource) initContext.lookup("MyDB");
in weblogic JNDI Name
在 weblogic 中JNDI 名称
MyDB
Any help please?
请问有什么帮助吗?
采纳答案by kiwiron
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.
与 Tomcat 不同的是,weblogic 创建了多个服务器(通常是一个管理服务器,加上至少一个其他服务器)。必须为每个服务器分配数据源。在集群环境中,需要将数据源应用到集群服务器上。
- 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
- Check the datasource Targetstab, and make sure it is applied to the server/cluster you are going to deploy your web app to.
- Restart Weblogic. I find that data sources sometimes need this before they become visible to application code.
- Deploy your web app to the correct server/cluster.
- 登录到 Weblogic 控制台,并检查数据源 JNDI 名称(不要将其与数据源名称混淆,这纯粹是为了使控制台列表看起来很漂亮)。JNDI 名称应该类似于 jdbc/MyDB
- 检查数据源目标选项卡,并确保它应用于您要将 Web 应用程序部署到的服务器/集群。
- 重新启动 WebLogic。我发现数据源有时在它们对应用程序代码可见之前就需要它。
- 将您的 Web 应用程序部署到正确的服务器/集群。
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.
您应该正常连接到数据源。我总是使用 Spring JNDI bean,所以我无法提供确切的语法。@Maas 的建议看起来不错。
回答by ACV
Restarting the server after deployment helps.
部署后重新启动服务器会有所帮助。
回答by A. Schoinas
Check the JNDI case (MyDB != MyDb). It sounds trivial, but it happened to me and had a hard time spotting it. Since this is the first thread google returns when searching for this issue, I post it here in case it helps.
检查 JNDI 案例 (MyDB != MyDb)。这听起来微不足道,但它发生在我身上并且很难发现它。由于这是 google 在搜索此问题时返回的第一个线程,因此我将其发布在这里以防万一。
Besides that, @kiwiron 's answer covers everything else.
除此之外,@kiwiron 的回答涵盖了其他所有内容。
回答by weiwei
For me, starting the managed server from Windows command line instead of starting it using the WebLogic Admin console solved the javax.naming.NameNotFoundException
problem. Not sure why this was the case though.
对我来说,从 Windows 命令行启动托管服务器而不是使用 WebLogic 管理控制台启动它解决了这个javax.naming.NameNotFoundException
问题。不知道为什么会这样。