【发布时间】:2019-07-22 11:51:40
【问题描述】:
我是 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);
}
}
【问题讨论】:
标签: java ejb jndi enterprise