There was a problem loading the comments.

User Guide - Groovy and Grails

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

Applicable plans - Standard Plus plans or better (CentOS 5 plans)

User Guide - Groovy and Grails

Overview

Grails is an open source web application framework which leverages the Groovy programming language (which is in turn based on the Java platform). It is intended to be a high-productivity framework by following the "coding by convention" paradigm, providing a stand-alone development environment and hiding much of the configuration detail from the developer - from http://en.wikipedia.org/wiki/Groovy_(programming_language)

Groovy and Grails is for advanced users who are looking for a web application framework for their Java applications. Groovy and Grails assumes that you are already an expert in Java programming, and that you are willing to devote the time and effort it will take to master this new framework.

Groovy and Grails is only available on plans using the CentOS 5 or greater operating system. To see what operating system (OS) you have, click on the Subscriptions icon from the My Account tab of your Control Panel. Then click on the name of the subscription you want to see. The OS for the subscription will be displayed near the top of the page. If you are not on a CentOS 5 plan, but would like information on updating your plan, please contact eApps Technical Support for more information.

Groovy and Grails is not available in the Standard plans due to memory requirements. Groovy and Grails requires Java, and the Standard plan does not have enough memory available to run Java. The Standard Plus plan has just enough memory to run Java, and therefore Groovy and Grails, and serves as our entry level plan for Groovy and Grails users. However, it is important that you select a plan that has enough memory available to build your application.

This User Guide is limited to the installation of Groovy and Grails from the Control Panel on your eApps Hosting service, and is not intended as a Groovy and Grails tutorial. If you need assistance installing Groovy and Grails on your eApps Hosting service, please contact eApps Support.

If you need assistance learning how to use Groovy and Grails, or how to configure your IDE or development environment to use Groovy and Grails, please consult the official documentation or any of the available online resources. See the Links to other information section for examples.

Keep in mind that Groovy and Grails is not a Java application server, but simply a tool to help you build Java applications. The end result of your work in Groovy and Grails should be a WAR file that you will then deploy on Tomcat, JBoss, or Glassfish. For information on how to deploy your application, please see the User Guides for those application servers.

Installing Groovy and Grails

Getting started with the Pet Store sample application


Specifying a different port for an application

Links to other information


Installing Groovy and Grails

Requirements

Groovy and Grails

Groovy and Grails requires that a JVM be installed. Since Groovy and Grails will usually be installed on a VPS this is already running an application server such as Tomcat, JBoss or Glassfish, there should already be a JVM installed.

Java Libraries

If for some reason there is no JVM installed, one can be installed from the Control Panel. Please choose the newest version of the Java Libraries, unless you know your code base needs the older version. Currently, the versions available are Java-SE-5 and Java-SE-6.

If there is no JVM installed, install it first before installing Groovy and Grails.

Subversion

If you want to take advantage of the sample applications from grails.org, you will need to have Subversion installed on your VPS so you can check out the source code. See the Subversion User Guide for more information. Note that the full Subversion configuration is not necessary, all that is needed is the svn command line tools that are installed when Subversion is installed. No other setup needs to be done, unless you also want to use Subversion to manage your source codes.

To install an Application, follow these steps:

Login to your Control Panel, and click on the System Tab. If necessary, click the Select Another System (Subscription) link on the left and choose the correct Virtuozzo container.

Go to Applications, and click on the Add Application link. Select the box next to the Application(s) you want to install, and then scroll down and click the Next button.

This takes you back to the All Applications screen. Wait for five to ten minutes, then click on the Refresh link at the upper right, just under the word Parallels. The application should now show as installed. If it is still in a Scheduled state, wait another five minutes, and click Refresh again. If you see it in Error state, or it still shows as Scheduled, please contact eApps Technical Support.


Getting started with the Pet Store sample application

Because Groovy and Grails is an application development framework, how you use it will vary greatly depending on your specific development environment. However, you can use one of the example applications available from grails.org  to get an idea of how Groovy and Grails works.

If you have questions on how to set up or run any of the sample applications, please refer to the official Grails Documentation or the Grails Community for assistance.

Tech tip All command line examples in this User Guide must be done from the command line of the VPS while logged in via SSH, as the root user. See the SSH User Guide for more information if necessary.


After installation, Groovy and Grails is located in /opt/grails. Using SVN, you can check out the Grails sample application.

Checking out the Pet Store sample application 

To check out the Sample Application, follow these steps

[root@eapps-example ~]# cd /opt/grails
[root@eapps-example grails]# svn checkout http://grails-petstore.googlecode.com/svn/trunk/

Setting up the Pet Store application

This is an example of how to set up the Pet Store application

Note There will be an error when trying to run the application. This is due to the version of Grails that is installed being newer that the version of Grails being expected by the application. The application has to be updated from the command line.You may need to do this every time you run one of the Sample Applications.

The application is downloaded to the trunk/ directory.

[root@eapps-example grails]# cd trunk
[root@eapps-example trunk]# grails run-app
Welcome to Grails 1.2.1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /opt/grails

Base Directory: /opt/grails/trunk
Resolving dependencies...
Dependencies resolved in 2761ms.
Running script /opt/grails/scripts/RunApp.groovy
Environment set to development
Application expects grails version [1.2.0], but GRAILS_HOME is version [1.2.1] - use the correct Grails version or run 'grails upgrade' if this Grails version is newer than the version your application expects.

The application has to be upgraded:

[root@eapps-example trunk]# grails upgrade

Answer  'y' to any question that the upgrade process asks. Once the upgrade is complete, run the grails run-app command again.

[root@eapps-example trunk]# grails run-app

The application will output some status messages, and at the end finish with:

Server running. Browse to http://localhost:8080/grails-petstore

To see the application substitute your domain for localhost

Pet Store

This demonstrates that Groovy and Grails is working.

If you need assistance past this point, please contact the Groovy and Grails community and read the official documentation.



Specifying a different port for an application

If you are currently running Tomcat, JBoss or Glassfish on your VPS, then port 8080 is already in use, and you cannot view your Grails application there. In that case, you can specify a port for testing with Groovy and Grails.

Warning Not all ports are open on your VPS due to our network security policy. The port shown in the example, port 8090, will work. Other ports may not work. For a list of which ports are open, send a request for the port list from the Authorized e-mail address for your Subscription to eApps Support

[root@eapps-example trunk]# grails -Dserver.port=8090 run-app

The application will output some status messages, and you may have to upgrade the application again as in the previous example. When the application has been built, the message will be:

Server running. Browse to http://localhost:8090/grails-petstore

Again, substitute localhost for your actual domain.


Links to other information

Grails main site - http://grails.org/
Grails Community site - http://grails.org/Community
Grails Documentation, with links to a Quick Start and IDE setup - http://grails.org/Documentation

Share via
Did you find this article useful?  

Related Articles


On-Premise Help Desk Software by SupportPal

Categories

© Cloudscale365