grails 2.0 - 将WAR部署到远程服务器(Tomcat),而不是连接 [英] grails 2.0 - deploying WAR to remote server (Tomcat), not connecting

查看:95
本文介绍了grails 2.0 - 将WAR部署到远程服务器(Tomcat),而不是连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常从我的IDE运行Grails 2.0,但一直在寻求将应用程序部署到远程虚拟专用服务器(linux),我在那里安装了Tomcat和Mysql。我创建了一个生产WAR文件并将其复制到Tomcat webapps目录中,在那里我可以看到Tomcat重新启动,并且在一些修复之后,我看到应用程序出现了,在MySql数据库中添加了最少的引导入口。 然而,我无法连接到Grails应用程序(远程)。如果我指定www.mydomain.com,我(最终)能够访问主要的Tomcat服务器欢迎页面。如果我在最后添加了/,而不是我的grails应用程序,我也会到达Tomcat。

正因为如此,我试着将它放在完全控制器路径中,在我的开发机器上,然后在远程机器上访问它们(请注意grails.serverURL被配置为 http://www.mydomain。 COM )。做到这一点,我得到

  HTTP状态404  - 请求的资源(/ BareBones / bare / create)不可用。 

这个错误来自于我创建的 BareBones 应用程序, VPS可用内存存在一些问题。无论如何,在我的开发机器上,我可以访问这个BareBones应用程序的URL

  http:// localhost:8080 / BareBones /如预期的那样裸设/创建

。当我部署时,当我执行时,出现相同的HTTP状态404错误(资源不可用):

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

在Config.groovy中,在这个BareBones应用程序中,最小的变化:

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

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




在我的Tomcat server.xml文件中,我从默认的8080 / 8443端口到80/443,但使用任一设置都会导致同样的问题。



我可能错过了一个简单的步骤,只是不知道它是什么。






PS当我部署Tomcat附带的sample.war文件(不是Grails,只是一个hello-world servlet)时,它可以工作。我可以在

  www.mydomain.com/sample 

由于我将sample.war从我的计算机FTP到服务器,它似乎表明我的FTP很好,并且到服务器的路由是正确的,缩小到Grails& Tomcat。

解决方案

正如您所指出的那样,通常在开发模式下,Grails装载 appName ,即 http:// localhost:8080 / BareBones / 在这里。

它在tomcat上挂载的路径不符合Grails本身,它完全依赖于Tomcat配置,主要是WAR文件的名称。



即使您将BareBones作为你的 appName ,然后将它部署为ROOT.war,然后它将挂载根目录/上下文。如果您将其部署为BareBones.war,那么它应该安装与开发模式相同的目录。



因为网站通常被安装为ROOT.war /,我可以推荐设置



grails.app.context =/ Config.groovy 文件中,你可以使用根上下文路径在开发中,即 http:// localhost:8080 /



这使得它更简单,因为dev和production都会现在到处都有相同的相对路径,只有hostname:port会改变。


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.

解决方案

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.

这篇关于grails 2.0 - 将WAR部署到远程服务器(Tomcat),而不是连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆