grails application terminating automatically - grails

I am doing sample application from git-hub [book-flow] I created domain classes,controller classes and also views of the book -flow application, then I executed the application in development mode but the application is terminated automatically in console it showed
Loading Grails 2.1.1
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 2 source files.....
| Running Grails application
I unable to find where is the problem and I want to know that where can I find the applications on grails other than github.

Srujan
I thought I give you more of an insight into grails now that I have a little time on my hands...
most of the grails should remember one day not too long ago we were also in the same boat and had no idea where to start...
I would suggest getting hold of a good book such as definitive guide to grails 2 and reading/experimenting....
To create a basic app with one object :
The following is using grails command line - so refer to No console output available on linux when executing grails/groovy for expoerting out java grails - I Guess you are windows so same but on windows environment...
$ grails create-app grails-example
$ cd grails-example
$ grails create-domain-class Books
$ vi grails-app/domain/grails/example/Books.groovy
cat grails-app/domain/grails/example/Books.groovy
package grails.example
class Books {
String name
static constraints = {
}
}
vi is a linux editing tool so use notepad and go to that path and as you can see I added
String name
save file now run:
$ grails generate-controller grails.example.Books
$ grails generate-view Books
$ grails generate-view grails.example.Books
$ grails run-app
As for general beginners guide, I came across this site today and have probably used in the past without noticing it...
http://grails.asia/grails-tutorial-for-beginners/
Best of luck and welcome to Grails. I have enjoyed every moment of working with it...

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.

Grails create-app name with dot

It's a little strange question, but why when I'm running next command:
grails create-app project.api
Grails 2.5.0 creates folder project.api with main package project.api, but Grails 3.0.1 creates folder api with package project and ignores provided project full name?
Try it like this:
grails create-app "project.api"
Because the dot has special meaning, used to show package hierarchy(my guess).

Grails run-app 'Application metadata not found'

I downloaded a serverpush example called GrailsChat and trying to run is on grails 2.4.4.
I had some issues with dependencies missing that took me a while to figure out (don't think it's related but just mentioning it).
When I run grails run-app I get:
| Application metadata not found, please run: grails upgrade
When I run grails upgrade I get
| Script 'Upgrade' not found, did you mean:
1) MigrateDocs
2) IntegrateWith
3) SetGrailsVersion
4) InstallDependency
5) DependencyReport
> Please make a selection or enter Q to quit:
I figure the issue is probably to do with the grails version I have being newer than the grails version that the sample app was targetting but I don't want to move back version simply to run an example (I'd rather understand the underlying issue).
Can anyone point me to some documentation that will help me understand what the application metadata is and how to move forward please?
Grails Upgrade command is removed in 2.4. You might have to upgrade the app manually following the guide.
Or you can just run the service wrapper which will download the grails version automatically base on the app.
./grailsw run-app
It seems like you have missed any one of mentioned
Not set grails proper Version
Missing application.properties file (with proper grails version)

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.

Grails equivalents to Rails console Book.all, Book.create, etc

I am relatively new to Grails, and want to learn more about how to create some quick mock data while developing my app.
In Ruby on Rails, i can use the console to create new objects, like so:
Book.create{title: "new book", author_id: 2}
And with Rails i can see all like so:
Book.all
What are the grails equivalents for this? I am using Grails 2.0.0
You can use the Grails shell (as Michael alludes to). For example, here I have a test app with a domain class test.Book. In this example, I first load the Grails interactive mode, run the app, then run the shell and test saving and listing a Book entry:
/home/tim/cmdline $ grails
| Enter a script name to run. Use TAB for completion:
grails> run-app
| Compiling 38 source files
| Server running. Browse to http://localhost:8080/cmdline
| Application loaded in interactive mode. Type 'exit' to shutdown.
| Enter a script name to run. Use TAB for completion:
grails> shell
| Packaging Grails application.....
Groovy Shell (1.8.4, JVM: 1.6.0_29)
Type 'help' or '\h' for help.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
groovy:000> new test.Book( title:'Groovy things' ).save()
===> test.Book : 1
groovy:000> test.Book.list()
===> [test.Book : 1]
groovy:000>
If you install the Grails console plugin, and navigate to /console, you can create objects using
new Book(title: "new book").save()
and get a list of all books using
Book.list()
If you are using an in-memory database during development the easiest way to
add testdata is to add code to Bootstrap.groovy that creates and saves
data.
Another option is to use the Grails Console: http://www.grails.org/Command+Line+Tools

Resources