title: Getting a RuntimeException : Datasource user is null ? when updating User model in Play Framework 2.2.1
body: <p>I am currently trying to enhance the To-Do List tutorial from Play framework's website. I've added a login form, (and of course a User class acting as a model), and it works perfectly well. I also made a small "dashboard" in which the logged user is able to change his password and his email address. But when I submit the form, I get a "Datasource user is null ?" error (RuntimeException). </p>
  
  <p>The whole problem came when I wanted to restrict the edition possibilities (I first used a whole User form, which is quite over the top (User do not need to edit their ID). So I made a small inner class in my Application file called UpdateUser which gathers the required informations, just as I did for the login system.</p>
  
  <p>Searching this error gave me many results but people saw their problem fixed by uncommenting the ebean.default line in the conf file, which I already did.</p>
  
  <p>Here is the method I used to update user's informations :</p>
  
  <p>Firstly, I made a small class in my Application to hold the form (exactly like I did for the login thing).
  Then I made a update function as found <a href="https://stackoverflow.com/questions/16122884/update-the-task-model-runtimeexception-datasource-user-is-null">here</a> in my user class :</p>
  
  <pre><code>public static String update(String id, User newuser) {
      newuser.update(id);
      return("Your profile has been updated");    
  }
  </code></pre>
  
  <p>which returns the String that will be in my flash and which is according to my compiler the problem function.</p>
  
  <p>This function is called in my Application like this : </p>
  
  <pre><code>public static Result updateUser(String id)
  {
      Form&lt;UpdateUser&gt; filledForm = updateUserForm.bindFromRequest();
      System.out.println("Updated User : "+filledForm.get().id);
      if(filledForm.hasErrors())
          {
              flash("success","Error while updating");
      }else{
          User user = new User(filledForm.get().id, filledForm.get().email, User.find.byId(filledForm.get().id).name, User.find.byId(filledForm.get().id).surname, filledForm.get().password);
          flash("success", User.update(id,user));
      }
      return redirect(routes.Application.dashboard());
  }
  </code></pre>
  
  <p>I tracked the data in the Form and it is not null (I mean I can get everything from the form). But I wonder if I have to create another ebean or if it's my function which is wrong. I also wonder if it's not my User creation that fail. Or maybe I should take the updateUser function and put it in my inner UpdateUser class ?</p>
  
  <p>I have to admit that I worked on that all of yesterday (and probably today too), and I can't find anything on the internet except the ebean.default thing.</p>
  
  <p>------EDIT</p>
  
  <p>I continued to search, so here's what I tried :</p>
  
  <p>1) Getting the form result into an instance of UpdateUser in order to use it<br>
  2) Use this instance instead of getting the data from the form</p>
  
  <p>But it failed too. What's really weird is that I've added a toString() method for User class, and calling it on the user I want to insert (as an update) gives me the full stuff. I think it must be a configuration problem, but I can't see it. </p>
  
  <p>Another thing : when I come to the error page and when I try to come back to the application by modifying the URL, I am disconnected. Is it my ebean that closes himself ?</p>
  
  <p>Last edit for the day, I'm getting tired of this. I tried to delay the action (i.e. making it happen after the user has logged out), the new data are correctly saved but I still get the error when calling the update function.</p>