Grails app kills itself - grails

I just got a chance to test-drive a VPS for a week, and decided to try Grails on it. The problem is, that it shuts itself down.
Details:
VPS - 512MB Ram, Ubuntu 12.10 x64 (no particular reason for x64)
Oracle Java 7u17
Latest GVM 0.9.5
Grails 2.2.1
What I did was follow along this tutorial http://grails.org/Quick+Start, which is very basic. Everything went smooth until I did grails run-app.
After doing the initialization, it showed running for like 5s, and I could even start loading the page, but it suddenly showed Killed in the terminal. This is what the terminal showed:
root#jp:/var/grails/my-project# grails run-app
| Running Grails application
Killed
There was no input during that time whatsoever. Any ideas on the cause of this problem?

You should only ever run Grails with the run-app command when developing locally. The reason behind this is because run-app starts your Grails app with a lot of dynamic behavior that is great for rapid development, but horrible performance-wise for running on an actual server.
Refer to Grails' User Guide on how best to deploy your application:
http://grails.org/doc/latest/guide/gettingStarted.html#deployingAnApplication
As the docs above state, the correct way to run your Grails app is to embed it in a servlet container. Tomcat is a good place to start since Grails uses that by default when running locally. You may also need to play around with the VM flags of your servlet container, depending on your environment (again, the docs give a few suggestions here).

You can redirect output of your command if it get's killed immediately on your terminal.
grails run-app > output.txt
Then open output.txt and from there you can dissect the problem.
For my case, i got an incorrect JAVA_HOME directory.
Hope it helps.

Related

Vagrant box for Groovy and Grails Development

I want to use Vagrant to ensure a consistent development environment for my Groovy and Grails projects. Is there are standard base Vagrant box? Ie that comes with Java, GVM, Groovy and Grails pre-installed?
I’ve taken a look and can find two but I had some issues with both:
http://borzacchiello.it/set-up-a-vagrant-machine-for-grails-development/
“An error occurred while downloading the remote file. The error message, if any, is reproduced below. Please fix this error and try again. Couldn't open vag2demo/vagrant-grails/base”
https://github.com/osoco/testbox
Here localhost:8888 went to a tomcat that should have Jenkins running, instead it was a base tomcat installation.
Does anyone know of any other sources for a Groovy and Grails Vagrant box?
I ran into similar problems recently and created my own Vagrant box for Grails development.
https://github.com/janmey/grails-vagrant
It's based on Java7 and the latest Groovy and Grails versions are installed using gvm. It's still work-in-progress, but you should be able to get started with it pretty quickly. The inital "vagrant up" will take a while, but the "Hello World" app should work then.

Lifecycle exception in tomcat

I'm getting org.apache.catalina.LifecycleException when running shopizer project in eclipse. Shopizer use struts2. Also I'm using tomcat7 to run it. The bad thing is some times it comes and sometimes it don't. When It comes restarting the server is not helping and I have to restart the whole system to get things working again.
open task manager.
kill the process 'javaw.exe'
then restart the server after cleaning tomcat directory and project
it should work..

Bizarre results when launching war in EC2 using elasticsearch 0.19.8

I'm using Grails 2.0.4 and elasticsearch 0.19.8, with a homegrown build of the elasticsearch-grails plugin to use 0.19.8, running on a micro Ubuntu instance of EC2.
I'm building my grails project locally as a war. When I drop this was in a jetty container locally (on my laptop), jetty starts and I'm able to navigate to the root context (as expected) and get my site.
However, when I take the same war (confirmed via md5sum) in the same version of jetty (confirmed via md5sum) on a micro EC2 instance, I get strange results.
Occasionally, jetty starts and my application is available...all is well. But then other times, jetty won't start...and the logs are complaining about elasticsearch.
Now, I'm the first to admit that running both elasticsearch and jetty (with a grails war) on the same node is, well, not the greatest idea...but, this is a test environment, and I'm okay with swapping to disk (not a perf testing lab).
But, what's driving me batty is the inconsistency in running my application. Currently, I cannot get it to start (which, I suppose, counters my "inconsistency" argument). But even taking a "starting" war, with MINIMAL changes in the war (no domain object changes, just changes in controller and/or view), my app won't start - complaining about elasticsearch.
Here's the gist
In the past, I've solved this by stopping elasticsearch, and blowing away /var/lib/elasticsearch/elasticsearch (which is basically, as I understand it, a crude way of blowing away the elasticsearch index).
But now, this doesn't appear to be working. Neither does uninstall/reinstall elasticsearch.
Can anybody offer any advice on what to look for and/or where to look?
Ok, this is driving my crazy, but I found an answer.
/data contains an elasticsearch directory which, apparently, had bad data...I deleted this directory and restarted jetty and...
Viola!
I have NO idea how it got into this state, nor the actual ramifications of deleting the directory (I think elasticsearch data is persisted in the elasticsearch node...)
I suspect an incomplete shutdown of my app...
Thanks for everybody's input.

aws memory high usage

Recently I configured my instance into a micro environment in EC2 with glassfish and mysql in windows..
I deployed my war and i was able to access my site through http.
I changed my application and redeployed the war and it also worked.
When I was about to redeploy the war for 4th or 5th time, the application got deployed, I saw the message in the log file. But I was unable to access the site through http.
Then I tried the command "asadmin list-applications" and I got the following message.
Error occurred during initialization of VM
Could not reserve enough space for object heap
After that I was not able to connect to my instance through RDP and I had to reboot, I was able to access it again after that. I started the servers again (glassfish mysql), but no luck.
I noticed that the memory usage is around 90% or more. CPU isage is low.
now I can not access my site through http. what shall i do ?
Thanks in advance !
Honestly, there are a couple issues working against you here:
1) Windows requires FAR more RAM than Ubuntu to run at a minimum decent level.
2) GlassFish has a much larger footprint than Tomcat or Jetty.
Is there any particular reason you need Windows? Like is there a specific need that your server run some executables for file processing or something like that outside the JVM? Most would agree that Linux (Ubuntu or other) will give you much better results in performance and stability to run an App Server like GlassFish in any environment.

How to start a grails webtest without starting the grails application?

I am working with the webtest plugin as functional test component for grails.
It works fine, but is very slow - the whole application has poor response times (>1min per page) when under test. My feeling is that this is because the app, canoo webtest and the IDE (netbeans) are running in one JVM when I start my test through the IDE (test-app functional:)
So my goal is now to deploy the app to a stand-alone tomcat and run my tests against this tomcat instance.
I googled and found an old option -nostart for webtest which seem to be outdated.
So I googled some more and found the -baseUrl=http://... option in the current documentation. The docs say that with this option, the app will not be started and all tests will run against this baseUrl. But when I give it a try, grails still tries to start up jetty (at least, I get an error message saying that the port 8080 is already in use).
Any ideas? I am already thinking about using webtest stand-alone, but I like the groovy syntax of the plugin...
I'm using grails 1.3.4
You could try interactive mode as mentioned here: Can I run grails integration & functional tests against a running server?
If the -baseUrl option isn't working then I'd raise a JIRA issue.
cheers
Lee

Resources