Silver Jay
Silver Jay

Reputation: 576

Grails NoClassDefFoundError: Could not initialize class

I have added a jar in to lib folder and refresh dependencies but there is always Caused by NoClassDefFoundError: Could not initialize class. Maybe somebody have some ideas?

Upvotes: 2

Views: 2541

Answers (1)

Burt Beckwith
Burt Beckwith

Reputation: 75671

You'll get a ClassNotFoundException if you try to load a class that isn't in the classpath, but NoClassDefFoundError is quite different and often tricky to resolve. This is because they occur when the class exists, but another class (or a resource in some cases) that it depends on cannot be loaded.

Try to find out what other libraries are needed by this jar file. http://mvnrepository.com/ is a great site for displaying library dependencies. Of course, if this jar is in a public Maven repo, you should delete it from the lib dir and change to using a dependency in BuildConfig.groovy. That way it will be downloaded once and cached, and reused in multiple projects, and all of its dependencies and transitive dependencies will also be downloaded and added to the classpath.

Upvotes: 3

Related Questions