Primefaces 扩展 11 错误 [...] monacoeditor.EditorOptions 不存在

Primefaces Extension 11 error [...] monacoeditor.EditorOptions not present

运行 primefaces-extensions 时出现严重错误。从消息中可以看出 EditorOptions 不存在:

SEVERE: java.lang.TypeNotPresentException: Type org.primefaces.extensions.model.monacoeditor.EditorOptions not present.

日志:

INFORMAÇÕES:   Loading application compras done in 17.059 ms
INFORMAÇÕES:   Using OmniFaces version 3.13
INFORMAÇÕES:   Registering WebSocket filter for url pattern /*
INFORMAÇÕES:   Initializing Soteria 1.1-b01.payara-p5 for context '/compras'
INFORMAÇÕES:   Inicializando Mojarra |version.string| para o contexto '/compras'
GRAVE:   java.lang.TypeNotPresentException: Type org.primefaces.extensions.model.monacoeditor.EditorOptions not present
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
    at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
    at sun.reflect.generics.repository.ClassRepository.getSuperclass(ClassRepository.java:90)
    at java.lang.Class.getGenericSuperclass(Class.java:777)
    at org.jboss.weld.util.reflection.HierarchyDiscovery.discoverFromClass(HierarchyDiscovery.java:139)
    at org.jboss.weld.util.reflection.HierarchyDiscovery.discoverTypes(HierarchyDiscovery.java:132)
    at org.jboss.weld.util.reflection.HierarchyDiscovery.discoverFromClass(HierarchyDiscovery.java:139)
    at org.jboss.weld.util.reflection.HierarchyDiscovery.discoverTypes(HierarchyDiscovery.java:113)
    at org.jboss.weld.util.reflection.HierarchyDiscovery.<init>(HierarchyDiscovery.java:94)
    at org.jboss.weld.util.reflection.HierarchyDiscovery.<init>(HierarchyDiscovery.java:87)
    at org.jboss.weld.annotated.enhanced.TypeClosureLazyValueHolder.computeValue(TypeClosureLazyValueHolder.java:41)
    at org.jboss.weld.annotated.enhanced.TypeClosureLazyValueHolder.computeValue(TypeClosureLazyValueHolder.java:31)
    at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:46)
    at org.jboss.weld.annotated.slim.backed.BackedAnnotated.getTypeClosure(BackedAnnotated.java:27)
    at org.jboss.weld.annotated.AnnotatedTypeValidator.validateAnnotated(AnnotatedTypeValidator.java:44)
    at org.jboss.weld.annotated.AnnotatedTypeValidator.validateAnnotatedType(AnnotatedTypeValidator.java:62)
    at org.jboss.weld.manager.BeanManagerImpl.getInjectionTargetFactory(BeanManagerImpl.java:1503)
    at org.jboss.weld.manager.BeanManagerImpl.createInjectionTarget(BeanManagerImpl.java:1019)
    at org.glassfish.weld.services.JCDIServiceImpl.injectManagedObject(JCDIServiceImpl.java:357)
    at org.glassfish.faces.integration.GlassFishInjectionProvider.inject(GlassFishInjectionProvider.java:203)
    at com.sun.faces.config.processor.AbstractConfigProcessor.createInstance(AbstractConfigProcessor.java:233)
    at com.sun.faces.config.processor.AbstractConfigProcessor.createInstance(AbstractConfigProcessor.java:199)
    at com.sun.faces.config.processor.RenderKitConfigProcessor.addRenderers(RenderKitConfigProcessor.java:291)
    at com.sun.faces.config.processor.RenderKitConfigProcessor.process(RenderKitConfigProcessor.java:167)
    at com.sun.faces.config.ConfigManager.lambda$initialize(ConfigManager.java:341)
    at java.util.Iterator.forEachRemaining(Iterator.java:116)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:318)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:206)
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:5178)
    at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:681)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5756)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:619)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:958)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:941)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1851)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1603)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:107)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:123)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:292)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:361)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.initialize(ApplicationLifecycle.java:623)
    at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:335)
    at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:303)
    at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:351)
    at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:463)
    at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:281)
    at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:65)
    at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2102)
    at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:93)
    at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:67)
    at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:1213)
    at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:1144)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.primefaces.extensions.model.monacoeditor.EditorOptions
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1819)
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1660)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
    ... 61 more

INFORMAÇÕES:   Running on PrimeFaces 11.0.0
INFORMAÇÕES:   Running on PrimeFaces Extensions 11.0.2

有没有人已经找到解决这个问题的方法?

Primefaces 11,Primefaces 扩展 11.0.2,Mojarra 2.3.14,Payara 5.2021.10。

这是由于 Payara 扫描 classes 的方式所致。出于某些奇怪的原因,Payara 似乎 class 加载其他容器(例如 Jboss Wildfly)不加载的地方,因此没有这个问题。

查看问题:https://github.com/primefaces-extensions/primefaces-extensions/issues/718

有一个简单的解决方案...只需在您的 pom.xml 中包含 Monaco 扩展,然后 Payara 就会很高兴。

<dependency>
   <groupId>org.primefaces.extensions</groupId>
   <artifactId>resources-monacoeditor</artifactId>
   <version>11.0.2</version>
</dependency>

那会让Payara重新愉快地工作。