java - GlassFish 5 上的 JNDI 查找失败
问题描述
我是 Java EE 的新手,我的问题可能看起来很愚蠢。
当我javax.naming.NameNotFoundException
尝试在 Glassfish 上部署我的应用程序时,我有。当我在 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);
}
}
解决方案
推荐阅读
- php - 开发一个 php 页面并被重定向到 web 而不是 localhost?
- json - 为什么生成的 JSON 被截断?
- php - 在 Laravel 5.5 中通过 CURL 发布和接收
- json - 在 Azure 逻辑应用中解析具有多行相同 JSON 代码的文件
- r - 如何在 Shiny 书签中排除参数?
- ruby-on-rails - 仅在生产中,Sidekiq 启动延迟作业但不发送电子邮件
- node.js - Firestore 调用需要(平均)100/200 毫秒,对于对话流响应超时
- git - 是否可以为现有配置指定新的本地 git 存储库位置?
- css - 根据文本方向属性提供不同的 SCSS 文件
- java - 如何将 else false 添加到布尔方法