Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails 3.2.0.M1 Template not found for name

In my domain class com.example.users.User I added transient field carnets:

class User implements Serializable {
    ...
    def carnets

    static transients = ['springSecurityService', 'carnets']
    ...
}

and in my gson view user/_user.gson I'd like to render it:

import com.example.users.User

model {
    User user
}

json g.render(user, [excludes:['password', 'deleted', 'enabled', 'accountExpired', 'accountLocked', 'passwordExpired', 'authorities']]) {
    //"carnets" g.render(template:"/carnet/index", collection: user.carnets, var:'carnets')
    "carnets" tmpl.'/carnet/index'(user.carnets)
}

but I've received:

Caused by: grails.views.ViewRenderException: Error rendering view: Template not found for name /carnet/index

Carnet's views gson files were autogenerated and works fine when executed from CarnetController.

What am I missing?

like image 476
Michal_Szulc Avatar asked Feb 05 '23 18:02

Michal_Szulc


1 Answers

In my use case (Grails 3.3.0), I had to change the template path from: tmpl.'message/message' to: tmpl.'/message/message' (added leading slash).

Using the ../ syntax worked in development, but caused an error for me when deploying the WAR file to Tomcat. See: [https://github.com/grails/grails-views/issues/140]

like image 96
RMorrisey Avatar answered May 24 '23 00:05

RMorrisey