5 Replies Latest reply on Aug 26, 2008 3:23 PM by moumen rajae

    Could not instantiate seam components

    moumen rajae Newbie

      Hi every body ,i'm trying to merge a table from database to a datatable,i actually made it but i don't know where i touched and it doesn't work anymore,could please help me
      here is following stack trace



      org.jboss.seam.InstantiationException: Could not instantiate Seam component: userssearch
           at org.jboss.seam.Component.newInstance(Component.java:1986)
           at org.jboss.seam.Component.getInstance(Component.java:1876)
           at org.jboss.seam.Component.getInstan
      ce(Component.java:1843)
           at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
           at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
           at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:166)
           at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:53)
           at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
           at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
           at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
           at org.jboss.el.parser.AstValue.getValue(AstValue.java:63)
           at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
           at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
           at javax.faces.component.UIOutput.getValue(UIOutput.java:173)
           at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:189)
           at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:320)
           at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:200)
           at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:896)
           at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
           at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
           at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
           at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:199)
           at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:194)
           at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
           at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
           at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
           at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
           at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Unknown Source)
      Caused by: javax.naming.NameNotFoundException: UtilisateursAction not bound
           at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
           at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
           at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
           at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
           at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
           at javax.naming.InitialContext.lookup(Unknown Source)
           at org.jboss.seam.Component.instantiateSessionBean(Component.java:1290)
           at org.jboss.seam.Component.instantiate(Component.java:1276)
           at org.jboss.seam.Component.newInstance(Component.java:1970)
           ... 75 more



      this is my employee.xhtml



      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:a="http://richfaces.org/a4j"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:rich="http://richfaces.org/rich"
                template="layout/template.xhtml">
      
                <ui:define name="body">
      
                     <div class="menu"><h:form>
                          <h:commandButton  value="Demandes" ></h:commandButton>
                          <h:commandButton value="Envoyer requete" ></h:commandButton>
                          <h:commandButton value="Utilisateurs"></h:commandButton>
                     </h:form></div>
                     <h:messages styleClass="message" />
      
                     <h:form id="admin">
      
      <rich:panel>
         <f:facet name="header">Administration</f:facet>
                          
        <div class="section">
        <h1>Chercher un utilisateur</h1>
      
           <h:form id="searchCriteria">
           <fieldset> 
              <h:inputText id="searchString" value="#{userssearch.searchString}" style="width: 165px;">
               <a:support id="onkeyup" event="onkeyup" actionListener="#{userssearch.find}" reRender="searchResults" />
             </h:inputText>
             &#160;
              <a:commandButton id="findUsers" value="Chercher utilisateur" action="#{userssearch.find}" reRender="searchResults"/>
             &#160;
             <a:status id="status">
                <f:facet id="StartStatus" name="start">
                   <h:graphicImage id="SpinnerGif" value="/img/spinner.gif"/>
                </f:facet>
             </a:status>
              <br/>
             <h:outputLabel id="MaximumResultsLabel" for="pageSize">Maximum results:</h:outputLabel>&#160;
             <h:selectOneMenu id="pageSize" value="#{userssearch.pageSize}">
                <f:selectItem id="PageSize5" itemLabel="5" itemValue="5"/>
                <f:selectItem id="PageSize10" itemLabel="10" itemValue="10"/>
                <f:selectItem id="PageSize20" itemLabel="20" itemValue="20"/>
             </h:selectOneMenu>
          </fieldset>
          </h:form>
          
      </div>
      
      <a:outputPanel id="searchResults">
        <div class="section">
           <h:outputText id="NousersFoundMessage" value="Aucun utilisateur trouve" rendered="#{users != null and users.rowCount==0}"/>
           <h:dataTable id="users" value="#{users}" var="hot" rendered="#{users.rowCount>0}">
                <h:column id="column1">
                     <f:facet id="NameFacet" name="header" >Username</f:facet>
                     #{hot.username}
                </h:column>
                <h:column id="column2">
                     <f:facet id="AddressFacet" name="header" >name</f:facet>
                     #{hot.name}
                </h:column>
                <h:column id="column3">
                     <f:facet id="passwordFacet" name="header" >Password</f:facet>
                     #{hot.password}
                </h:column> 
                <h:column id="column4">
                     <f:facet id="mailFacet" name="header" >Mail</f:facet>
                     #{hot.mail}
                </h:column>
                
           </h:dataTable>
           <s:link id="MoreResultsLink" value="More results" action="#{userssearch.nextPage}" rendered="#{usersearch.nextPageAvailable}"/>
        </div>
      </a:outputPanel>
      
      
          </rich:panel>
      
                       </h:form>
      
                </ui:define>
      </ui:composition>



      UtilisateursAction.java



      //
      package com.bean.workflow;
      
      import java.util.List;
      
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Factory;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.datamodel.DataModel;
      import org.jboss.seam.annotations.security.Restrict;
      
      @Stateful
      @Name("userssearch")
      @Scope(ScopeType.SESSION)
      @Restrict("#{identity.loggedIn}")
      public class UtilisateursAction implements Utilisateurs
      {
         
         @PersistenceContext
         private EntityManager em;
         
         private String searchString;
         private int pageSize = 10;
         private int page;
         private boolean nextPageAvailable = false;
         
         @DataModel
         private List<User> users;
         
         public void find()
         {
            page = 0;
            queryUsers();
         }
         public void nextPage()
         {
            page++;
            queryUsers();
         }
            
         private void queryUsers()
         {
             List<User> results = em.createQuery("select u from User u where lower(a.name) like #{pattern} or lower(a.username) like #{pattern} or lower(a.mail) like #{pattern}")
                 .setMaxResults(pageSize+1)
                 .setFirstResult( page * pageSize )
                 .getResultList();
      
      
             nextPageAvailable = results.size() > pageSize;
             if (nextPageAvailable) {
                 users = results.subList(0,pageSize);
             } else {
                 users = results;
             }
         }
         
         public boolean isNextPageAvailable()
         {
             return nextPageAvailable;
         }
         
         public int getPageSize() {
            return pageSize;
         }
         
         public void setPageSize(int pageSize) {
            this.pageSize = pageSize;
         }
         
         @Factory(value="pattern", scope=ScopeType.EVENT)
         public String getSearchPattern()
         {
            return searchString==null ? 
                  "%" : '%' + searchString.toLowerCase().replace('*', '%') + '%';
         }
         
         public String getSearchString()
         {
            return searchString;
         }
         
         public void setSearchString(String searchString)
         {
            this.searchString = searchString;
         }
         
         @Remove
         public void destroy() {}
      }



      thanks for your help