BlackLabs / play-morphia

Provide mongodb access service to play.db.Model via Morphia
Apache License 2.0
130 stars 49 forks source link

Using Morphia with POJO-mapping or CRUD gives Nullpointer #64

Open blockmar opened 12 years ago

blockmar commented 12 years ago

When I try to use Morphia-based model objects with the Controller pojo-mapping I get a NullpointerException when navigating to the page. See below.

Oops: NullPointerException

An unexpected error occured caused by exception NullPointerException: null

play.exceptions.UnexpectedException: Unexpected Error
        at play.mvc.ActionInvoker.invoke(ActionInvoker.java:258)
        at Invocation.HTTP Request(Play!)
Caused by: java.lang.NullPointerException
        at play.modules.morphia.MorphiaPlugin.bind(MorphiaPlugin.java:577)
        at play.PlayPlugin.bind(PlayPlugin.java:68)
        at play.plugins.PluginCollection.bind(PluginCollection.java:534)
        at play.data.binding.Binder.bind(Binder.java:111)
        at play.mvc.ActionInvoker.getActionMethodArgs(ActionInvoker.java:642)
        at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
        at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
        at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
        ... 1 more

Model object:

package models;

import play.modules.morphia.Model;

public class Registerform extends Model {

    public String name;
    public String alias;
    public String password1;
    public String password2;

}

Controller method:

package controllers;

import models.forms.Registerform;
import play.mvc.Controller;

public class Register extends Controller {

    public static void index(Registerform form) {
        if(form != null){ System.out.println(form.name); }
        render();
    }   
}
greenlaw110 commented 12 years ago

which play version are you using? There are known binding issue with Play 1.2.4.

On Tue, Jan 31, 2012 at 8:32 PM, Anders Blockmar < reply@reply.github.com

wrote:

When I try to use Morphia-based model objects with the Controller pojo-mapping I get a NullpointerException when navigating to the page. See below.

Oops: NullPointerException

An unexpected error occured caused by exception NullPointerException: null

play.exceptions.UnexpectedException: Unexpected Error
       at play.mvc.ActionInvoker.invoke(ActionInvoker.java:258)
       at Invocation.HTTP Request(Play!)
Caused by: java.lang.NullPointerException
       at play.modules.morphia.MorphiaPlugin.bind(MorphiaPlugin.java:577)
       at play.PlayPlugin.bind(PlayPlugin.java:68)
       at play.plugins.PluginCollection.bind(PluginCollection.java:534)
       at play.data.binding.Binder.bind(Binder.java:111)
       at
play.mvc.ActionInvoker.getActionMethodArgs(ActionInvoker.java:642)
       at
play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
       at
play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
       at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
       ... 1 more

Model object:

package models;

import play.modules.morphia.Model;

public class Registerform extends Model {

       public String name;
       public String alias;
       public String password1;
       public String password2;

}

Controller method:

package controllers;

import models.forms.Registerform;
import play.mvc.Controller;

public class Register extends Controller {

   public static void index(Registerform form) {
       if(form != null){ System.out.println(form.name); }
       render();
   }
}

Reply to this email directly or view it on GitHub: https://github.com/greenlaw110/play-morphia/issues/64

blockmar commented 12 years ago

I am using Play 1.2.4. I did not make the connection between the issues until now. Probably the same reason.

greenlaw110 commented 12 years ago

Can you try on Play 1.2.3 ?

On Wed, Feb 1, 2012 at 12:36 AM, Anders Blockmar < reply@reply.github.com

wrote:

I am using Play 1.2.4. I did not make the connection between the issues until now. Probably the same reason.


Reply to this email directly or view it on GitHub: https://github.com/greenlaw110/play-morphia/issues/64#issuecomment-3738968

blockmar commented 12 years ago

I tried using 1.2.3 same problem.

This is what I did.

blockmar commented 12 years ago

If you have any tips on how to run play using a custom version of the play-morphia plugin (say in Eclipse for example) I can try to help you with the issue. So far I have forked the repo but haven't figured out how to start play with "my" plugin code.

Do I need to build a plugin jar for each try or can I run it from within my dev env somehow?

greenlaw110 commented 12 years ago

Hi can you try the latest 1.2.7 version?

greenlaw110 commented 12 years ago

Can you send your project package to me? I need to understand how you invoke Register.index(...) method

blockmar commented 12 years ago

Hi!

Sorry about my mack of answers. I will try to test the tastest version asap, if I can't test it myself I will send you the project.

redards

Anders

On Sun, Jun 10, 2012 at 6:39 AM, Green Luo < reply@reply.github.com

wrote:

Can you send your project package to me? I need to understand how you invoke Register.index(...) method


Reply to this email directly or view it on GitHub: https://github.com/greenlaw110/play-morphia/issues/64#issuecomment-6225870

greenlaw110 commented 12 years ago

hi any update here?

blockmar commented 12 years ago

Hi!

Just tested my old code with play 1.2.5 and the 1.2.10 plugin. Same problem.

I have retired my code (ande the project) in favour of Play 2 a few months ago so this bug is not a problem to me any longer. Please close it since I am unable to dig any further into this.