8

Strangely I am not having any compile-time error but while running the application I am getting NoClassDefFound error for Groovy classes.

I am using Eclipse 3.6 with Groovy 2.7.0 plugin. I have Groovy 1.8.5 installed on my machine and groovy-all.jar is in my classpath of application.

I can see all the groovy files in WEB-INF/classes folder with .groovy extension not with .class extension.

What I am missing here?

2
  • 1
    How are you compiling? How are you running it? What's on your classpath? What's in your Jar? Commented May 8, 2012 at 13:12
  • What version of Eclipse? What version of Groovy? Up to date Groovy plugin? ...*sigh*... Commented May 8, 2012 at 13:25

2 Answers 2

11

Two possibilities:

  1. You project is not a groovy project and so your groovy files are being treated as resources (not sources). Resources are copied to the output folder, whereas sources are compiled. Make sure that your project icon has a little GR symbol on it.

  2. Or perhaps you have inadvertently enabled script folders for the source folder where your groovy files are located. Go to Preferences -> Groovy -> Compiler and look at the section on Groovy Script Folders. Note that Groovy Script folders can also be configured on a per-project basis, so you may also need to look at Project -> Properties -> Groovy Compiler.

Sign up to request clarification or add additional context in comments.

Comments

2

Make sure you are executing the code using groovy and not java. Otherwise, you will have to link the groovy.jar file in your classpath. See this discussion.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.