Reputation: 1611
I have the following two Groovy classes:
Buzz.groovy:
import widgets.Fizz
class Buzz {
def WhistleFeather
def init = { servletContext ->
WhistleFeather.load()
println "WhistleFeather loaded."
}
def destroy = { }
}
WhistleFeather.groovy:
package net.me.myapp
import widgets.Fizz
public class WhistleFeather {
def navMenu
def load() {
println "Loading!"
}
}
When execution gets to the WhistleFeather.load()
method call I'm getting a NullPointerException
. Can anyone see why?
Upvotes: 0
Views: 322
Reputation: 123986
WhistleFeather#load
is an instance method, not a static method. Either call it with new WhistleFeather().load(),
or turn it into a static method (static load() { ... }
).
Upvotes: 1