title: JSF2 form submit " Target Unreachable, identifier 'myModel' resolved to null ONLY on submit
body: <p>I have a very strange problem where a bean is not resolved but ONLY on submit. It works fine on view but on submit, it errors out saying that the identifier is null</p>
  
  <p>My JSF</p>
  
  <pre><code>    &lt;h:form id="edit" styleClass="form"&gt;
          &lt;rich:panel&gt;
              &lt;f:facet name="header"&gt;
                  &lt;h:outputText value="Edit Data" /&gt;
              &lt;/f:facet&gt;
  
              &lt;rich:graphValidator value="#{myModel}" id="gv"&gt;
                  &lt;rich:messages for="gv" /&gt;
                  &lt;rich:messages id="goal-messages" globalOnly="true" /&gt;
  
                      &lt;!-- form fields that reference #{myModel.fields} --&gt;
  
                      &lt;h:commandButton id="save" value="Save"
                          action="#{myModel.save}" /&gt;
              &lt;/rich:graphValidator&gt;
  
          &lt;/rich:panel&gt;
      &lt;/h:form&gt;
  </code></pre>
  
  <p>The Model class</p>
  
  <pre><code>@Named("myModel")
  @RequestScoped
  public class MyModelImpl implements Model {
  
      @Inject
      @RequestParam("objectId")
      private Long objectId;
  
  
      // Getters &amp; Setters for the various fields
  
  
      public void save() {
          // does nothing just now
      }
  }
  </code></pre>
  
  <p>I know that I should move the save operation into a controller which I will once I have it working. I have another instance of this working without issues (in another but related module). In fact, I copied the code to start with and modified as necessary.</p>
  
  <p>The main difference in this module is that I name it differently from the class.</p>
  
  <p>The view loads up ok without any issues, but on submit, I get the following:</p>
  
  <p>The root exception is:</p>
  
  <pre><code>Caused by: javax.el.PropertyNotFoundException: /edit.xhtml @26,71 value="#{myModel.name}": Target Unreachable, identifier 'myModel' resolved to null
  at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:133) [jsf-impl-2.1.7-jbossorg-2.jar:]
  at org.richfaces.el.ValueExpressionAnalayserImpl$SetValueCommand.resolve(ValueExpressionAnalayserImpl.java:42) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
  at org.richfaces.el.ValueExpressionAnalayserImpl.resolveValue(ValueExpressionAnalayserImpl.java:64) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
  at org.richfaces.el.ValueExpressionAnalayserImpl.updateValueAndGetPropertyDescriptor(ValueExpressionAnalayserImpl.java:90) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
  at org.richfaces.validator.BeanValidatorServiceImpl.validateExpression(BeanValidatorServiceImpl.java:157) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
  ... 41 more
  </code></pre>
  
  <p>Bearing in mind that it works on viewing the page, I am at a real loss as to why it doesn't work on submit.</p>
  
  <p>I have tried various things including: </p>
  
  <ul>
  <li>changing the scope to @ViewScoped, </li>
  <li>removing the bulk of the fields displayed (bar one - the name), </li>
  <li>passing in the requestParam again (but I realised that i wasn't even picked up in the first place and it works fine.</li>
  </ul>
  
  <p>I have found lots of different people with the same final error but not the same circumstances .</p>
  
  <p>all with no joy. Anybody have any thoughts on what might be the issue?</p>
  
  <p>I am testing using Arquillian on JBoss 7.1.1.Final</p>
  
  <p>Any help appreciated.</p>