IDEA 8 + Groovy (Grails), can't resolve "String"?

Hi all,

First time IDEA user, trying to play with Grails. I've done some things with Grails just using TextMate, but when I come over to IDEA, I get errors in .groovy files (like my first Domain Class) with just specifying "String" - its like the project settings don't include Java classes on the classpath? I didn't bring an existing project over, I just followed the wizards in IDEA to create a Grails project.

Any assistance would be appreciated.

Thanks,
Brice

7 comments
Comment actions Permalink

Hello Brice,

its like the project settings don't include Java
classes on the classpath? I didn't bring an existing project over, I
just followed the wizards in IDEA to create a Grails project.


If your assumption is correct, you need to check the grails module's dependencies
in the project structure dialog. If "No JDK" is shown, then - yes, you need
to define one and add to dependencies.

Normally new Grails module wizard either selects one of existent JDK definitions,
or suggests to create new.

Alexander.


0
Comment actions Permalink

You are missing JDK definition. Either you don't have one defined at all or attached to your project (module). Please check 'Project structure'

0
Comment actions Permalink

I've installed Groovy (1.6.1) and Grails (1.1) and both their homes (GROOVY_HOME and GRAILS_HOME) are correctly set.

After that, I've installed IntelliJ IDEA 8.1 and created a Grails project from the scratch. Created some domain classes with some String attributes in them and after Ctrl + Alt + G and 'run-app' I can successfully access my application using a browser.

The question is, the String attributes aren't recognized by IDEA (Cannot resolve symbol 'String'). In File -> Settings I can't find anything related to this and in the Project Structure the Language Level is set to 6.0, in the tab Dependencies right below the grails-1.1 I have 1.6 (java version "1.6.0_05").

Even if I want to import the String class, after writing 'import java.' IDEA can't autocomplete what I've wrote so I think it's somehow related with the JDK isn't correctly "defined" on IDEA or in the project.

Sorry about the totally newbie question, but didn't find any other way to solve this.


Thanks in advance

0
Comment actions Permalink

Could you attach your .ipr/.iml files?

0
Comment actions Permalink

My .iml file is attached.

Thanks for the quick reply.



Attachment(s):
MonitorizacaoBagagensWebApp.iml
0
Comment actions Permalink

Please ensure that your JDK (in project structure settings) is
configured correctly, with all the jars in classpath. If everything
seems correct, please try File | Invalidate caches action. Is 'String'
class available from Ctrl+N (Go to class)? If all this doesn't help,
could you please prepare a sample project with this problem and attach it?

0
Comment actions Permalink

Hi.

Found the error, I think it might be a bug. I've created the Grails project using the New Project Wizard. After that, created the application and it worked, despite of the fact that IntelliJ wasn't recognizing simple Java classes (like String). Neither the String class appeared when I did Ctrl + N. The JDK was added to the project but the classpath wasn't set (the Wizard didn't set the classpath at all). I deleted the existent JDK (pointing to C:\packages\jdk16_05) and added a JDK pointing to the same place. The added JDK automatically configured the classpath and after that everything worked.

IntelliJ IDEA 8.1
Grails 1.1
Groovy 1.6.1

Thanks for all your responses

0

Please sign in to leave a comment.