3 Replies Latest reply on Jul 4, 2008 1:14 AM by Ariel T

    InstantiationException: Could not instantiate Seam component

    Ariel T Newbie

      I get this exception I don't know how to solve. I am pretty sure it is a dumb mistake, but I can't see it.


      I get the same error extending EntityQuery too.


      Any ideas?


      TIA.


      -Ariel


      Exception


      javax.faces.FacesException: org.jboss.seam.InstantiationException: Could not instantiate Seam component: paisesManager
              at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:240)
              at org.jboss.seam.jsf.SeamApplication.createComponent(SeamApplication.java:327)
              at com.sun.facelets.tag.jsf.ComponentHandler.createComponent(ComponentHandler.java:224)
              at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:139)
              at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
              at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)
              at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)
              at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
              at com.sun.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:64)
              at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:131)
              at com.sun.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:310)
              at com.sun.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:280)
              at com.sun.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:68)
              at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
              at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
              at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
              at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
              at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:248)
              at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:294)
              at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:273)
              at com.sun.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:144)
              at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:113)
              at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
              at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
              at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:95)
              at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:524)
              at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:567)
              at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
              at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
              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:154)
              at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
              at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
              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: org.jboss.seam.InstantiationException: Could not instantiate Seam component: paisesManager
              at org.jboss.seam.Component.newInstance(Component.java:1970)
              at org.jboss.seam.Component.getInstance(Component.java:1873)
              at org.jboss.seam.Component.getInstance(Component.java:1840)
              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 com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:229)
              ... 71 more
      Caused by: javax.naming.NameNotFoundException: \PaisesManagerBean 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:1287)
              at org.jboss.seam.Component.instantiate(Component.java:1273)
              at org.jboss.seam.Component.newInstance(Component.java:1966)
              ... 84 more
      





      XHTML


      <h:form>
      
                 <rich:spacer height="30" />
                 
                 <rich:scrollableDataTable
                      binding="#{paisesManager.table}"
                      sortMode="single"
                      rowKey="#{paises.idpais}" 
                      rowKeyVar="rkv" 
                      frozenColCount="1" 
                      height="200px" 
                     selection="#{paisesManager.selection}"
                     rendered="#{not empty paisesManager.allPaises}"
                     width="80%"
                     id="sdtPaises"
                     columnClasses="col"
                     var="paises"
                      value="#{paisesManager.allPaises}"
                 >
                     <rich:column id="idpais" sortable="#{paisesManager.sortable}">
                          <f:facet name="header"><h:outputText styleClass="headerText" value="ID" /></f:facet>
                      <h:outputText value="#{paises.idpais}" />
                      </rich:column>
                     <rich:column id="descripcion" sortable="true">
                          <f:facet name="header"><h:outputText styleClass="headerText" value="Descripcion" /></f:facet>
                      <h:outputText value="#{paises.descripcion}" />
                      </rich:column>
                     <rich:column id="isoNumber" sortable="#{paisesManager.sortable}">
                          <f:facet name="header"><h:outputText styleClass="headerText" value="ISO #" /></f:facet>
                      <h:outputText value="#{paises.isoNumber}" />
                      </rich:column>
                     <rich:column id="iso2Chars" sortable="#{paisesManager.sortable}">
                          <f:facet name="header"><h:outputText styleClass="headerText" value="ISO 2" /></f:facet>
                      <h:outputText value="#{paises.iso2Chars}" />
                      </rich:column>
                     <rich:column id="iso3Chars" sortable="#{paisesManager.sortable}">
                          <f:facet name="header"><h:outputText styleClass="headerText" value="ISO 3" /></f:facet>
                      <h:outputText value="#{paises.iso3Chars}" />
                      </rich:column>
                     <rich:column id="caracteristica" sortable="#{paisesManager.sortable}">
                          <f:facet name="header"><h:outputText styleClass="headerText" value="Caracteristica" /></f:facet>
                      <h:outputText value="#{paises.caracteristica}" />
                      </rich:column>
                 </rich:scrollableDataTable>
                 
                 <rich:spacer height="20px"/>
                 
                 <a4j:commandButton value="Mostrar Seleccionados"  
                     action="#{paisesManager.takeSelection}" />
          </h:form>
      





      Bean


      @Stateless
      @Name("paisesManager")
      @Scope(ScopeType.SESSION)
      public class PaisesManagerBean implements PaisesManagerLocal
      {
              @PersistenceContext
              private EntityManager em;
              
              /*
              OR (tried this too)
              @PersistenceContext
              private EntityManager entityManager;
      
              OR
              @In
              @PersistenceContext
              private EntityManager entityManager;
              */
      
              private List<Paises> allPaises = new ArrayList<Paises>();
              private List<Paises> selectedPaises = new ArrayList<Paises>();
              private Paises paises;
              private SimpleSelection selection;
              
              private static final boolean SORTABLE = false;
              
              public PaisesManagerBean() {
                      
              }
              
              private UIScrollableDataTable table;
      
              public UIScrollableDataTable getTable() {
                      return table;
              }
              
              public void setTable(UIScrollableDataTable table) {
                      this.table = table;
              }
              
              public void destroy() {
                      
              }
      
              public List<Paises> getAllPaises() {
                      if (this.allPaises == null)
                      {
                              this.allPaises = this.initAllPaises();
                      }
                      
                      return this.allPaises;
              }
      
              public Paises getPaises() {
                      return this.paises;
              }
      
              public List<Paises> getSelectedPaises() {
                      return this.selectedPaises;
              }
      
              public SimpleSelection getSelection() {
                      return this.selection;
              }
      
              public List<Paises> initAllPaises() {
                      return em.createQuery("select paises from Paises paises").getResultList();
              }
      
              public boolean isSortable() {
                      return SORTABLE;
              }
      
              public void setAllPaises(List<Paises> allPaises) {
                      this.allPaises = allPaises;
              }
      
              public void setSelectedPaises(List<Paises> selectedPaises) {
                      this.selectedPaises = selectedPaises;
              }
      
              public void setSelection(SimpleSelection simpleSelection) {
                      this.selection = simpleSelection;
              }
      
              public String takeSelection() {
                      getSelectedPaises().clear();
                      Iterator<Object> iterator = getSelection().getKeys();
                      while (iterator.hasNext()){
                              Object key = iterator.next();
                              table.setRowKey(key);
                              if (table.isRowAvailable()) {
                                      getSelectedPaises().add((Paises) table.getRowData());
                              }
                      }
                      
                      System.out.println("Mostrando paises seleccionados:");
                      for (Paises p : getSelectedPaises()) {
                              System.out.println(p);
                      }
                      System.out.println("Fin Mostrando paises seleccionados");
                      
                      return null;
              }
      
      }
      



      components.xml


      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
                  xmlns:core="http://jboss.com/products/seam/core"
                  xmlns:persistence="http://jboss.com/products/seam/persistence"
                  xmlns:drools="http://jboss.com/products/seam/drools"
                  xmlns:bpm="http://jboss.com/products/seam/bpm"
                  xmlns:security="http://jboss.com/products/seam/security"
                  xmlns:mail="http://jboss.com/products/seam/mail"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation=
                     "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd 
                       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd 
                       http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd
                       http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.1.xsd
                       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
                       http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.1.xsd
                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd">       
      
         <core:init debug="true" jndi-pattern="upcn-ear/\#{ejbName}/local"/>
           
         <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>
      
         <persistence:managed-persistence-context name="entityManager"
                                           auto-create="true"
                            persistence-unit-jndi-name="java:/upcnEntityManagerFactory"/>                          
      
      </components>





      persistence.xml



      <?xml version="1.0" encoding="UTF-8"?>
      <!-- Persistence deployment descriptor for dev profile -->
      <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
                   version="1.0">
                   
         <persistence-unit name="upcn">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/upcnDatasource</jta-data-source>
            <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.FirebirdDialect"/>
               <property name="hibernate.hbm2ddl.auto" value="validate"/>
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.format_sql" value="true"/>
               <property name="jboss.entity.manager.factory.jndi.name" value="java:/upcnEntityManagerFactory"/>
            </properties>
         </persistence-unit>
      </persistence>