jsf - CDI Inject Alternatives {identifier not found} -
i checked other posts nil seems solve trivial issue. hope can help me. created j2ee application netbeans 8.0.1 , glassfish 4.1. have input.xhtml , show.xhtml file. (both facelets , utilize template.xthml). in add-on i've got welcome bean using 1 of 2 implementations (hellogreeting or howdygreeting) interface greeting. since added sec implementation howdygreeting got error message shown below.
that's glassfish serverlog:
fatal: jsf1073: javax.faces.facesexception caught during processing of process_validations 3 : uicomponent-clientid=, message=/input.xhtml @14,102 value="#{welcome.name}": target unreachable, identifier 'welcome' resolved null fatal: /input.xhtml @14,102 value="#{welcome.name}": target unreachable, identifier 'welcome' resolved null javax.faces.facesexception: /input.xhtml @14,102 value="#{welcome.name}": target unreachable, identifier 'welcome' resolved null @ com.sun.faces.lifecycle.processvalidationsphase.execute(processvalidationsphase.java:84) @ com.sun.faces.lifecycle.phase.dophase(phase.java:101) @ com.sun.faces.lifecycle.lifecycleimpl.execute(lifecycleimpl.java:198) @ javax.faces.webapp.facesservlet.service(facesservlet.java:646) @ org.apache.catalina.core.standardwrapper.service(standardwrapper.java:1682) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:318) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:160) @ org.apache.catalina.core.standardpipeline.doinvoke(standardpipeline.java:734) @ org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:673) @ com.sun.enterprise.web.webpipeline.invoke(webpipeline.java:99) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:174) @ org.apache.catalina.connector.coyoteadapter.doservice(coyoteadapter.java:357) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:260) @ com.sun.enterprise.v3.services.impl.containermapper.service(containermapper.java:188) @ org.glassfish.grizzly.http.server.httphandler.runservice(httphandler.java:191) @ org.glassfish.grizzly.http.server.httphandler.dohandle(httphandler.java:168) @ org.glassfish.grizzly.http.server.httpserverfilter.handleread(httpserverfilter.java:189) @ org.glassfish.grizzly.filterchain.executorresolver$9.execute(executorresolver.java:119) @ org.glassfish.grizzly.filterchain.defaultfilterchain.executefilter(defaultfilterchain.java:288) @ org.glassfish.grizzly.filterchain.defaultfilterchain.executechainpart(defaultfilterchain.java:206) @ org.glassfish.grizzly.filterchain.defaultfilterchain.execute(defaultfilterchain.java:136) @ org.glassfish.grizzly.filterchain.defaultfilterchain.process(defaultfilterchain.java:114) @ org.glassfish.grizzly.processorexecutor.execute(processorexecutor.java:77) @ org.glassfish.grizzly.nio.transport.tcpniotransport.fireioevent(tcpniotransport.java:838) @ org.glassfish.grizzly.strategies.abstractiostrategy.fireioevent(abstractiostrategy.java:113) @ org.glassfish.grizzly.strategies.workerthreadiostrategy.run0(workerthreadiostrategy.java:115) @ org.glassfish.grizzly.strategies.workerthreadiostrategy.access$100(workerthreadiostrategy.java:55) @ org.glassfish.grizzly.strategies.workerthreadiostrategy$workerthreadrunnable.run(workerthreadiostrategy.java:135) @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.dowork(abstractthreadpool.java:564) @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.run(abstractthreadpool.java:544) @ java.lang.thread.run(thread.java:745) caused by: javax.el.propertynotfoundexception: /input.xhtml @14,102 value="#{welcome.name}": target unreachable, identifier 'welcome' resolved null @ com.sun.faces.facelets.el.tagvalueexpression.gettype(tagvalueexpression.java:100) @ com.sun.faces.renderkit.html_basic.htmlbasicinputrenderer.getconvertedvalue(htmlbasicinputrenderer.java:95) @ javax.faces.component.uiinput.getconvertedvalue(uiinput.java:1046) @ javax.faces.component.uiinput.validate(uiinput.java:976) @ javax.faces.component.uiinput.executevalidate(uiinput.java:1249) @ javax.faces.component.uiinput.processvalidators(uiinput.java:712) @ javax.faces.component.uicomponentbase.processvalidators(uicomponentbase.java:1261) @ javax.faces.component.uiform.processvalidators(uiform.java:253) @ javax.faces.component.uicomponentbase.processvalidators(uicomponentbase.java:1261) @ javax.faces.component.uicomponentbase.processvalidators(uicomponentbase.java:1261) @ javax.faces.component.uiviewroot.processvalidators(uiviewroot.java:1195) @ com.sun.faces.lifecycle.processvalidationsphase.execute(processvalidationsphase.java:76) ... 30 more caused by: javax.el.propertynotfoundexception: target unreachable, identifier 'welcome' resolved null @ com.sun.el.parser.astvalue.gettarget(astvalue.java:174) @ com.sun.el.parser.astvalue.gettype(astvalue.java:86) @ com.sun.el.valueexpressionimpl.gettype(valueexpressionimpl.java:201) @ com.sun.faces.facelets.el.tagvalueexpression.gettype(tagvalueexpression.java:98) ... 41 more
template.xhtml:
<?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:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html"> <h:head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <h:outputstylesheet name="./css/default.css"/> <h:outputstylesheet name="./css/csslayout.css"/> <title>facelets template</title> </h:head> <h:body> <div id="top"> <ui:insert name="top"><h1>super cool app</h1></ui:insert> </div> <div id="content" class="center_content"> <ui:insert name="content">content</ui:insert> </div> <div id="bottom"> <ui:insert name="bottom"><br/><br/>powered glassfish & netbeans</ui:insert> </div> </h:body> </html>
these 2 facelet clients (input , show):
input.xhtml:
<?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:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html"> <body> <ui:composition template="./web-inf/templates/template.xhtml"> <ui:define name="content"> <h:form> <h:panelgrid columns="3"> <h:outputtext value="name:"/> <h:inputtext value="#{welcome.name}" title="name" id="name" required="true"/> <h:message for="name" style="color: red"/> </h:panelgrid> <h:commandbutton action="show" value="submit"/> </h:form> </ui:define> </ui:composition> </body> </html>
show.xhtml:
<?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:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html"> <body> <ui:composition template="./web-inf/templates/template.xhtml"> <ui:define name="content"> <h:outputtext value="#{welcome.message}"/> </ui:define> </ui:composition> </body> </html>
beans.xml:
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="all"> <alternatives> <class>impl.hellogreeting</class> </alternatives> </beans>
welcome.java:
package beans; //import javax.faces.bean.managedbean; import javax.enterprise.context.requestscoped; import javax.inject.inject; import javax.inject.named; /** * @author kolling, denny */ @named @requestscoped public class welcome{ private string name; private string message; @inject greeting greeting; public string getmessage(){ homecoming greeting.greet(name); } public void setmessage(string message){ this.message = message; } public string getname(){ homecoming name; } public void setname(string name){ this.name = name; } }
greeting.java interface:
package beans; /** * @author kolling, denny */ public interface greeting { public string greet(string name); }
hellogreeting impl.:
package impl; import beans.greeting; import javax.enterprise.inject.alternative; /** * @author kolling, denny */ @alternative public class hellogreeting implements greeting{ @override public string greet(string name) { homecoming "hello " + name; } }
howdygreeting.java impl.:
package impl; import beans.greeting; import javax.enterprise.inject.alternative; /** * @author kolling, denny */ @alternative public class howdygreeting implements greeting{ @override public string greet(string name) { homecoming "howdy " + name; } }
web.xml:
<?xml version="1.0" encoding="utf-8"?> <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> <context-param> <param-name>javax.faces.project_stage</param-name> <param-value>development</param-value> </context-param> <servlet> <servlet-name>faces servlet</servlet-name> <servlet-class>javax.faces.webapp.facesservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>faces servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>faces/index.xhtml</welcome-file> </welcome-file-list> </web-app>
seems stacktrace indicates welcome
<h:inputtext value="#{welcome.name}" title="name" id="name" required="true"/>
not found.
try replace :
@named
by :
@named("welcome")
in welcome.java
bean.
you can seek specify @default
annotation 1 of @alternative
implementation.
see : http://docs.oracle.com/javaee/6/tutorial/doc/gjsdf.html (specialization)
jsf java-ee ejb cdi glassfish-4
No comments:
Post a Comment