Estou começando a estudar agora o jsf e estou com problemas com para popular um combo com jsf e estou com o seguinte erro
Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectOne(id). Found null.
<h:selectOneMenu id=“id” value="#{ControleCategoria.id}">
<f:selectItems value="#{ControleCategoria.montarListaSelectItemCategortia}" />
</h:selectOneMenu>
Alguém pode me ajudar?
<?xml version="1.0" encoding="UTF-8"?>
<tx:annotation-driven/>
<import resource="hibernate-uga.xml" />
<bean id="categoriaFacade" class="business.impl.CategoriaFacade">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="controleCategoria" class="Controller.ControleCategoria" scope="session">
<property name="categoriaFacade" ref="categoriaFacade"/>
</bean>
package Controller;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.faces.model.SelectItem;
import business.InterfaceFacadeCategoria;
import domain.Categoria;
public class ControleCategoria {
public InterfaceFacadeCategoria categoriaFacade = null;
public Categoria categoria;
public List<SelectItem> listaSelectItemCategoria ;
private Integer id ;
public List<SelectItem> objs = new ArrayList<SelectItem>();
private String nome;
public void setNome(String nome) {
this.nome = nome;
}
public String getNome() {
return nome;
}
public String grava(){
Categoria categoria = new Categoria();
categoria.setCatNome(getNome());
categoriaFacade.saveUga(categoria);
return "sayBye";
}
public List<SelectItem> montarListaSelectItemCategortia() {
List<SelectItem> resultadoConsulta = consultarCategoriaPorName();
Iterator i = resultadoConsulta.iterator();
listaSelectItemCategoria.add(new SelectItem("", ""));
Categoria obj = new Categoria();
listaSelectItemCategoria.add(new SelectItem(obj.getId(), obj.getCatNome()));
return listaSelectItemCategoria;
}
public List<SelectItem> consultarCategoriaPorName() {
List<SelectItem> lista = categoriaFacade.consultarPorNameCategoria();
return lista;
}
public void setListaSelectItemCategoria(List<SelectItem> listaSelectItemCategoria) {
this.listaSelectItemCategoria = listaSelectItemCategoria;
}
public void setCategoriaFacade( InterfaceFacadeCategoria categoriaFacade) {
this.categoriaFacade = categoriaFacade;
}
public void setCategoria(Categoria categoria) {
this.categoria = categoria;
}
public Categoria getCategoria() {
return categoria;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
}
e da esse erro:
27/07/2009 13:31:27 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:uga’ did not find a matching property.
27/07/2009 13:31:27 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Java\jdk1.5.0_16\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\Java\jdk1.5.0_16\jre\bin;C:/Java/jdk1.5.0_16/bin/…/jre/bin/client;C:/Java/jdk1.5.0_16/bin/…/jre/bin;C:\gwt-windows-1.6.4;c:\cygwin\bin;C:\Java\apache-maven-2.0.9\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\ARQUIV~1\IBM\CLIENT~1;C:\ARQUIV~1\IBM\CLIENT~1\Shared;C:\ARQUIV~1\IBM\CLIENT~1\Emulator;C:\Java\jdk1.5.0_16\bin;C:\Java\jdk1.5.0_16\lib;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Java\apache-ant-1.7.1/bin;C:\Java\svn-win32-1.5.2\bin;C:\Arquivos de programas\TortoiseSVN\bin;C:\Java\jdk1.5.0_16
27/07/2009 13:31:27 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
27/07/2009 13:31:27 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 944 ms
27/07/2009 13:31:27 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
27/07/2009 13:31:27 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
27/07/2009 13:31:29 com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra (1.2_12-b01-FCS) for context '/uga’
log4j:WARN No appenders could be found for logger (org.ajax4jsf.renderkit.ChameleonRenderKitFactory).
log4j:WARN Please initialize the log4j system properly.
27/07/2009 13:31:34 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
27/07/2009 13:31:41 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
27/07/2009 13:31:41 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
27/07/2009 13:31:41 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/63 config=null
27/07/2009 13:31:41 org.apache.catalina.startup.Catalina start
INFO: Server startup in 14758 ms
27/07/2009 13:32:56 com.sun.faces.renderkit.html_basic.HtmlBasicRenderer getForComponent
WARNING: Unable to find component with ID promptName in view.
27/07/2009 13:32:56 com.sun.faces.lifecycle.Phase doPhase
SEVERE: JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /greeting.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@164da25]
27/07/2009 13:32:56 org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet FacesServlet threw exception
java.lang.IllegalArgumentException: Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectOne(id). Found null.
at com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:326)
at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:814)
at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:280)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:242)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:180)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:127)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:266)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:197)
at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:696)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:667)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:97)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
27/07/2009 13:32:56 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.IllegalArgumentException: Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectOne(id). Found null.
at com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:326)
at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:814)
at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:280)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:242)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:180)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:127)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:266)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:197)
at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:696)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:667)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:97)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
Se alguém puder me ajudar