Netbeans12+Glassfish5.1。简单jsf,CDI(JavaEE8)程序引发RuntimeException

Netbeans12+Glassfish5.1. Simple jsf,CDI(JavaEE8) program causes RuntimeException

我在 NB 中创建了项目“Java EE Web 应用程序”。
新项目 -> Java With Ant -> Java Web -> Web Application.

部署后,我访问这个包含#{mainBB.number}的简单网页,然后出现异常。如果我打错了像 {mBB.number} 这样的 bean 名称,网页显示时没有编号。

这是 GF 日志消息。网络“+堆栈跟踪”消息在 Firefox 上几乎是这样的。

错误消息

  JSF1073: RENDER_RESPONSE 6 の処理中に java.lang.RuntimeException をキャッチしました: UIComponent の ClientId =、メッセージ =|#]
  java.lang.RuntimeException: 
    at beans.MainBB.<init>(MainBB.java:1)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

我认为某些库不匹配是在启动 bean 控制器或初始化此 class 时在 el.parser 引起的。

信息

JSF 2.3:javax.faces.jar
Java EE 7 API 库

环境

win10
(a) 异常:GlassFish5.1(JavaEE8), NB 12.0(JDK 1.8, JavaEE8)
以后我想用 JakartaEE9

我试过的。

...没有任何变化。

・ jsf 检查(检查 import javax.enterprise.* ,检查 bean 的错别字)
・ 检查source(@Named, @~~Scoped, setter/getter, constructor)
・ 检查图书馆
・ 再次阅读jsf 2.3网页

・追加配置 beans.xml, faces.config-xml, web.xml

Activating CDI in JSF 2.3
@FacesConfig 注释 class 以在 JSF 2.3

中激活 CDI

WEB-INF/beans.xml
version="1.1" bean-discovery-mode="all"

在 WEB-INF/faces-config.xml
设置版本 2.3

web.xml
设置 javax.faces.ENABLE_CDI_RESOLVER_CHAIN 真

来源
设置@FacesConfig 2.3

・ 添加jsf库,cdi(1.2, 2.0)库,java el库

・其他版本
NG: (a) + GF6.0m1, (a) + wildfly 20.0.1 final, (a) + Payara ml 5.2020.4
好的:(b)GlassFish4.1(JavaEE8),NB 8.2(JDK 1.7,JavaEE7)

来源

 <?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>  
        <div>content #{mainBB.number}</div>
    </h:body>
</html>

java

package beans;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

@Named 
@RequestScoped
public class MainBB  {

    private Integer number =631223;
    private String name = "fjkdfdaa;";
    
    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
       
}

您可以从这里获取源代码(JP)。
"projects.zip『1章、3~18章の例题プロジェクト" link
https://k-webs.jp/JavaEE/download/projects.zip 样本 02

https://k-webs.jp/JavaEE/index.html

消息

  JSF1073: RENDER_RESPONSE 6 の処理中に java.lang.RuntimeException をキャッチしました: UIComponent の ClientId =、メッセージ =|#]
  java.lang.RuntimeException: 
    at beans.MainBB.<init>(MainBB.java:1)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:119)
    at org.jboss.weld.injection.ConstructorInjectionPoint.invokeAroundConstructCallbacks(ConstructorInjectionPoint.java:92)
    at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:78)
    at org.jboss.weld.injection.producer.AbstractInstantiator.newInstance(AbstractInstantiator.java:28)
    at org.jboss.weld.injection.producer.BasicInjectionTarget.produce(BasicInjectionTarget.java:112)
    at org.jboss.weld.injection.producer.BeanInjectionTarget.produce(BeanInjectionTarget.java:180)
    at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:158)
    at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
    at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
    at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.get(ContextualInstanceStrategy.java:177)
    at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:676)
    at org.jboss.weld.module.web.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107)
    at org.jboss.weld.module.web.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:90)
    at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:147)
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:156)
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:184)
    at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:92)
    at com.sun.el.parser.AstValue.getBase(AstValue.java:126)
    at com.sun.el.parser.AstValue.getValue(AstValue.java:175)
    at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:202)
    at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
    at com.sun.faces.facelets.el.ELText$ELTextVariable.writeText(ELText.java:216)
    at com.sun.faces.facelets.el.ELText$ELTextComposite.writeText(ELText.java:123)
    at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:44)
    at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:41)
    at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:169)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:468)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:170)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:132)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:102)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:199)
    at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:708)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1540)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:297)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
    at org.glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:282)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:215)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:119)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:550)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:75)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:114)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:199)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:439)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
    at org.glassfish.grizzly.filterchain.ExecutorResolver.execute(ExecutorResolver.java:95)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:515)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access0(WorkerThreadIOStrategy.java:33)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
    at java.lang.Thread.run(Thread.java:748)
|#]

我错过了什么? (o.o)
我该怎么办...

谢谢 BalusC。

有效!
3 周!

我从 NB 页面更新了“nb-javac 的 3 个插件”并重新启动 IDE。
然后我的程序工作了!!
("JAVA_HOME & PATH" 仍然是 JDK1.8)

※ 第一次,
注意在 IDE window.
的底部告诉我一个警告和信息(大约 nb-javac) 但我无法从 tool -> plugin 安装,所以我保持原样.... 我学会了。 (^^;)>