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

425 views Asked by At

I made project "Java EE Web Application" in NB.
new project -> Java With Ant -> Java Web -> Web Application.

After deploying, I access this simple web page it incluludes #{mainBB.number}, then exception causes. If I typo bean name like {mBB.number}, web page is shown without number.

This is GF log message. and web "+ stack trace" msg is alomst like this on firefox.

error msg

  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)

I think some library mismatch was caused at el.parser when launched bean controller or initialized this class .

info

lib

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

env

win10
(a) NG: GlassFish5.1(JavaEE8) , NB 12.0(JDK 1.8, JavaEE8)
In the future I want to make with JakartaEE9

What I tried.

... nothing change.

・ jsf check(check import javax.enterprise.* , check typo at bean)
・ check source(@Named, @~~Scoped, setter/getter, constructor)
・ check library
・ read jsf 2.3 web page again
jsf - Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable - Stack Overflow
jsf - Changing faces-config.xml from 2.2 to 2.3 causes javax.el.PropertyNotFoundException: Target Unreachable, identifier 'bean' resolved to null - Stack Overflow

・ append and config beans.xml, faces.config-xml, web.xml

Activating CDI in JSF 2.3
@FacesConfig annotated class to activate CDI in JSF 2.3

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

at WEB-INF/faces-config.xml
set version 2.3

web.xml
set javax.faces.ENABLE_CDI_RESOLVER_CHAIN true

at source
set @FacesConfig 2.3

・ add jsf library, cdi(1.2, 2.0) library , java el library

・ other version
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)

source

 <?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;
    }
       
}

You can get source from here(JP).
"projects.zip 1章、3~18章の例題プロジェクト" link
https://k-webs.jp/JavaEE/download/projects.zip of sample02
in
https://k-webs.jp/JavaEE/index.html

msg

  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)
|#]

What am I missing? (o.o)
What should I do...

1

There are 1 answers

3
naturallucky On BEST ANSWER

Thank you BalusC.

It works!
3 weeks!

I update "3 plugin of nb-javac " from NB page and relaunch IDE.
Then my program work!!
("JAVA_HOME & PATH" remains JDK1.8)

※ At first time,
NB informed me one warning and infomation(it is about nb-javac) at bottom of IDE window.
but I coundn't install from tool -> plugin , so I left it as it was.... I'v learned. (^^;)>