Liberty Profile - 远程 EJB

Liberty Profile - Remote EJB

我正在尝试从我的应用程序调用远程 ejb,但出现错误

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.RuntimeException: javax.naming.NameNotFoundException: CNTR4009E: The edu.osu.cse5234.ooth.business.view.InventoryService remote interface for the InventoryServiceBean enterprise bean in the OutOfTheHouse-EJB.jar module in the OutOfTheHouse-EJBEAR application could not be obtained for the java:global/OutOfTheHouse-EJBEAR/OutOfTheHouse-EJB/InventoryServiceBean!edu.osu.cse5234.ooth.business.view.InventoryService JNDI name because remote interfaces are not supported by any of the features configured in the server.xml file.

我发现我们需要添加

<featureManager>
    <feature>ejbRemote-3.2</feature>
    <feature>localConnector-1.0</feature>
</featureManager>

但是我没有在我的 server.xml 中添加 ejbRemote 的选项。 可能是什么原因?

打开 server.xml,在设计模式(相对于源代码模式)下查看,展开服务器配置并单击功能管理器。右侧将列出功能管理器的详细信息。单击添加。添加以下功能:

ejblite-3.2 javaee-7.0 jndi-1.0 本地连接器-1.0

此外,请确保将 EAR 项目添加到 WAS 自由配置文件中。将控制台日志级别提高到 INFO(服务器管理器 --> 添加 --> 日志记录,然后在详细信息 window 中编辑控制台日志级别)。控制台输出将吐出与容器生成的 JNDI 名称完全相同的名称。复制粘贴到 ServiceLocator 代码中。

  • 普拉文

问题出在我使用的 liberty profile 版本上。我使用了一个不同的,我能够添加 javaee-7.0 作为功能,然后它工作正常。

我在启用功能 "webProfile-7.0" 或 "javaee-7.0" 后立即收到此错误。这些特性加载了其他特性,并且其中之一似乎阻止了 EJB 的绑定。在这种情况下,也没有包含 JNDI 名称的日志条目。为了解决这个问题,我只启用了我真正需要的功能(在我的例子中是 servlet-3.1、localConnector-1.0、ejbLite-3.2、ejbRemote-3.2、jsp-2.3)。这也加快了服务器启动速度。