Where to edit grails startup command line in IntelliJ IDEA? - grails

Grails-2.5.0 startup fails if fork mode is disabled.
I've found a workaround at https://jira.grails.org/browse/GRAILS-12129, which says;
Don't use the spring loaded java agent. Removing the following from the command started by IntelliJ is enough
But I cannot find where the command is written.
Run -> Edit Configurations doesn't have any option to disable agent.
Where should I edit?

If you open the run configuration you should see fields like Module, Command Line, VM options and more. So add this to the Command Line field
-noreloading -Ddisable.auto.recompile=true run-app
That should stop Grails from reloading your application.

Related

Grails/aNimble on Windows : Getting cannot find the specified path

I am trying to setup aNimble on Windows following this article.
I have setup the Java and MySQL (xampp) on Windows and both are working properly.
Now, as the final step I need to execute
grails prod execute-database-scripts-all
but I am getting cannot find the specified path. Even when I type grails only I get the same error. I have zero experience in Grails, but it seems that I need to install Grails first on the PC. Until I do this, I want to know is there anything else that I need to do this to successfully execute this command.
What are the three portions of this command grails, prod and execute-database-scripts-all
This error means that Windows is unable to find grails executable anywhere it looks (in any paths specified in PATH system property) when you typing grails command. You may have to follow this guide in order to install grails application framework properly in your system (also, make sure you are installing a correct version of grails compatible with your distribution of aNimble) and then retry.
Grails is a web application framework and which provides a set of tools to develop, build and run web applications like aNimble, prod is a command line option for grails telling it to run in a production mode and execute-database-scripts-all is aNimble-specific command to initialize it's database.

Debug a Grails 3.x application

I am trying to debug a Grails 3.x application using grails run-app --debug-fork. But when the application starts it does not wait for the debugger to attach. Any solution on how to debug a Grails 3.x application?
Please use the --debug-jvm flag.
For example: grails --debug-jvm run-app
In IntelliJ you can right click the Gradle task bootRun and select Debug.
The other option is to directly run the Application class located in grails-app/init. It has a static void main and be run as a regular application. You can run it directly from your IDE with a debug profile.
In IntelliJ IDEA 2016.1, I create two configurations. This allows me to make solid use of all the context menus, etc. that IntelliJ IDEA offers. Here's how:
The first configuration is a "Run" configuration. Edit the default
configuration and in the "Command Line" field, enter
run-app --debug-jvm
The second configuration is a "Remote" configuration. On the "Run/Debug" dialog, click the + symbol and select "Remote" from the
list. Name it "Debug" and save.
Select your "Run" config from the config dropdown at the top and then click the green arrow to run the app. Monitor the console
output until you see the message
Listening for transport dt_socket at address: 5005.
Select the remote debug profile you created in step 2 and click the debug button. In a few moments the console output will say
Grails application running at http://localhost:8080 in environment: development.
Success!

Glassfish 2.1 classpath-prefix or classpath-suffix not loading

Hope you can help me here, I am trying to add some new jars to the classpath of the glasspath, but they just fail to load up.
I am using glassfish 2.1
Here's the snippet when the server is started
-Dcom.sun.aas.ClassPathPrefix=../grops/lib/grops-4.3.5.jar;../grops/lib/iaik_jce_full_3.13.jar;../grops/config
-Dcom.sun.aas.ClassPathSuffix=
-Dcom.sun.aas.ServerClassPath=
Snippet from my domain.xml
java-config classpath-suffix="../grops/lib/grops-4.3.5.jar${path.separator}../grops/lib/iaik_jce_full_3.13.jar${path.separator}../grops/config${path.separator}../grops/lib/zmd-security-LU2.jar${path.separator}../grops/lib/db2jcc.jar${path.separator}../grops/lib/db2jcc_javax.jar${path.separator}..........
I have tried from admin console and also changing directly in domain.xml , they just dont load up and always throw an error java.lang.NoClassDefFoundError
I have solved this by myself, actually whenever we add something to the classpath newly a new command window has to be used to restart the glassfish server:
ex run-->cmd--> cd C:\glassfish\bin
asadmin --> start-domain xxx
This has to be done by closing the previous command window after stopping the server by stop-domain because everytime you run asadmin command, asenv is called which sets the new parameters to the JVM.

grails is not recognized as an internal or external command

Hi i installed grails at
c:/grails
directory on my windows 7
after that i created GRAILS_HOME environment variable as mentioned on grails website
but now when i run this command
grails integrate-with --intellij
on command prompt it throws an error :
grails is not recognized as an internal or external command
any thoughts what i am doing wrong here
I have faced the same problem and did as follows to get rid off.
Although you have already mentioned that, you set Environment variables. I am assuring again:
In environment variables dialogue: (user variables section)
1. Set GRAILS_HOME to your extracted grails version as GRAILS_HOME=D:\GrailsEnvironment\grails-2.1.1
2. Set JAVA_HOME to your installed jdk version as JAVA_HOME=C:\Program Files\Java\jdk1.7.0_04
In environment variables dialogue: (System variables section)
1. Edit path and add D:\GrailsEnvironment\grails-2.1.1\bin
2. Edit path and add C:\Program Files\Java\jdk1.7.0_04\bin
If needed reboot your pc again. and in command prompt run 'grails -version' and 'java -version' command to check whether grails and java were perfectly installed.
If error shows then may be your grails package is corrupted, Extract your grails package newly in the specified path again. run the command to check. if necessary reboot and run command.
Thanks

How to use command to shutdown grails run-app

After executing grails run-app, except using Ctrl + C", is there a command to shutdown it?
For Stop Server
Exit from the terminal and use any one from the commands below:
grails exit
grails stop-app
grails quit
No. grails run-app is intended to be run for development, interactively.
If you want to control grails as a service, you should deploy it to a web application container such as tomcat. The tomcat plugin allows you to easily deploy your app to tomcat, for example. Add lines like
tomcat.deploy.username="manager"
tomcat.deploy.password="secret"
tomcat.deploy.url="http://myserver.com/manager"
to Config.groovy and then you can use
grails tomcat deploy
grails tomcat undeploy
to start and stop your application. Alternatively, you can use grails war to bundle your app into a war archive which all java app servers should be able to use.
If you really want to stop grails run-app without Ctrl+C, write a small controller that calls System.exit(0). Then browse to that URL, or write a small shell script or batch file that invokes it with e.g. wget or curl.
Open a new command line window, go to the project directory and type:
grails stop-app
This will stop the application if it is running in forked mode.
You can then go to the same URL and see that the page won't be displayed, i.e., the server has been stopped as it will be specified also when the command executes.
grails exit
This will stop the application if running in non-forked mode, otherwise it will quit the console.
grails quit
Exits the console.
in Grails 2.3.3, running 'grails dev run-app' on the command line leaves the command window in a kind-of limbo. It does not give you back the command prompt, Ctrl-C does nothing, and you have to revert to killing the processes by hand.
It is much more pleasant to follow the intended usage, as follows:
On the command line, enter the command 'grails' and hit return (notice no parameters are given). This starts grails itself, (and only grails, i.e. it does not start your server or app). This results in one new java process. It also gives you back the grails prompt, so you are still in control.
1.1 At the grails prompt, you can start your server (and app), by typing 'run-app'. This starts your server (in dev mode), and again gives you back the grails prompt. With your server running, you now have two java processes running, one for grails, and the other for your server and app.
1.2 If you want to stop your server (and app), you can, at the grails prompt, enter 'stop-app', which will stop the server and app. Also, you get your grails prompt back. After stopping your server/app, you will be back to having just one java process running, i.e. grails.
1.3 At the grails prompt, you can start and stop your app as many times as you like.
1.4 To stop grails itself, at the grails prompt, you can enter 'exit' or 'quit', and then grails will quit, and leave you back with the normal command prompt. At this point, the grails java process should be gone too, so there should be no java processes running.
I believe all of grails 2.3.x behaves like this.
My system is windows 7.
Hope this helps.
Noel
In Grails 2.1.0, a simple "exit" stops the server
I found a neat way that works on Grails 2.0.1 for me.
This is a hack that uses a hack put in GrailsRun.groovy for shutting down servers after running functional tests. (see line 246)
Create a file in the application basedir named .kill-run-app
When Grails sees the .kill-run-app file, it issues a grailsServer.stop(). It also conveniently deletes the file. This may depend on having autoRecompile on. I'm not sure, like I said this is a hack.
One day it will most likely cease to work when the GrailsRun.groovy script is changed.
I created a simple Ant target to do this. Granted you will need another terminal to execute it (actually I run it from Eclipse).
<target name="kill-app" description="--> Kills Grails web application" depends="">
<touch file="${basedir}/.kill-run-app"/>
</target>
Quick way is to kill the java process:
ps -aux | grep grails
kill "proess ID from above that is container to your application"
I'm new to Grails and I also had this "problem". I wrote a little script (called grill ;-)) that kills all the grails-processes.
#!/bin/bash
for P in $(ps aux | grep grails | grep java | awk '{print $2};'); do
kill -9 $P
done
exit 0
I had same problem to stop my running grails server. I did
ps aux | grep grails --> that gave me the PID
kill -9 PID
That way I was able to stop my running server. Hope that helps.

Resources