java - "NullPointerException: null" in play framework -


i new play framework , have project java in play framework connected mongodb via morphiaplay. problem cannot add data. of code

public class sign extends controller{       static form<group> groupform = form(group.class);      public static result index() throws exception {         // redirect "group result         return redirect(routes.sign.group());     }      public static result group() {         return ok(views.html.sign.render(group.all(), groupform));       }      public static result newgroup() {         form<group> filledform = groupform.bindfromrequest();         if(filledform.haserrors()) {             return badrequest(views.html.sign.render(group.all(), filledform));         } else {             group.create(filledform.get());             return redirect(routes.sign.group());           }     }     }     @entity public class group {  @id public objectid id; @required public string name; public string email; public string username; public string password;  public static list<group> all() {     if (morphiaobject.datastore != null) {         return morphiaobject.datastore.find(group.class).aslist();     } else {         return new arraylist<group>();     } }  public static void create(group group) {     morphiaobject.datastore.save(group); } 

and error

execution exception 

[nullpointerexception: null] in c:\lo\app\models\group.java @ line 37.

public static void create(group group) {     morphiaobject.datastore.save(group); } 

my morphiaobject class

package controllers; 

public class morphiaobject extends globalsettings{

static public mongo mongo;  static public morphia morphia;  static public datastore datastore;  @override public void onstart(play.application arg0) {     super.beforestart(arg0);     logger.debug("** onstart **");      try {         morphiaobject.mongo = new mongo("127.0.0.1", 27017);     } catch (unknownhostexception e) {         e.printstacktrace();     }     morphiaobject.morphia = new morphia();     morphiaobject.datastore = morphiaobject.morphia.createdatastore(morphiaobject.mongo, "project");     morphiaobject.datastore.ensureindexes();        morphiaobject.datastore.ensurecaps();        logger.debug("** morphia datastore: " + morphiaobject.datastore.getdb()); 

} }

can please help!


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -