javax.naming.NameNotFoundException:尝试查找'abc'时没有找到子上下文'abc' [英] javax.naming.NameNotFoundException: While trying to lookup 'abc' didn't find subcontext 'abc'
问题描述
我开发了一个带有Remote接口的EJB应用程序。这个应用程序部署在weblogic 12上。
I've developed a EJB application, with a Remote interface. This application was deployed on weblogic 12.
使用java应用程序,我正在尝试使用我的EJB应用程序,但是当我从类InitialContext调用方法查找时,我得到了此消息javax.naming.NameNotFoundException:尝试查找'NewSessionBean.remote'时未找到子上下文'NewSessionBean'
With a java application, i'm trying use my EJB application, but when I call method lookup from the class InitialContext, i get this message "javax.naming.NameNotFoundException: While trying to lookup 'NewSessionBean.remote' didn't find subcontext 'NewSessionBean"
这是来自远程接口的代码:
This is code from remote interface:
package co.com.tutorial.stateless;
import java.util.List;
import javax.ejb.Remote;
/**
*
* @author jquintep
*/
@Remote
public interface NewSessionBeanRemote {
void addBook(String bookName);
List getBooks();
}
这是实施代码的一部分:
This is part of the code from implementation:
package co.com.tutorial.stateless;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
/**
*
* @author jquintep
*/
@Stateless
public class NewSessionBean implements NewSessionBeanRemote {
List<String> bookShelf;
public NewSessionBean() {
bookShelf = new ArrayList<String>();
}
当我调用lookup时,这是代码的一部分:
And this is a part of the code when i call lookup:
try {
int choice = 1;
NewSessionBeanRemote libraryBean =
(NewSessionBeanRemote)ctx.lookup("NewSessionBean/remote");
感谢您考虑我的请求。
PS
我正在关注tutorialspoint上的EJB教程。
PS I am following the EJB tutorial at tutorialspoint.
推荐答案
你可以通过以下路径看到你的JNDI树Weblogic的控制台
You could see your JNDI tree through the following path in Weblogic's console
环境 - >服务器 - >选择你的服务器 - >点击查看JNDI树链接
Environment -> servers -> select your server -> click on view JNDI tree link
I总是检查JNDI树是否存在查找问题。
I always check JNDI tree for lookup problems.
为什么不使用JNDI可移植名称进行查找?
Why do not you use JNDI portable name for lookup?
https://docs.oracle.com/cd/E19798-01/821-1841/girgn/index.html
如果你有将您的实现部署为单独的EAR,您可以使用以下查找
If you had deployed your implementation as a separate EAR, you could use the following lookup
ctx.lookup("java:global/[your ear name]/[your jar file name(module name)]/NewSessionBean!co.com.tutorial.stateless.NewSessionBeanRemote");
如果您已将实现部署为单独的jar,则可以使用以下查找
If you had deployed your implementation as a separate jar, you could use the following lookup
ctx.lookup("java:global/[your jar file name(module name)]/NewSessionBean!co.com.tutorial.stateless.NewSessionBeanRemote");
如果你想在同一个EAR中查找但是在另一个罐子里
If you want to look up in the same EAR but in a different jar
ctx.lookup("java:app/[your jar file name(module name)]/NewSessionBean!co.com.tutorial.stateless.NewSessionBeanRemote");
如果你想在同一个EAR和同一个罐子中查找
If you want to look up in the same EAR and in the same jar
ctx.lookup("java:module//NewSessionBean!co.com.tutorial.stateless.NewSessionBeanRemote");
这篇关于javax.naming.NameNotFoundException:尝试查找'abc'时没有找到子上下文'abc'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!