0

我在 NB 中制作了项目“Java EE Web 应用程序”。
新项目 -> Java With Ant -> Java Web -> Web 应用程序。

部署后,我访问它包含的这个简单的网页 #{mainBB.number},然后是异常原因。如果我输入像 {mBB.number} 这样的 bean 名称,则网页显示时没有数字。

这是 GF 日志消息。和 web "+ stack trace" msg 在 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 控制器或初始化此类时,el.parser 会导致一些库不匹配。

信息

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

环境

win10
(a) NG: GlassFish5.1(JavaEE8) , NB 12.0(JDK 1.8, JavaEE8)
以后想用JakartaEE9做

我试过了。

... 没变化。

・ jsf 检查(检查 import javax.enterprise.* ,检查 bean 的错字)
・ 检查源代码(@Named,@~~Scoped,setter/getter,构造函数)
・ 检查库
・ 再次阅读 jsf 2.3 网页
jsf - 识别和解决javax.el.PropertyNotFoundException:目标无法到达 - 堆栈溢出
jsf - 将 faces-config.xml 从 2.2 更改为 2.3 会导致 javax.el.PropertyNotFoundException:目标无法到达,标识符“bean”解析为 null - 代码日志

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

在 JSF 2.3 中激活 CDI
@FacesConfig 注释类以在 JSF 2.3 中激活 CDI

WEB-INF/beans.xml
版本="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
OK: (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>

爪哇

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 章の例题プロジェクト”链接
https://k-webs.jp/JavaEE/index中 sample02

https://k-webs.jp/JavaEE/download/projects.zip。 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$9.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.access$100(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)
|#]

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

4

1 回答 1

0

谢谢BalusC。

有用!
3周!

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

※ 第一次,
NB在IDE窗口底部通知我一个警告和信息(关于nb-javac)。
但我无法从 tool -> plugin 安装,所以我保持原样......我学会了。(^^;)>

于 2020-09-26T14:19:16.290 回答