You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Grails 4.0.3 and Grails 3.3.11, if you have a domain class named A, e.g.
package mypackage
abstract class A {
String name
// ...
// properties
// ...
}
And you populate it in Bootstrap.groovy, e.g.
package mypackage
class BootStrap {
def init = { servletContext ->
A.withTransaction { status ->
A.saveAll(
new A( name: "a1" ),
new A( name: "a2" ),
new A( name: "a3" )
)
}
}
def destroy = {
}
}
If you use scaffolding (create-scaffold-controller A), everything works correctly.
But if you delete the scaffolding controller and generate-all for your class A, everything fails throwing a java.lang.NullPointerException because the AService aService object is null in AController.groovy, i.e. the service object is not properly injected in the controller.
Now, if you delete all the generated files except the domain class file (A.groovy), rename the file and the class as, let's say, A1, and generate-all again, everything works!
You can try with any one-letter named classes, e.g. A, B, X, etc., and the generated code always fails for the same reason. Add another character to the class name, regenerate, and everything works!
I suppose there must be some name clash somewhere when a class is named with a single character.
The text was updated successfully, but these errors were encountered:
@amador-duran-toro FYI... The BootStrap code that you quoted in the question doesn't have any affect on and is not affected by the scaffolding issue in question. I don't think BootStrap should be involved.
In Grails 4.0.3 and Grails 3.3.11, if you have a domain class named
A
, e.g.And you populate it in
Bootstrap.groovy
, e.g.If you use scaffolding (
create-scaffold-controller A
), everything works correctly.But if you delete the scaffolding controller and
generate-all
for your classA
, everything fails throwing ajava.lang.NullPointerException
because theAService aService
object isnull
inAController.groovy
, i.e. the service object is not properly injected in the controller.Now, if you delete all the generated files except the domain class file (
A.groovy
), rename the file and the class as, let's say,A1
, andgenerate-all
again, everything works!You can try with any one-letter named classes, e.g.
A
,B
,X
, etc., and the generated code always fails for the same reason. Add another character to the class name, regenerate, and everything works!I suppose there must be some name clash somewhere when a class is named with a single character.
The text was updated successfully, but these errors were encountered: