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.
Related
I have a Spock unit test in a Grails app. In IntelliJ IDEa I can either run it with grails environment and then it means I wait a minute until the environment loads to run the test even though I do not need the environment.
The other option is to run it with JUnit. This works nicely in a Grails app without my own plugins. However, when I run it in a Grails app that has a plugin of another Grails app I have, it crashes on NoClassFound. It does not see the classes from the plugin that I included.
When I checked in IDEa the project structure, indeed the sources nowhere include a folder where the plugin classes would be included. For some reason the plugins in plugins section in BuildConfig.groovy do not appear in the classpath anywhere, they are not found in the external libraries section or anywhere else.
Is there a way to tell grails not to spin up its environment when running some of my tests? Or how can I include my plugin in the classpath for Groovyc to see it when building for testing?
The problem occurs also when simply pressing Build Project in IntelliJ IDEa. The project we are working with is simply run with grails and is never built (beyond how grails builds it). When you try to build it in IDEa, it fails on NoClassDefFound of plugin class.
Versions:
IntelliJ IDEa 2021.2
Grails 2.5.6
EDIT: Ok, it seems like grails apps are to be tested via their command-linke with grails test-app. When Grails runs in interactive mode, test-app won't have to reinitialize the environment, cause it's already running, so it runs faster.
However, as I found here Slow Grails test starting in Intellij IDEA it seems like there's no way to run grails in interactive mode from within IDEa in a way that would enable IDEa test runs to use such interactive console. Which means I'm forced to run tests via command-line. Not happy.
Edit 2: At some point in time I have managed to get the compiled tested.class to the out folder. This enabled running the test instantly via IDEa circumventing the Grails glory. However, I have no idea how I got it to out folder and after removing it I am unable to compile it again and get it there.
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.
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.
I am unable to clean, compile my individual grails project .
If I try running compile --stacktrace or --verbose on project 'X_Project' throws me the below error
Problem executing: compile --stacktrace
The command 'GrailsCommand(P/X_Project> --noreloading compile --stacktrace)' was terminated because it didn't produce new output for some time.
See details for the output produced so far.
If you think the command simply needed more time, you can increase the time limit in the Grails preferences page.
See menu Windows >> Preferences >> Grails >> Launch
Command: GrailsCommand(P/X_Project> --noreloading compile --stacktrace)
---- System.out ----
Loading Grails 2.2.3
---- System.err ----
Couldn't collect a stacktrace because Grails process was not found
------System.out:-----------
Loading Grails 2.2.3
------System.err:-----------
Couldn't collect a stacktrace because Grails process was not found.
I'm a bit lost at the moment.Maybe someone can give me a hint about where to search for the error/problem.
Version am using : Grails 2.2.3 , Groovy/Grails Tool Suite Version: 3.3.0.RELEASE.
Thanks in advance...
First thing that I would try is to run Grails project on it's own from a console. Make sure that your OS has correct path to grails installation. Go to the project folder and run: grails run-app
If it runs from console then you know the issue is in the IDE. Now you have a decision to make: run Grails project from console or use IDE - your choice. Here are my 2 cents:
Now I am not a big fan of Groovy/Grails Tool Suite in the first place. When I used Eclipse, I use to install Eclipse separately and then install Groovy & Grails plugins. This approach allows you to have a "standard" Eclipse without any restrictions and run Groovy & Grails without being constrained to a specific version. Now having said that you can try the approach.
If you don't want Eclipse, you can always use IntelliJ - it plays very well with Grails. IMHO it is working better with Grails than Groovy/Grails Tool Suite.
I have downloaded my grails project from SVN and tried to run it.Project Using grails 2.0.4 version.I'm using STS 3.0 version.I have set the JAVA_HOME properly and added the proper grails compiler in the STS.
When i try to run the project it throws the following error and build not starting up
The command '\bin\javaw.exe' was terminated because it didn't produce new output for some time.
Can anyone please help?
It's a problem related with the way Grails executes multiple commands through a single external process. If you are in Eclipse (+GGTS plugin), go to "Windows > Preferences > Groovy > Grails > Grails Launch", then disable the "Keep External Grails Running" option.
This is also happening in GGTS.
My workaround to this is to create Run Configuration. Open Run Configurations, double click Grails, it will create new Grails configuration. Rename it, select your project and enter grails command: run-app. Click Apply or Run.
On the top toolbar where you have run configurations drop-down, it should include your new configuration. Running this way will not timeout.
This STS issue is kinda-related. Windows >> Preferences >> Grails >> Grails Launch is the place where you can find all the options.
I was getting this problem when I tried to use run-app from the grails command line. Try using the Run menu instead.
Run -> Run As -> Grails Command (run-app)
See this ticket.
I meet same problem when I try run war on my project. I fixed it by change setting in
Windows -> Preference -> Groovy -> Grails -> Grails Launch -> Grails Command Timeout[ms]
Change the timeout time to a big value.