Java Play Mustache NPE Error

We get a mustache game error in production (amazon linux EC2 AMI), but not in development (MAC), and we tried updating jvm using jdk instead and moving from the tomcat deployment model to our development environments as much as possible, but nothing works. Please any help would be greatly appreciated. We have a lot of common code in java and javascript using mustache, and it would be very important to rewrite everything if we had to truncate the mustache on the java side.

20: 48: 52,403 ERROR ~

@6al2dd0po
Internal Server Error (500) for request GET /mystuff/people

Execution exception (In {module:mustache-0.2}/app/play/modules/mustache/MustacheTags.java around line 32)
NullPointerException occured : null

play.exceptions.JavaExecutionException
    at play.templates.BaseTemplate.throwException(BaseTemplate.java:90)
    at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:257)
    at play.templates.Template.render(Template.java:26)
    at play.templates.GroovyTemplate.render(GroovyTemplate.java:187)
    at play.mvc.results.RenderTemplate.<init>(RenderTemplate.java:24)
    at play.mvc.Controller.renderTemplate(Controller.java:660)
    at play.mvc.Controller.renderTemplate(Controller.java:640)
    at play.mvc.Controller.render(Controller.java:695)
    at controllers.MyStuff.people(MyStuff.java:183)
    at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:548)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
    at Invocation.HTTP Request(Play!)
Caused by: java.lang.NullPointerException
    at play.modules.mustache.MustacheTags._template(MustacheTags.java:32)
    at play.modules.mustache.MustacheTags$_template.call(Unknown Source)
    at /app/views/User/people.html.(line:22)
    at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:232)
    ... 13 more
+5
source share
3 answers

The problem seems to be related to threadlocal. In Prod, according to my logs, the session is initialized with the main thread.

     [2012-06-30 18:35:38,102] INFO 10097[**main**] - Mustache module initialized

, MustacheTag , .

     [2012-06-30 17:48:44,669] INFO 66048[**play-thread-1**] - [{module:mustache-0.2}/app/play/modules/mustache/MustacheTags.java:46] _meta() :: MustachePlugin.session():null

, MustachePlugin this.Changed :

    //private static ThreadLocal<MustacheSession> session_ = new ThreadLocal<MustacheSession>();
    private static MustacheSession _session = null;
    public static MustacheSession session(){
    //return session_.get();
    return _session;
    }
    public void onConfigurationRead(){
    // some code
    _session = new MustacheSession(compiler, root);
    // some code
    }

prod! , ThreadLocal, , !

+1

, . , env. .

  • : . , NPE.

  • : - people.html.(line:22), . / , , . mustache ( , ), , .

  • : proprties env? , - prod env?

0

NullPointerException MustacheTags.java 32.

, , , Mustache . , ( MyStuff.java 183?).

MustacheTags , , .

0

All Articles