Reputation: 1841
i think this is an easy one for you:
I have a Controller in which i want to access a static field within another class XY (groovy class, located in package src/groovy ...). But this gets an NoClassDefFoundError.
public class XY{ public static final String a = "something" }
in controller: XY.a causes error!!!
Other classes in the same package than Class XY dont cause problems.
what i am doing wrong?
Upvotes: 0
Views: 354
Reputation: 1841
I found out what the problem was:
The class XY compiled, but i tried to assign a "" to a (accidentallydeclared) static integer.
That was the reason why the whole class could not be initialized and the error occoured.
Are there any propertys to set the compiler to print warnings?
Thanks for your hints!
Upvotes: 0
Reputation: 75671
It appears that you've oversimplified the example. NoClassDefFoundError
is not the same as ClassNotFoundException
. ClassNotFoundException
happens when the class isn't there. NoClassDefFoundError
happens when the class is there, but something that it references isn't. So it's a lot trickier to fix.
Does the XY package match the folder structure (i.e. if it's in the "com.foo" package, is it in src/groovy/com/foo)?
Try running 'grails clean' and running it again - it could be that there's some compiler confusion and re-compiling everything could fix it, or show the real problem.
Upvotes: 1