IntelliJ Grails 3 Project: Unable to Run Grails project - grails

I recently installed IntelliJ onto my machine after many unsuccessful attempt to get GGTS working reliably. So far the error messages were clear and easy to resolve after I imported my Grails project. GGTS had forced me to downgrade from Grails 3 to 2 because, at the time, GGTS does not seem to support Grails 3. I ran into issues after pointing IntelliJ to Grails 3, but restarting IntelliJ seemed to fix those problems. Now, however, I can't get my project to start and I get the following error:
"C:\Program Files\Java\jdk1.8.0_51\bin\java" ...;C:\dev\grails-3.0.4\lib\xalan\serializer\jars\serializer-2.7.2.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 15.0\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.grails.cli.GrailsCli run-app
Error |
Problem updating profiles from origin git repository (Use --stacktrace to see the full trace)
Error |
Could not checkout tag for Grails release [3.0.4]: repository not found: C:\Users\Randeep\.grails\repository (Use --stacktrace to see the full trace)
Error |
Error occurred running Grails CLI: No profile found for name [web]. (Use --stacktrace to see the full trace)
Process finished with exit code 1
Note the "Problem updating profiles from origin git repository" message. This is a git project, but I don't know why IntelliJ is trying to do any git operations (I don't want it to, I just want it to run my project).

There's a lot going on behind the scenes with grails here. The CLI (command line interface) is trying to load a profile called web. Basically grails creates a .grails folder in your home directory that contains a set of default profiles (see ~/.grails/repository/profiles).
Somehow this folder got corrupted or modified on my system and the web profile, which is the default profile, disappeared. To fix this I simply deleted the .grails folder from my home directory, ran grails, and it regenerated.
Edit: Deleting your .grails folder may have undesirable behavior if other projects are using data within it, so try deleting the profiles folder first.

I got this error message too after I delete ~/.grails ~/.gradle from my home directory.
Thoses directories seems won't created again for some reason, and grails clean isn't work at the same time.
This how I fixed it, hope it helps.
set up JAVA_HOME / GRAILS_HOME variables.
cd GRAILS_HOME (ie. /etc/grails/grails-3.1.4 )
execute 'bin/grails'
create-profile web
grails will try to create a new web profile, and start downloading dependency jars.
exit. & done.
ps. my environment.
jdk 1.7.0_4
grails 3.1.4

IntelliJ is trying to download a Grails profile called 'web' and it is unable. Enable --stacktrace and dig into the problem.
Or Create a new project in IntelliJ and point it to your source.
Note: Your project should be a Grails 3.0.X to use profiles.

I stumbled across this question when my Grails 3.2.8 app was reporting a similar problem for react.
Error occurred running Grails CLI: No profile found for name [react]
I do not have a .grails/profile folder, for whatever reason, and didn't want to trash the whole .grails folder right off the bat, so I ended up :
reimporting my project into the IDE
refreshed the grails dependencies
cleaned the grails project
and it worked for me.

Related

Why is Grails completely broken since Sunday and why is no one noticing?

Since Sunday, I and my co-worker cannot build any Grails project nor even create a new Grails app of any version. We have completely independent development environments.
For example:
$ grails create-app --profile web junk
| Error Error occurred running Grails CLI: Could not find artifact org.grails:grails-bom:pom:4.0.10 in grailsCentral (https://repo.grails.org/grails/core) (Use --stacktrace to see the full trace)
./gradlew dependencies also fails with Could not find org.grails:grails-gradle-model:3.2.13).
The repository repo.grails.org is up, but when I browse it, it is very slow and missing many, many artifacts.
Is their a way to configure build.gradle to fix this? We have several Grails projects using different versions, mostly using the default repository configuration.
There's actually been some discussion here on stackoverflow, but more on a github issue: https://github.com/grails/grails-core/issues/11825
You can certainly read that issue for far more info than makes sense to post here, but the short version is: URL changed unintentionally, temporary workaround is to move to https://repo.grails.org/artifactory/core
I guess we have an official message related to this issue in grails blog - https://grails.org/blog/2021-06-10-grails-wrapper-update.html

Running Grails 3 app on Intellij

I created a default Grails 3 app using the following commandline:
$ grails create-app myapp --profile web --features mongodb,asset-pipeline
And then, I opened the project in IntelliJ IDE 2016.1.
In the first time, the app started correctly. But, I cannot run it anymore due to the following error:
Error running Grails: myapp: Grails application is not found.
I tried to reconfigure the running configurations, but my project is not in the list at all, as shown in the following figure:
IntelliJ Project configuration
Can anybody help me, please?
To restore sanity to IntelliJ configuration files, the simplest solution on Grails > 3 is to let gradle do the work for you. First close the project in Intellij, then from a *sh shell cd to your project directory and run 'gradle cleanIdea idea'. Reopen the project in IntelliJ. If you were able to start your app with 'grails run-app,' you should now be able to run the app again from within IntelliJ Idea. This works for me whenever IntelliJ starts displaying the same 'no Grails application' message on opening a project.

Intellij IDEA 14 Errors with grails run-app

I upgraded to IDEA 14 (from 13) and when I attempt to run my grails 2.2.0 application, I am getting the following error:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/gdboling/Projects/GenRocket/web/build.gradle' line: 92
* What went wrong:
A problem occurred evaluating root project 'web'.
> No such property: environment for class: org.gradle.api.internal.project.DefaultProject_Decorated
It would seem that IDEA is attempting to use my build.gradle as part of the grails build process. IDEA 13 didn't do this. I use the build.gradle for some other non-grails related tasks for the project.
If I remove the build.gradle file all together, I get this error:
FAILURE: Build failed with an exception.
* What went wrong:
Task 'grails-run-app' not found in root project 'web'.
* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I do see the Grails View in the IDE but when I try and do a Make, it is telling me to re-import the gradle project. So it would seem that IntelliJ think this is a gradle project. How I can tell it that is is just a grails project?
To confirm my suspicions, I've opened a grails project that did not contain a build.gradle and it works just fine.
I had faced similar issue when unknowingly kept on hit next next in hurry. So, you probably mistakenly created a gradle project as shown in screenshot.
And when you recreated the project created it as "Create project from existing source" which idea well knows as grails-app (default for idea).
See if you can reproduce the error by re-importing the project using import project form external module.

Using Grails 2.4.3 in IntelliJ

I've been unable to create/import a Grails 2.4.3 project with IntelliJ 13.1.4. For example, when I create a new module, choose Grails, then click the create button (highlighted below) and choose the location where Grails 2.4.3 is installed, the project is not created correctly (I get a module with just a /src directory instead of a Grails project) and Grails 2.4.3 is not added to the list of Global Libraries. I don't have this problem with any earlier version of Grails.
I have used Grails 2.4.2 with Intellij 13.1.4 successfully. What I did is create the application with the grails create-app command and then do a File / Import Project in Intellij. Give that a try.
As an alternative solution to the IntelliJ 13.1.4 and Grails 2.4.3 bug you can:
grails create app <app-name>
cd app-name
grails integrate-with --intellij
This configured the project correctly for me with just minor tweaks to SDK and application server. This is a minor twist on the work around described above.
See grails doc here
I had the same problem with IntelliJ 13.1.4 and Grails 2.4.3, which i just downloaded.
After using the grails create-app command from the command line i had to import the project, by "create from existing sources" (point to the new top level folder), "Configure SDK" (to set for the Grails 2.4.3) and finally edit the run configuration. In a second test run with a new test project i did not have too configure the run config.
Then the Grails libs for the were downloaded and the basic app ran. Also the Grails specific option in the Intellij "Tools2 section were suddenly available.
So the given answer by Joe is the way to setup a new Grails project but the IDE should be fixed anyways.
It is not consistent. After several tries I can get some applications to work but it does not seem to be automatic. I think I am going to go back to Grails 2.4.2 until this is resolved within Intellij 13.1.4.
In the screenshot above, there are options for groovy/grails/griffon, and so far the alternative offered was command-line. Try choosing groovy option within intelliJ.
We are using IDEA 13.1.4 with grails 1.3.7 and grails 2.2.1(diff projects) and saw the same issue. It appears this is an intelliJ issue and not so much the grails version, so reverting your grails won't gain you anything. Choosing groovy, you should see a prompt for grails directory structure. This does work if you are presented with this option. Seeing inconsistencies here. Thanks to all for posting your workarounds; never hurts to have multiple approaches.
-Duane

Error installing Grails plugin to local maven repository

I have created a Grails plugin using Grails 2.3.3 and trying to use the plugin in a Grails application which was also created using Grails 2.3.3. Now, to use the plugin in the application, it needs to be published to a plugin repository first. So I attempted to publish the plugin into the local repository by using the commands:
grails clean
grails compile
grails maven-install
For the grails maven-install command I selected the option 2)InstallPlugin. But then got an error:
Error installing plugin: No such property: ERROR_MESSAGE for class: Inst
allPlugin (Use --stacktrace to see the full trace)
Ran the last command above with option --stacktrace and --verbose but did not get any clue as to what the problem might be. I also removed %HOME%/.grails directory and reran the above commands and still came with the same error.
After googling, I found a JIRA for this issue which was closed stating that it happens when Grails version is changed and cleaning up cache files will get rid of this issue. However, that solution is not working for me and, by now, I have spent couple of hours trying to fix this. Also I did not change my Grails version.
Has anyone faced this issue with Grails 2.3.3 or with any recent version of Grails? What was the solution?
Don't use install-plugin, add a dependency in BuildConfig.groovy.
I don't know where the 2)InstallPlugin "option" is coming from. The maven-install script packages your plugin and generates a POM file and the other files needed to be a valid published plugins. Then it copies these files to your local M2 directory, e.g. if your plugin name is "mycoolplugin" the files are copied to $HOME/.m2/repository/org/grails/plugins/mycoolplugin
Now you can "install" the plugin as if it had been published in a remote repo. Add a dependency in the app's BuildConfig.groovy using the usual format, e.g.
plugins {
build ":tomcat:7.0.50"
compile ":scaffolding:2.0.1"
runtime ":hibernate:3.6.10.7"
...
compile ":mycoolplugin:0.1"
}

Resources