WildFly 12.0.0.Final JSF 2.3&f:websocket - 类加载器问题

NOT*_*iFY 2 cdi jboss-weld weld wildfly jsf-2.3

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

由于我之前的问题的答案得到了JSF 2.3的工作:

f:JSF 2.3中的websocket

然而,在将服务器端代码添加到我的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
Run Code Online (Sandbox Code Playgroud)

在EJB中使用:

@Inject
@Push
private PushContext push;
Run Code Online (Sandbox Code Playgroud)

包含在:

jboss-jsf-api_2.3_spec-2.3.3.SP1.jar
Run Code Online (Sandbox Code Playgroud)

当我添加@Inject@Push.时会发生这种情况.

WildFly 12和/或JSF 2.3中的CDI有什么问题吗?

Bal*_*usC 7

在EJB中使用:

@Inject
@Push
Run Code Online (Sandbox Code Playgroud)

您永远不应该在EJB中使用前端目标库.这样,您的EJB变得紧密耦合到JSF前端,并且对于其他前端(例如JAX-RS,JSP/Servlet等)完全无法使用.

@Push文件甚至明确提到的只有战争侧注入它.

也可以看看:


将'jboss-jsf-api_2.3_spec-2.3.3.SP1.jar'添加到我部署的EAR/JAR中:

您永远不应该向运行时类路径添加重复的类.它只会混淆类加载器.特定库已由目标运行时(WildFly)本身提供.您无需从部署中提供它.

也可以看看:


WildFly 12和/或JSF 2.3中的CDI有什么问题吗?

不适合我.OmniFaces展示目前运行WildFly 12与JSF 2.3和OmniFaces对应的@Push工作就好了.

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

在此输入图像描述

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

将所有内容保留为默认值,注入@PushWAR而不是EJB,并告诉WildFly在EE8模式下运行,一切都应该顺利.

也可以看看: