0 Replies Latest reply on Nov 25, 2009 8:25 PM by mblanton

    NullPointerException when updating record with extended EntityHome class

    mblanton

      I have this code...


      @Name("userHome")
      public class UserHome extends EntityHome<User> implements IUserHome {
      ...SNIP...
              @Override
              public String update() {
                      User cUser = userManager.findByEmail(identity.getCredentials().getUsername());
                      User lUser = getInstance();
                      lUser.setModifiedBy(cUser);
                      lUser.setModifiedDate(new Date(System.currentTimeMillis()));
                      return super.update();
              }
      ...SNIP...
      }
      



      However, when I use the generated UserEdit page, modified one of the User fields, then click save, I get the following exception:


      Caused by: java.lang.NullPointerException
              at org.jboss.seam.framework.Home.updatedMessage(Home.java:55)
              at org.jboss.seam.framework.EntityHome.update(EntityHome.java:65)
              at org.j_commerce.action.impl.UserHome.update(UserHome.java:100)
      ...SNIP...
      


      If I update my UserHome class to include the following:


              @SuppressWarnings("unchecked")
              @Override
              public ValueExpression getUpdatedMessage() {
                      return createValueExpression(messages.get("User_updated"));
              }       
      



      the error goes away.  I have an entry User_updated in my messages_en.properties file:


      User_updated=User #{user.email} successfully updated.
      



      Any thoughts as to what is going on?  I'd like to be able to do this without having to override all of the get*Message() methods.


      I'm using Seam 2.2.0.GA running in JBoss 5.1.0.GA.