1
votes

I generally run Grails 2.0 from my IDE but have been seeking to deploy an app to a remote Virtual Private Server (linux) where I installed Tomcat and Mysql. I create a production WAR file and copy it to the Tomcat webapps dir, where I can see Tomcat restart and after some "fixing" I see the application come up, adding minimal bootstrap entries into the MySql database fine.

However, I cannot connect to the Grails app (remotely). If I specify www.mydomain.com, I am (finally) able to reach the main Tomcat server "welcome page". I also reach Tomcat if I add a "/" at the end, not my grails app.

As such I'm tried putting in full controller paths that I know work on my dev machine, and then accessing them on the remote machine (note grails.serverURL is configured as http://www.mydomain.com). Doing this, I get

 HTTP Status 404 -- The requested resource (/BareBones/bare/create) is not available.

This error is from a BareBones application I created, as I was having some problems with VPS available memory. In any case, on my dev machine I can reach the this BareBones app URL

   http://localhost:8080/BareBones/bare/create

as expected. When I deploy, I get the same HTTP Status 404 error (resource not available) when I do:

   http://www.mydomain.com/bare/create

In Config.groovy, in this BareBones app I've got the minimal change:

  environments {
     development {
        grails.logging.jul.usebridge = true
     }
    production {
       grails.logging.jul.usebridge = false

       grails.serverURL = "http://www.mydomain.com"
    }
 }

In my Tomcat server.xml file I changed over from the default 8080/8443 ports to 80/443, but using either either set results in the same problem.

I'm probably missing an easy step, just don't know what it is.


P.S. When I deploy the sample.war file that comes with Tomcat (isn't Grails, just a hello-world servlet), it works. I'm able to access that at

  www.mydomain.com/sample

Since I FTP'd sample.war from my computer to the server, it would appear to indicate my FTPs are good, and the routing to the server is right, narrowing this down to Grails & Tomcat.

1
I would recommend moving the memory issue to a separate question, since it deserves its own title and answers. - Jan Wikholm

1 Answers

2
votes

Usually in dev mode Grails mounts, as you pointed out, the context of appName, i.e. http://localhost:8080/BareBones/ here.

But the path it mounts on tomcat is not up to Grails itself, it is wholly dependent on the Tomcat configuration and primarily the name of the WAR file.

Even if you have BareBones as your appName and you deploy it as ROOT.war then it will mount the root "/" context. If you deploy it as BareBones.war then it should mount the same dir as in dev mode.

Because sites are usually mounted as ROOT.war "/", I can recommend setting

grails.app.context = "/"

in your Config.groovy file which will make it so that you will use the root context path also in dev, i.e. http://localhost:8080/

This makes it simpler since both dev and production will now have identical relative paths to everywhere and only the hostname:port will change.