4 Replies Latest reply on Mar 20, 2010 3:35 PM by asookazian

    Cannot create Seam component, scope is not active

    oyesiji77

      I am using Seam 2.2 and sometimes i keep getting the following message


      23:17:42,324 WARN  [Component] Cannot create Seam component, scope is not active: advertiserPortal(CONVERSATION)


      Please how can i resolve this

        • 1. Re: Cannot create Seam component, scope is not active
          carolinofr

          i have the to problem :(

          • 2. Re: Cannot create Seam component, scope is not active
            asookazian

            I'm not sure what the Seam container means by scope is not active.  Apparently in this situation the current component's context is not active?  Here is the method that is outputting that warning:


            private static Object getInstance(String name, boolean create, boolean allowAutoCreation, Object result) {
                  Component component = Component.forName(name);
            
                  create = create || (Init.instance().isAutocreateVariable(name) && allowAutoCreation);
            
                  if (result==null && create)
                  {
                    result = getInstanceFromFactory(name);
                    if (result==null)
                    {
                       if (component==null)
                       {
                          //needed when this method is called by JSF
                          if ( log.isTraceEnabled() ) log.trace("Seam component not found: " + name);
                       }
                       else if ( component.getScope().isContextActive() )
                       {
                          result = component.newInstance();
                       }
                       else
                       {
                          log.warn("Cannot create Seam component, scope is not active: " + name + "(" + component.getScope().name() + ")");
                       }
                    }
                  }
            
                  if (result!=null)
                  {
                     if (component!=null)
                     {
                        if ( !component.isInstance(result) )
                        {
                           if ( component.hasUnwrapMethod() ) return result; ///best way???
                           throw new IllegalArgumentException( "value of context variable is not an instance of the component bound to the context variable: " + name  +
                                    ". If you are using hot deploy, you may have attempted to hot deploy a session or " +
                                    "application-scoped component definition while using an old instance in the session.");
                        }
                        result = component.unwrap(result);
                     }
                  }
            
                  return result;
            
               }

            • 3. Re: Cannot create Seam component, scope is not active
              oyesiji77

              Yes that's the Module causing the error. But i don't know why??

              • 4. Re: Cannot create Seam component, scope is not active
                asookazian

                Sometimes this is caused by a hot deploy problem and can be rectified by doing a clean redeploy/restart. Other times it may indicate that you have a Seam component name (@Name annotation) the same as a variable name. Check your code carefully to see if your context variable is not already in use as a Seam component name. If it is, change one of them.

                This is a somewhat common thing to occur, because if you create a Seam component called myThing, it is only natural that you might end up creating an in-or-out-jected property called myThing as well. One solution would be to always declare your Seam component names with some distinguishable prefix or suffix (like SeamMyThing).

                http://jeremygoodell.com/2009/03/26/value-of-context-variable-is-not-an-instance-of-the-component-bound-to-the-context-variable.aspx