Grails War and deploy - grails

I am using grails 1.3.4 on windows xp and centos. Tomcat 5 on centos.
I do a 'grails dev war' and 'grails prod war' on an app (as well as a test app I've put together). I take the war file on xp and expand it in another dir. On the centos I can put the war file in tomcat and also in it's own dir. But when I go to run-war or run-app the unpacked war files, I am told my app is pre-0.5 grails. I do a grails upgrade. But then when I go to run-app or run-war again I get 0 domains 0 controllers and nothing is available.
My app before I war the files is 1.3.4 and it's runs, passes tests and full functions, but not once I war it. Any ideas?

You can't use run-app or run-war on unpacked war files. Both are meant to be used from the source project itself. run-app runs directly with an embedded Tomcat (or Jetty if you switch to that plugin) and run-war builds a war and deploys it into an embedded Tomcat.
When you build a war (whether you unpack it or not) it's to be used by Tomcat or another servlet container directly, not as a 'Grails war' but as a war like any other.
Basically your options are:
'grails run-app' from the project root to test in dev mode
'grails prod run-war' from the project root to test a war in prod mode
'grails war' to deploy to a standalone container and run as a deployed application

If you are using datasource check that your username and password are correct for database connections

Related

Grails "war" command, how to set system property

I'm running grails prod war to create my app's .war file. The problem is, I need to somehow set a system property that can be accessed in grails-app/conf/Config.groovy when that .war is being built.
How can I do this? Grails version 2.1.0
You need to set this property when the war is being launched, not when it's being built. If the app is being hosted by Tomcat (or similar) you would typically adds this as a parameter to the java command that launches Tomcat.
grails -Dproperty=value prod war

How do I know what webserver gradle / grails is using?

This thread: Gradle / Grails application describes how to set up the grails plugin for gradle.
The command gradle grails-run-app tries to start the grails application on port 8080. What webserver is gradle using here?
Does it have an embedded one? If so how can I access / configure it?
It just shelling out to the same thing that Grails would have done without Gradle, as if you had run grails run-app. That depends on which server plugin you have installed. By default it's http://grails.org/plugin/tomcat, but you can switch to http://grails.org/plugin/jetty by changing the values in grails-app/conf/BuildConfig.groovy
Gradle is nothing but a build and config tool like maven. When you use it with Grails app the dependencies are managed by it as it happens when maven is used.
When you use gradle grails-run-app it does nothing more other than running grails run-app from its own context. The same embedded Tomcat server is used by default.

Grails 2 app deployed twice on tomcat7

I'm having trouble with my grails app. For some reason when I deploy it on a standalone tomcat7 instance it seems to deploy the app twice. e.g. when I run a quartz job, it calls the job twice, when I run a controller method, it's run twice.
This happens in the following cases:
1. adding the war into the webapps folder
2. manually unpacking the war into the webapps folder
3. adding a context line such as <Context path="/process" docBase="C:\apache-tomcat-7.0.27-windows-x64\apache-tomcat-7.0.27\process.war" reloadable="true" /> into the server.xml file and have the actual war file outside of the webapps folder. I've also set unpackWARs="false" autoDeploy="false" for the HOST parameter where the context parameter is added to.
I'm running out of ideas on what else to test.
This bug/feature does not occur when launching the app with the run-app command line and using the tomcat plugin.
Any ideas anyone?

Doesn't grails run-app create a war?

Doesn't a grails run-app create a WAR file(exploded) in the embedded Tomcat Container? If so what is the difference between grails run-app and grails run-war command?
Is it possible to view the web app directory under the embedded Tomcat Directory after the execution of grails run-app command?
The grails-app command starts an embedded Tomcat server and configures its context paths so that it can look up everything it needs from their original filesystem paths. Therefore there is no single place where everything would be gathered as would be when running an exploded web application archive.
No, run-app doesn't create a war. It starts the Tomcat server and configures it programmatically as an exploded war.

Grails war command defaults to development environment under netbeans

When I generate the war in my grails app via right-click / run grails / command / war, it shows "Environment set to development", having it run without parameters. Why is this happening when according to the docs it should default to production (which is what I need)?
BTW, is there a way having built the whole grails application with NetBeans to use the command line to generate the wars ?
Versions: NetBeans 6.7.1, Grails 1.2
OS: Ubuntu 9.1
Thanks
The netbeans plugin is probably running the command "grails dev war" which creates a war file based on the development settings. The normal "grails war" command uses production settings.
You should just be able to change to the directory containing your grails-app and src folders and run the command
grails war
This assumes that you have grails installed and on your path.
No, only that grails war may assume it to be a development. I suggest you specifically type as follow:
grails prod war
you can modify the proyect file gradle.properties and add
org.gradle.jvmargs=-Dgrails.env=dev //for development
org.gradle.jvmargs=-Dgrails.env=prod //for production enviroment
Check https://docs.grails.org/latest/guide/gettingStarted.html

Resources