grails.util.Metadata.getServletVersion throws java.lang.NullPointerException

Viewed 21

Calling Holders.grailsApplication.metadata.getServletVersion() throws the following error wherever I place the code:

java.lang.NullPointerException: null
        at java.util.Objects.requireNonNull(Objects.java:203)
        at java.util.Optional.<init>(Optional.java:96)
        at java.util.Optional.of(Optional.java:108)
        at grails.util.Metadata.getServletVersion(Metadata.groovy:284)
        at grails.util.Metadata$getServletVersion$1.call(Unknown Source)      
1 Answers

Add the following to application.yml:

info:
    app:
        servletVersion: '3.0'

Or set through the command line:

./gradlew bootRun -Dinfo.app.servletVersion=3.0

Having the following in your bootRun block in build.gradle:

bootRun {
    systemProperties(System.getProperties())
}
Related