繁体   English   中英

在GlassFish 5上JNDI查找失败

[英]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);

    }
}

GlassFish中存在一个错误,该错误导致了这样的错误消息。 该错误已于2018年2月在Payara(派生自GlassFish)中发现并修复,并包含在发行版5.182中。 我不知道它是否已在GlassFish中修复。 可在此处找到Payara错误报告,并在此处提交了修复程序。

该错误报告提到以下属性(JVM选项)可以用作解决方法:

-Ddeployment.resource.validation=false

我不确定该设置是否也适用于GlassFish,还是特定于Payara。 但这当然值得一试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM