2 Replies Latest reply on Apr 18, 2009 12:44 AM by Thai Dang Vu

    Please help: Could not instantiate Seam component

    Thai Dang Vu Apprentice

      I have this in components.xml


      <component name="hiddenInput" class="javax.faces.component.html.HtmlInputHidden" scope="event"/>



      and in xhtml


      <a4j:form>
          <h:inputHidden binding="#{hiddenInput}" id="hiddenComponent"/>
          <rich:message for="hiddenComponent" style="display: block; color: red;"/>
          ....
          <a4j:commandLink action="#{countries.deleteCountry(country)}" .../>
      </a4j:form>



      In Java


      @Name("countries")
      @Scope(ScopeType.PAGE)
      public class Countries implements Serializable {
          @In(required=false)
          private HtmlInputHidden hiddenInput;
      
          @Transactional
          public void deleteCountry(Country c) {
              try {
                  ...
              }
              catch (Throwable throwable) {
                  String error = "Error: " + throwable.getMessage();
                  FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_ERROR, error, error);
                  FacesContext facesContext = FacesContext.getCurrentInstance();
                  log.debug(hiddenInput.getClientId(facesContext));
                  facesContext.addMessage(hiddenInput.getClientId(facesContext), fm);
              }
          }
      }



      When I accessed the xhtml in the web browser, I got these exceptions


      javax.faces.FacesException: org.jboss.seam.InstantiationException: Could not instantiate Seam component: hiddenInput
           at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:257)
           at org.jboss.seam.jsf.SeamApplication.createComponent(SeamApplication.java:394)
           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:337)
           at com.sun.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:307)
           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.tag.jsf.core.ViewHandler.apply(ViewHandler.java:109)
           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:140)
           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: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 org.jboss.jsfunit.seam.JSFUnitLifecycle.render(JSFUnitLifecycle.java:59)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
           at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:333)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
           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:178)
           at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
           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:58)
           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:246)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:313)
           at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
           at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
           at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
           at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
           at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
           at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
           at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
           at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
           at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
           at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
           at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
           at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: hiddenInput
           at org.jboss.seam.Component.newInstance(Component.java:2106)
           at org.jboss.seam.Component.getInstance(Component.java:1988)
           at org.jboss.seam.Component.getInstance(Component.java:1950)
           at org.jboss.seam.Component.getInstance(Component.java:1944)
           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:175)
           at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
           at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
           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:246)
           ... 86 more
      Caused by: java.lang.RuntimeException: by java.lang.NoClassDefFoundError: org/jboss/seam/Instance
           at org.jboss.seam.util.ProxyFactory.createClass(ProxyFactory.java:190)
           at org.jboss.seam.Component.createProxyFactory(Component.java:2388)
           at org.jboss.seam.Component.getProxyFactory(Component.java:1480)
           at org.jboss.seam.Component.wrap(Component.java:1471)
           at org.jboss.seam.Component.instantiateJavaBean(Component.java:1409)
           at org.jboss.seam.Component.instantiate(Component.java:1326)
           at org.jboss.seam.Component.newInstance(Component.java:2084)
           ... 99 more
      Caused by: javassist.CannotCompileException: by java.lang.NoClassDefFoundError: org/jboss/seam/Instance
           at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:165)
           at org.jboss.seam.util.ProxyFactory.createClass(ProxyFactory.java:186)
           ... 105 more
      Caused by: java.lang.NoClassDefFoundError: org/jboss/seam/Instance
           at java.lang.ClassLoader.defineClass1(Native Method)
           at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
           at sun.reflect.GeneratedMethodAccessor80.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at javassist.util.proxy.FactoryHelper.toClass2(FactoryHelper.java:177)
           at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:159)
           ... 106 more
      Caused by: java.lang.ClassNotFoundException: org.jboss.seam.Instance
           at com.sun.appserv.server.util.ASURLClassLoader.loadClass(ASURLClassLoader.java:129)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
           ... 113 more



      Does anybody know what my problem is?


      In another page, I wrote my own event-scoped component like


      @Name("addCountryForm")
      @Scope(ScopeType.EVENT)
      public class AddCountryForm {
          private String id;
          private String name;
          private Region region;
      
          private UIComponent hiddenComponent;
          ...
      }



      and had this in xhtml and nothing wrong happened


      <h:inputHidden id="hidden" binding="#{addCountryForm.hiddenComponent}"/>
      <rich:message for="hidden" style="display: block; color: red;"/>
      



      Thank you.

        • 1. Re: Please help: Could not instantiate Seam component
          Arshad Mahmood Newbie

          Hi,


          You appear to be missing the main jboss-seam.jar. This jar needs to be declared as an EJB jar and placed at the top level of your EAR.


          Regards.

          • 2. Re: Please help: Could not instantiate Seam component
            Thai Dang Vu Apprentice

            I'm sure that it's not the case. Reason:
            my application.xml is like this


            <display-name>Seam Application in Glassfish</display-name>
                <module id="seam-glassfish-EJB">
                    <ejb>seam-glassfish.jar</ejb>
                </module>
                <module id="seam-glassfish-Web">
                    <web>
                        <web-uri>seam-glassfish.war</web-uri>
                        <context-root>/seam-glassfish</context-root>
                    </web>
                </module>
                <module><ejb>jboss-seam-2.1.1.GA.jar</ejb></module>
            </application>



            and my ear structure is like this


            jboss-seam-2.1.1.GA.jar
            lib
            META-INF
            seam-glassfish.jar
            seam-glassfish.war



            and if I don't have


            <component name="hiddenInput" class="javax.faces.component.html.HtmlInputHidden" scope="event"/>



            in the components.xml but write an event-scoped component like this


            @Name("genericComponents")
            @Scope(ScopeType.EVENT)
            public class GenericComponents {
                private HtmlInputHidden hiddenInput;
            
                public HtmlInputHidden getHiddenInput() {
                    return hiddenInput;
                }
            
                public void setHiddenInput(HtmlInputHidden hiddenInput) {
                    this.hiddenInput = hiddenInput;
                }
            }



            and in the xhtml I write


            <h:inputHidden binding="#{genericComponents.hiddenInput}" id="hiddenComponent"/>
            <!-- <h:inputHidden binding="#{hiddenInput}" id="hiddenComponent"/> -->
            


            then no error happens.


            Do you think of any other problem?


            Thank you.