gpt4 book ai didi

WildFly 12.0.0.Final JSF 2.3 & f :websocket - Class loader issue

转载 作者:行者123 更新时间:2023-12-02 06:48:57 25 4
gpt4 key购买 nike

尝试让 EJB 在文档(行)插入 MongoDB 集合时通知我的 XHTML JSF 页面。

由于对我之前问题的回答,JSF 2.3 可以正常工作:

f:websocket in JSF 2.3

然而,在将服务器端代码添加到我的 EJB 并尝试将我的 EAR 部署到 WildFly 12.0.0.Final 之后,我得到了 PushContext 的 java.lang.ClassNotFoundException:

Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class com.notifywell.ejb.FoodsCosmeticsMedicinesEJB with ClassLoader ModuleClassLoader for Module "deployment.NOTiFYwell.ear.NOTiFYwellJAR.jar" from Service Module Loader

at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:72)
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70)
... 13 more
Caused by: java.lang.ClassNotFoundException: javax.faces.push.PushContext from [Module "deployment.NOTiFYwell.ear.NOTiFYwellJAR.jar" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:199)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
... 18 more

在 EJB 中使用:

@Inject
@Push
private PushContext push;

包含在:

jboss-jsf-api_2.3_spec-2.3.3.SP1.jar

当我将 @Inject 添加到 @Push 时会发生这种情况。

WildFly 12 和/或 JSF 2.3 中的 CDI 有任何问题吗?

最佳答案

used in EJB:

@Inject
@Push

永远不要在 EJB 中使用面向前端的库。通过这种方式,您的 EJB 将与 JSF 前端紧密耦合,并且完全无法再用于其他前端,例如 JAX-RS、JSP/Servlet 等。

@Push 文档甚至 explicitly提到只在 WAR 端注入(inject)它。

另见:


add the 'jboss-jsf-api_2.3_spec-2.3.3.SP1.jar' to my deployed EAR/JAR:

您永远不应该将重复的类添加到运行时类路径中。它只会混淆类加载器。目标运行时 (WildFly) 本身已经提供了特定的库。您不需要从部署开始就提供它。

另见:


Any issues with CDI in WildFly 12 and/or JSF 2.3?

不适合我。 The OmniFaces showcase目前使用 JSF 2.3 运行 WildFly 12,并且 @Push 的 OmniFaces 副本工作得很好。

你只需要记住explicitly当您打算在其上使用 JSF 2.3 时,指示 WildFly 12 使用 standalone-ee8.xml。在 IDE 中使用时也是如此。在 Eclipse 中,创建服务器时,您可以在新建服务器向导的配置文件条目中指定,默认为standalone.xml

enter image description here

如果您仍然面临类加载问题,那么这只能意味着您以其他方式弄乱了运行时类路径。这可能有更多的原因,这些原因在目前提供的信息中是看不到的。对于像你这样在类路径问题的问题中没有立即提及类路径配置的初学者(因此表明对此一无所知),最好不要乱搞运行时类路径(或“构建路径”和“库”就像在普通 IDE 中调用的那样),直到你理解它。默认情况下,Java EE 已经提供了一切开箱即用的功能,绝对不需要调整项目中的库。

保留所有默认值,在 WAR 而不是 EJB 中注入(inject) @Push 并告诉 WildFly 在 EE8 模式下运行,一切都会顺利进行。

另见:

关于WildFly 12.0.0.Final JSF 2.3 & f :websocket - Class loader issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49859918/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com