title: WELD-001303 No active contexts for scope type javax.faces.view.ViewScoped
body: <p>I have switched to javax.enterprise.context.SessionScoped to javax.faces.view.ViewScoped
  Upgraded faces 2.1 to 2.2 to be able to use ViewScoped with my CDI injections. </p>
  
  <p>After I switched to ViewScoped I have started getting this error and I can't figure out why! Do you think there is something wrong here?</p>
  
  <p><strong>Glassfish 3.1.2, Primefaces 3.4.2, JSF 2.2</strong></p>
  
  <p>org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.faces.view.ViewScoped</p>
  
  <p>The button opens the page:
       </p>
  
  <p>The jsf page;</p>
  
  <pre><code>&lt;h:form enctype="multipart/form-data"&gt;
      &lt;p:fieldset legend="Create new feed" toggleable="true" collapsed="true" &gt;
          &lt;p:fileUpload fileUploadListener="#{adminHomeController.handleFileUpload}" style="margin-top: 20px;"
                        mode="advanced" 
                        update="messages"
                        sizeLimit="1000000" 
                        multiple="false" 
                        allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/&gt;
          &lt;p:inputText label="Baslik" style="margin-top: 20px;" required="true" value="#{adminHomeController.newFieldset.legend}"  /&gt; 
          &lt;p:editor style="margin-top: 20px;"
                    value="#{adminHomeController.newFieldset.content}" /&gt;
          &lt;p:commandButton style="margin-top: 20px;" value="#{msg['common.save']}" update="messages" icon="ui-icon-disk" actionListener="#{adminHomeController.saveFieldset()}"/&gt;
      &lt;/p:fieldset&gt;
      &lt;p:growl id="messages" showDetail="true"/&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>Controller;</p>
  
  <pre><code>import com.bg.entity.Fieldset;
  import com.bg.service.Service;
  import java.io.Serializable;
  import javax.annotation.PostConstruct;
  import javax.faces.application.FacesMessage;
  import javax.faces.context.FacesContext;
  import javax.faces.view.ViewScoped;
  import javax.inject.Inject;
  import javax.inject.Named;
  import org.primefaces.event.FileUploadEvent;
  
  @Named
  @ViewScoped
  public class AdminHomeController implements Serializable{
  
      @Inject
      private Service service;
      private Fieldset newFieldset;
  
      public AdminHomeController() {
      }
  
      @PostConstruct
      public void init() {
          System.out.println("INIT");
          newFieldset = new Fieldset();
      }
  
      public void handleFileUpload(FileUploadEvent event) {
          System.out.println("HandleFileUpload");
          byte[] file = event.getFile().getContents();
          newFieldset.setData(file);
          FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
          FacesContext.getCurrentInstance().addMessage(null, msg);
      }
  
      public void saveFieldset() {
          System.out.println("SaveFieldset");
          service.create(newFieldset);
          FacesMessage msg = new FacesMessage("Succesful", newFieldset.getLegend() + " is saved.");
          FacesContext.getCurrentInstance().addMessage(null, msg);
      }
  
      /**
       * @return the newFieldset
       */
      public Fieldset getNewFieldset() {
          System.out.println("getNewFieldset");
          return newFieldset;
      }
  
      /**
       * @param newFieldset the newFieldset to set
       */
      public void setNewFieldset(Fieldset newFieldset) {
          System.out.println("setNewFieldset");
          this.newFieldset = newFieldset;
      }
  }
  </code></pre>