How to get Grails create-app working - New app homepage is getting 404 - grails

Hyper-V Ubuntu 20.04LTS
Grails 5.1.9
JDK 11.0.15
Groovy 4.0.3
SDKMAN
I am getting this after I run grails run-app. It never gets to 100% (I am assuming it should). I can hit the main url or localhost:8080, but get 404 (localhost:8080/myapp) using the appname I created with 'grails create-app myapp' or 'grails create-app myapp --profile=web'. I am 1 day into grails. I did check the controller code, and there is code for '/', 'index'.
grails run-app image

It never gets to 100% (I am assuming it should)
That is a reasonable expectation, but not the way it works. It never gets to 100% because technically it isn't done until the process terminates. As long as the app is running, the task is still in progress.
By default your context root will be localhost:8080/, not localhost:8080/myapp.

Related

"Error occurred running Grails CLI: null" when running grails 3.0 command line

I'm trying to run grails list-profiles, but receive the following error:
snowch#snowch-ws2:~/repos$ grails list-profiles --stacktrace
| Error Error occurred running Grails CLI: null (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NullPointerException
at org.grails.cli.profile.git.GitProfileRepository.getAllProfiles(GitProfileRepository.groovy:72)
at org.grails.cli.profile.commands.ListProfilesCommand.handle(ListProfilesCommand.groovy:43)
at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:173)
at org.grails.cli.GrailsCli.main(GrailsCli.groovy:99)
| Error Error occurred running Grails CLI: null
My versions are:
snowch#snowch-ws2:~/repos$ grails --version
| Grails Version: 3.0.1
| Groovy Version: 2.4.3
| JVM Version: 1.7.0_75
This was on a fresh install of grails and gvm.
The command grails create-app myapp works without error.
This question is similar to Grails 3.0 error, nullpointer, however, that question does not state what command is being run.
After searching online, I found that I needed to set my GRAILS_OPTS environment variable as follows before running the command:
export GRAILS_OPTS="-XX:-UseSplitVerifier -Xverify:none"
Source of fix: https://grails.org/news/1292028
I have not figured out, what is the exact cause of the error, but it seems to occur if you try to run grails 3 in the system where grails 2 is also installed.
What I did to get the command run - I created the project in a new directory. The directory for my old grails app was:
/home/me/projects/oldgrailsapp
when I tried to execute the grails command in /home/me/projects it failed, but when I tried this in another directory /home/me/projects_new, it succeeded. So I guess that the problem was that old grails configuration was somehow interfering with the new one.
I also removed references to old grails and groovy versions from the PATH variable by editing .bashrc file in my home directory (I really do not know if it was needed).
I had same experience when I was working on "Building an Andoird Client" guide, I got the following message whenever I try to create an app in the same folder where I've created the first app grails-app :
| Error Error occurred running Grails CLI: null (Use --stacktrace to see the ful
l trace)
So obviously, when you create a grails app in folder containing "grails-app" directory, grails will consider this folder as full grails application, hence cannot create-app in that directory.
I used:
Grails 3.1.15
Java 1.8.0.101
Hope this help.
It worked for me now.
this was my setting
GRAILS_HOME=C:\Users\murali.solayappan\apps\grails-3.1.11
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_102
I received the same error while launching "grails" for the first time
**Error occurred running Grails CLI: connect timed out**
After reading GRAILS_HOME\bin\grails.bat i found that executing "grails" while in GRAILS_HOME dir makes some difference. So I did the same
Now i received error stating that GRAILS couldn't find a particular maven package from my mirror repository - printed my private nexus repository url. I know that's my private repo and not connected to internet.
so I changed the MY_HOME_DIR.m2\"settings.xml" with the one came by default in Maven.
After that executed "grails" while in %GRAILS_HOME% dir.
It worked like breeze !!! I got grails prompt.
C:\Users\murali.solayappan\apps>grails
| Enter a command name to run. Use TAB for completion:
grails> exit
Somethimes it happens when you have wrong version of grails installed for the project you want to run it on
try to run it somewhere else and see if you get the same error
i had the same issue because i was using Grails 1.3.5 witj Java 8 which are incompatibles. I changed with Java 7 and it works fine.

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 2.3 & GGTS 3.4 stop button not working

How to stop grails processes in GGTS 3.4 with grails 2.3. the stop button of GGTS is not stopping the server running and the java.exe processes are still showing in task manager.
Comment the grails.project.fork = [ .. ] part of your BuildConfig.groovy file.
This part enables running run-app, test-app and war in different threads(so you don't have to stop one to start the other), and it seems ggts isn't successfully destroying the thread right now.
For reference, here is the related issue in the ggts bug tracker https://issuetracker.springsource.com/browse/STS-3522
Can you try to disable the "Keep external Grails running" option in Eclipse Preferences -> Groovy -> Grails -> Grails Launcher?
Unchecking the "Keep external Grails running" does not work for me. What I do is to hit the "Grails Command History" icon and type "stopApp" (or pick stopApp if previously typed). Once this commands finishes executing, then you can stop the Grails application using the stop button.
Using Groovy Grails Tool Suite GGTS 3.4.0 on windows 64x. For my simple projects, the stop button works. For a bigger complex project, it does not. I use the "stop-app" (opposite of "run-app"). See: 2.8 Running an Application in the getting started guide. I think that in older versions of Grails ( < 2.x something) you had to create your own "stop-app" script. I think the newer 2.3.x has it built in.
I am using GGTS 3.5.1, Grails 2.3.8, Java1.7 over Windows configuration the command is works for me "stop-app" and "run-app"

new grails project won't start

I'm trying to get my feet wet with grails, so I'm following a tutorial to get going with a sample project. I downloaded grails 2.3.2, added the environment variables for the command prompt commands, and successfully created a project by using >grails create-app teamwork. Calling >grails run-app after changing to the project directory successfully downloads all requisites, but then I get . I know that this exception doesn't reveal much, but do you guys have any ideas on why? I am running command prompt in admin mode, if that means anything.
Try not forking the JVM in BuildConfig.groovy, if I recall correctly. If that works, then check the JIRA issues for Grails 2.3.2.

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