javax.naming.NameNotFoundException: While trying to lookup 。。。

错误大致如下:

javax.naming.NameNotFoundException: While trying to lookup 'HelloWorldApp.HelloWorldBean/local' didn't find subcontext 'HelloWorldApp'. Resolved ''; remaining name 'HelloWorldApp/HelloWorldBean/local' at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1138) at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:246) at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:171) at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:205) at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254) at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:367) at javax.naming.InitialContext.lookup(InitialContext.java:351) at ejb.learning.Locator.getBean(Ljava.lang.String  Ljava.lang.Object;(Unknown Source) at ejb.learning.web.HelloWorldServlet.processRequest(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse  V(Unknown Source) at ejb.learning.web.HelloWorldServlet.doGet(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse  V(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3370) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(Lweblogic.security.acl.internal.AuthenticatedSubject;Lweblogic.security.acl.internal.AuthenticatedSubject;Ljava.security.PrivilegedAction  Ljava.lang.Object;(Unknown Source) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2117) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2023) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1359) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200) at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)




解决办法:


在bean里面加上
@Stateless(mappedName="HelloWorldBean")



客户端访问的时候只需要

helloWorld = (HelloWorld) ctx.lookup("HelloWorldBean#"+ HelloWorld.class.getName());

ok,问题解决

你可能感兴趣的:(java,servlet,weblogic,Security,ejb)