tomcatgrailsgroovycompilationgsp

How to compile grails program after configuring a gsp webpage?


I have a question regarding adding texts or content of a webpage configured through Grails Groovy programming. Sometime ago, our group had created a web resource for mining expression data and software development of the same was left dormant. This resource was built using various software programs (Apache Tomcat 6.0.24, Java 1.7.0_03, Apache http server 2.2, R 2.15.1, Mysql 5.1.41, Mongo 2.02, Grails 2.1.0).

Since few weeks we got innovative ideas to actively develop this web resource and enhance it by adding interesting content to the webpage. Now, I am working on this and and would like to add brief texts and useful content to the webpage (landing.gsp file- see below directory path). However, the added texts does not get reflected on the webpage even after restarting tomcat server.

I have limited knowledge about the software development aspect and researched a bit and tried two suggested methods, however, unsuccessful in both of them.

Method 1:

It seems like after adding the texts to landing.gsp file in the views directory, or in order to make any changes to a deployed application on Grails, I had to configure Config.groovy file by adding the required details: Make any changes to a deployed application on Grails. I configured as suggested, however, no success.

1. Edited the landing.gsp file:

Sudo vi /home/ubuntu/gxb/gxbrowser/grails-app/views/landing.gsp
Sudo vi /var/lib/tomcat6/webapps/dm3/WEB-INF/grails-app/views/landing.gsp

2. Edited and added to the Config.groovy file:

Sudo vi /home/ubuntu/gxb/gxbrowser/grails-app/conf/Config.groovy

Added the below:
grails.gsp.enable.reload = true
grails.gsp.view.dir = "/var/www/grails/my-app/"

3. Also, with these settings in place, I copied the views directory from web application to the external directory. To retain the view directory structure, including the grails-app/views bit.

mkdir -p /var/www/grails/my-app/grails-app/views
cp -R grails-app/views/* /var/www/grails/my-app/grails-app/views

Method 2:

It seems another suggestion was to add the texts to landing.gsp file and compile, and then place the binary in the tomcat folder. I tried running Grails to compile or even generate war file, this shows an error message (see below):

ubuntu@ip-172-31-14-90:~/gxb/gxbrowser/grails-app/views$ grails compile
| Configuring classpath
| Error /home/ubuntu/gxb/gxbrowser/grails-app/views does not appear to be part of a Grails application.
| Error The following commands are supported outside of a project:
        add-proxy
        clear-proxy
        create-app
        create-multi-project-build
        create-plugin
        help
        list-plugins
        package-plugin
        plugin-info
        remove-proxy
        set-proxy
| Run 'grails help' for a complete list of available scripts.


ubuntu@ip-172-31-14-90:~/gxb/gxbrowser/grails-app/views$ grails war
| Configuring classpath
| Error /home/ubuntu/gxb/gxbrowser/grails-app/views does not appear to be part of a Grails application.
| Error The following commands are supported outside of a project:

Please assist me with this.

Thank you,

Toufiq


Solution

  • This issue is now resolved by Method 2.

    1. Made changes to the required *.gsp files (~/gxb/gxbrowser/grails-app/views/)
    2. Navigated to the ~/gxb/gxbrowser
    3. Ran grails war command
    4. Navigated to the ~/gxb/gxbrowser$ cd target/
    5. Then, copied to webapps folder: sudo cp dm3-1.70.war /var/lib/tomcat6/webapps/dm3.war
    6. Restarted tomcat server