8 Replies Latest reply on Dec 23, 2010 2:40 AM by Leo van den berg

    Could not instantiate Seam component - Have tried all online solutions

    Olalekan Ogunleye Newbie
      Hi All,

      Can someone please tell me what I am doing wrong as I keep on getting this error. I have followed all the solutions that I found online but all to no avail. Please find my components file, xhtml file and the seam component java file as well as the error log. Thank you

      Componentx.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:web="http://jboss.com/products/seam/web"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation=
                      "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.2.xsd
                       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.2.xsd
                       http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.2.xsd
                       http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.2.xsd
                       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.2.xsd
                       http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.2.xsd
                       http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.2.xsd
                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd">

         <!--core:init debug="true" jndi-pattern="@jndiPattern@"/-->
        
         <core:init debug="true" jndi-pattern="web-admin/#{ejbName}/local"/>

         <core:manager concurrent-request-timeout="500"
                       conversation-timeout="120000"
                       conversation-id-parameter="cid"
                       parent-conversation-id-parameter="pid"/>

         <!-- Make sure this URL pattern is the same as that used by the Faces Servlet -->
         <web:hot-deploy-filter url-pattern="*.seam"/>

         <persistence:managed-persistence-context name="entityManager" auto-create="true"
                            persistence-unit-jndi-name="java:/web-adminEntityManagerFactory"/>

         <drools:rule-base name="securityRules">
            <drools:rule-files>
               <value>/security.drl</value>
            </drools:rule-files>
         </drools:rule-base>

         <security:rule-based-permission-resolver security-rules="#{securityRules}"/>
        
         <security:jpa-identity-store
         user-class="za.co.csir.meraka.mobi4d.console.webadmin.entity.MemberAccount"
         role-class="za.co.csir.meraka.mobi4d.console.webadmin.entity.MemberRole"/>

      <security:jpa-permission-store user-permission-class="za.co.csir.meraka.mobi4d.console.webadmin.entity.AccountPermission"/>

         <!-- security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/-->

         <event type="org.jboss.seam.security.notLoggedIn">
            <action execute="#{redirect.captureCurrentView}"/>
         </event>
         <event type="org.jboss.seam.security.loginSuccessful">
            <action execute="#{redirect.returnToCapturedView}"/>
         </event>

         <mail:mail-session host="smtp.meraka.csir.co.za" port="25"/>

         <!-- For use with jBPM pageflow or process management -->
         <!--
         <bpm:jbpm>
            <bpm:process-definitions></bpm:process-definitions>
            <bpm:pageflow-definitions></bpm:pageflow-definitions>
         </bpm:jbpm>
         -->

      </components>





      Seam component

      import java.util.List;
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      import javax.persistence.PersistenceContextType;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.faces.FacesMessages;
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Factory;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.datamodel.DataModel;
      import org.jboss.seam.annotations.datamodel.DataModelSelection;
      //import org.jboss.seam.annotations.Logger;
      //import org.jboss.seam.log.Log;

      import za.co.csir.meraka.mobi4d.console.webadmin.entity.Subscriber;


      @Stateful
      @Name("subscriberListing")
      @Scope(ScopeType.SESSION)
      public class SubscriberListing implements SubscriberList
      {
              @PersistenceContext(type=PersistenceContextType.EXTENDED)
          EntityManager em;
             
              @DataModel
              List<Subscriber> subscribers;
             
              @DataModelSelection
              private Subscriber subscriber;
             
              //@Logger private Log log;
             
              @In FacesMessages facesMessages;
             
              @SuppressWarnings("unchecked")
              @Factory("subscribers")
              public void subscriberListing() {
                      subscribers = em.createQuery("Select s from Subscriber s").getResultList();
                     
              }
             
              public void showDetails() {
                      subscriber.setSelected(true);
                     
              }


              @Destroy @Remove
              public void destroy() {}

             
             
              //public void remove() {
              //}
      }


      xhtml file

      <!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: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">
             
          <rich:panel>
              <f:facet name="header">subscribers</f:facet>

              <div class="results">

                  <h:outputText value="No subscriber exists"
                             rendered="#{empty subscribers}"/>

                  <rich:dataTable id="subscriberList" var="subscriber"
                            value="#{subscribers}"
                         rendered="#{not empty subscribers}">
                      <h:column>
                          <f:facet name="header">Id</f:facet>
                          #{subscriber.id}
                      </h:column>
                      <h:column>
                          <f:facet name="header">Name</f:facet>
                          <s:link id="subscriber"
                               value="#{subscriber.subscriberName}"
                               action="#{subscriberListing.showDetails}">
                         <!--propagation="none"
                               view="/subscriber.xhtml">
                              <f:param name="subscriberId"
                                      value="#{subscriber.id}"/-->
                          </s:link>
                      </h:column>
                     
                      <h:column>
                          <f:facet name="header">Email</f:facet>
                          #{subscriber.email}
                      </h:column>
                     
                  </rich:dataTable>

              </div>

          </rich:panel>
         
          <br style="clear:both"/>
          <rich:panel rendered="#{subscriber.selected}">
              <f:facet name="header"><h:outputText value="#{subscriber.subscriberName}"/></f:facet>
              <h:panelGrid columns="2">           
                  <h:outputLabel for="businessAddress" value="Business Address" style="font-weight:bold"/><h:outputText id="businessAddress" value="#{subscriber.businessAddress}"/>
                  <h:outputLabel for="contactPerson" value="Contact Person" style="font-weight:bold"/><h:outputText id="contactPerson" value="#{subscriber.contactPerson}"/>
                  <h:outputLabel for="noOfReps" value="No. of Reps" style="font-weight:bold"/><h:outputText id="subscriberRep" value="#{subscriber.subscriberReps.size()}"/>
              </h:panelGrid>
          </rich:panel>
         

          <div class="actionButtons">
              <s:button id="done"
                     value="Create subscriber"
                      action="#{subscriberManager.createSubscriber}"/>
          </div>

      </ui:define>

      </ui:composition>



      Error log
      13:17:40,968 ERROR [viewhandler] Error Rendering View[/subscriberListing.xhtml]
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: subscriberListing
              at org.jboss.seam.Component.newInstance(Component.java:2170)
              at org.jboss.seam.Component.getInstance(Component.java:2024)
              at org.jboss.seam.Component.getInstance(Component.java:1986)
              at org.jboss.seam.Component.getInstance(Component.java:1980)
              at org.jboss.seam.Component.getInstanceFromFactory(Component.java:2081)
              at org.jboss.seam.Component.getInstance(Component.java:2014)
              at org.jboss.seam.Component.getInstance(Component.java:1986)
              at org.jboss.seam.Component.getInstance(Component.java:1980)
              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:148)
              at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:51)
              at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
              at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
              at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
              at org.jboss.el.parser.AstEmpty.getValue(AstEmpty.java:29)
              at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
              at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
              at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:390)
              at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:271)
              at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
              at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:200)
              at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:195)
              at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
              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.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
              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.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
              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:206)
              at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
              at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
              at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
              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:235)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
              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:158)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
              at java.lang.Thread.run(Thread.java:619)
      Caused by: javax.naming.NameNotFoundException: web-admin not bound
              at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
              at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
              at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
              at org.jnp.server.NamingServer.lookup(NamingServer.java:396)
              at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
              at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
              at javax.naming.InitialContext.lookup(InitialContext.java:392)
              at org.jboss.seam.Component.instantiateSessionBean(Component.java:1403)
              at org.jboss.seam.Component.instantiate(Component.java:1367)
              at org.jboss.seam.Component.newInstance(Component.java:2148)
              ... 76 more
      Any help would be greatly appreciated. Thank you for your help


        • 1. Re: Could not instantiate Seam component - Have tried all online solutions
          Leo van den berg Master

          Hi,


          To get the complete picture:


          - You have an EAR project?
          - You're using JBOSS AS 5.X ??
          - You have defined the Seam interceptors in ejb-jar.xml ??
          - You have tried the JBOSS admin tools an you have found the (deployed) SubscriberListing bean ? 


          Leo

          • 2. Re: Could not instantiate Seam component - Have tried all online solutions
            Olalekan Ogunleye Newbie
            <blockquote>
            _Leo van den Berg wrote on Dec 20, 2010 06:32:_<br/>

            Hi,

            To get the complete picture:

            - You have an EAR project?
            - You're using JBOSS AS 5.X ??
            - You have defined the Seam interceptors in ejb-jar.xml ??
            - You have tried the JBOSS admin tools an you have found the (deployed) SubscriberListing bean ? 

            Leo

            </blockquote>

            Hi Leo,

            Thank you for your response. However, the answer to all the questions you asked is YES. Please find below my ejb-jar.xml


            <?xml version="1.0" encoding="UTF-8"?>
            <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
                     version="3.0">
                    
               <interceptors>
                  <interceptor>
                     <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
                  </interceptor>
               </interceptors>
              
               <assembly-descriptor>
                  <interceptor-binding>
                     <ejb-name>*</ejb-name>
                     <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
                  </interceptor-binding>
               </assembly-descriptor>
              
            </ejb-jar>

            I have done everything possible but still with no luck. This is a kind of hindrance. Thank you
            • 3. Re: Could not instantiate Seam component - Have tried all online solutions
              Leo van den berg Master

              Hi,


              the reason I asked these questions, is because the error is a bit strange. Instead of stating it can't find a component. It states it can't find web-admin, which is the EAR-project name (prefix), I am using this kind of prefixes myself and I had this problem once, because I mispelled the real EAR project output. It is exactly the name of the created EAR, so if you have a suffix, such as project-1.0, the suffix must be included.


              Additionally:





              • Make your bean a simple POJO first and check again

              • I highly recommend using the Seam managed persistenceContext,




              Leo

              • 4. Re: Could not instantiate Seam component - Have tried all online solutions
                Olalekan Ogunleye Newbie

                Leo van den Berg wrote on Dec 21, 2010 03:16:


                Hi,

                the reason I asked these questions, is because the error is a bit strange. Instead of stating it can't find a component. It states it can't find web-admin, which is the EAR-project name (prefix), I am using this kind of prefixes myself and I had this problem once, because I mispelled the real EAR project output. It is exactly the name of the created EAR, so if you have a suffix, such as project-1.0, the suffix must be included.

                Additionally:




                • Make your bean a simple POJO first and check again

                • I highly recommend using the Seam managed persistenceContext,




                Leo


                Thanks a lot for the response Leo. What I dont understand is that this project works fine without maven but the moment I deploy the same project in a mavenized way it doesn't work. I jsut have to carry on with the one without maven hoping that one day I will get solution to the problem.


                Can someone who is more experienced help in this case? I am sorry to write this but not getting answers to one postings on this forum sometimes demotivate one as to truely accept that seam is powerful enough for one to shift all attention to it.


                Click HELP for text formatting instructions. Then edit this text and check the preview.

                • 5. Re: Could not instantiate Seam component - Have tried all online solutions
                  Leo van den berg Master

                  Hi,


                  now you've given additional information: You use Maven !


                  Show use the header of the maven build file which clarifies a lot. As stated before, sometimes the EAR-prefix contains a version, which is really the case with maven, or you have explicitely staed that you don't want a prefix..


                  If you go to your maven repository (the .m2 directory in your user account) just find the product of the maven build and see how it is called (dir-suffixes/..//name-version.ear).


                  That's the name you should use in your jndi-pattern.


                  Leo





                  Can someone who is more experienced help in this case?

                  AAAAAAAAAAAH that hurts....

                  • 6. Re: Could not instantiate Seam component - Have tried all online solutions
                    Leo van den berg Master

                    Hi,


                    sorry I mixed up prefix and suffix (bad excuse: well English is not my native tongue...)


                    Show use the header of the maven build file which clarifies a lot. As stated before, sometimes the EAR-suffix contains a version, which is really the case with maven, or you have explicitely staed that you don't want a suffix..


                    If you go to your maven repository (the .m2 directory in your user account) just find the product of the maven build and see how it is called (com/blaha/blah/..//EAR-NAME-version.ear).


                    Leo

                    • 7. Re: Could not instantiate Seam component - Have tried all online solutions
                      Olalekan Ogunleye Newbie


                      Can someone who is more experienced help in this case?

                      AAAAAAAAAAAH that hurts....



                      Sorry about that comment Leo, it was meant to be directed at me in the sense that can someone more experienced than me help in this case and not in anyway at you. I will try your suggestion and give you feedback as to weather it works or not. Thanks a lot

                      • 8. Re: Could not instantiate Seam component - Have tried all online solutions
                        Leo van den berg Master

                        Hi,


                        I'm not offended, I just couldn't resist...


                        Keep the forum informed about progress with your progress, because I feel every Maven expertise for Seam can be helpful.


                        Leo