playframework CRUD NullPointerException while loading classes-Collection of common programming errors
I get this Exception when running a play app that uses the crud module. the strange thing is that when i get this error and i refresh web page the play app works and page is loaded correctly. it seems the play compiler -in DEV mode- can’t compile CRUD class in first request. i don’t know why the play compiler in DEV mode frequently fails compiling some classes in my play web app?
i use eclipse IDE & i suspect that eclipse locks some java source files and prevent play from compiling the java sources ; however i’m not sure of this. There might be some reason that causes play DEV mode compiler to fail & i can’t figure it out. this issue is happening to me a lot these days while working on a play web app.
what this error means and how to fix it?
ERROR ~
@69g88ea66
Internal Server Error (500) for request GET /
Template execution error (In {module:crud}/app/views/tags/crud/types.tag around line 3)
Execution error occured in template {module:crud}/app/views/tags/crud/types.tag. Exception raised was NullPointerException : null.
play.exceptions.TemplateExecutionException
at play.templates.BaseTemplate.throwException(BaseTemplate.java:86)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:257)
at play.templates.GroovyTemplate$ExecutableTemplate.invokeTag(GroovyTemplate.java:379)
at /conf/routes.(line:42)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:232)
at play.templates.Template.render(Template.java:26)
at play.templates.GroovyTemplate.render(GroovyTemplate.java:187)
at play.mvc.Router.parse(Router.java:162)
at play.mvc.Router.load(Router.java:48)
at play.mvc.Router.detectChanges(Router.java:219)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.NullPointerException
at play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:266)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:478)
at play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:282)
at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:424)
at play.classloading.ApplicationClassloader.getAssignableClasses(ApplicationClassloader.java:453)
at play.classloading.ApplicationClassloader$getAssignableClasses.call(Unknown Source)
at {module:crud}/app/views/tags/crud/types.tag.(line:3)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:232)
... 9 more
—————UPDATE—————-
CRUD routes that i use in routes file. do i need to delete them ?
#{crud.types}
GET /? ${type.controllerClass.name.substring(12).replace('$','')}.index
GET /${type.controllerName} ${type.controllerClass.name.substring(12).replace('$','')}.list
GET /${type.controllerName}/new ${type.controllerClass.name.substring(12).replace('$','')}.blank
GET /${type.controllerName}/{id} ${type.controllerClass.name.substring(12).replace('$','')}.show
GET /${type.controllerName}/{id}/{field} ${type.controllerClass.name.substring(12).replace('$','')}.attachment
GET /${type.controllerName}/{id}/edit ${type.controllerClass.name.substring(12).replace('$','')}.edit
POST /${type.controllerName} ${type.controllerClass.name.substring(12).replace('$','')}.create
POST /${type.controllerName}/{id} ${type.controllerClass.name.substring(12).replace('$','')}.save
DELETE /${type.controllerName}/{id} ${type.controllerClass.name.substring(12).replace('$','')}.delete
#{/crud.types}