![](/img/trans.png)
[英]Ejb3 GlassFish - JNDI Lookup failed in SerialContext - NameNotFoundException
[英]JNDI lookup failed on GlassFish 5
我是Java EE的新手,我的问题似乎很愚蠢。
尝试在Glassfish上部署应用程序时出现javax.naming.NameNotFoundException
。 当我在DeviceStorage类中实现java.util.Observer时,就会发生这种情况。 当我不这样做时,它会部署而不会出现任何错误。 有人知道为什么会发生吗?
Exception while deploying the app [Test-1.0-SNAPSHOT] : JNDI lookup
failed for the resource: Name:
[java:module/env/com.view.servlet.TestServlet/deviceStorage], Lookup:
[com.core.DeviceStorage#com.core.DeviceStorage], Type: [Session].
Caused by:
javax.naming.NameNotFoundException:
com.core.DeviceStorage#com.core.DeviceStorage not found
@Singleton
public class ServersStateListener extends Observable {
...
}
@Singleton
public class DeviceStorage implements Observer{
...
}
@WebServlet("/test")
public class TestServlet extends HttpServlet {
@EJB
private ServersStateListener serversStateListener;
@EJB
private DeviceStorage deviceStorage;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("--== Servlet ==--");
System.out.printf("ServerStateListener: %s\n", serversStateListener);
System.out.printf("DeviceStorage: %s\n", deviceStorage);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.