Grails2.5.1应用程序偶尔会丢失上下文根

Grails2.5.1应用程序偶尔会丢失上下文根,grails,grails3,grails-2.5,Grails,Grails3,Grails 2.5,我们有几个应用程序部署到同一个tomcat服务器上(目前正在升级到grails 3,因此这可能是未来几个月的OBE,但它已经困扰了我们很长一段时间),其中两个应用程序偶尔会丢失其相对上下文根路径 假设我们有“app1”和“app2”,它们部署到server:port/app1和server:port/app2 app1工作正常,但app2有时(可能有20%的时间)会部署,并且所有链接(或任何其他生成的链接,如资产位置)都会相对于服务器根目录生成。。。应用程序在/app2下正确部署,因此链接指向错

我们有几个应用程序部署到同一个tomcat服务器上(目前正在升级到grails 3,因此这可能是未来几个月的OBE,但它已经困扰了我们很长一段时间),其中两个应用程序偶尔会丢失其相对上下文根路径

假设我们有“app1”和“app2”,它们部署到
server:port/app1
server:port/app2

app1工作正常,但app2有时(可能有20%的时间)会部署,并且所有
链接(或任何其他生成的链接,如资产位置)都会相对于服务器根目录生成。。。应用程序在
/app2
下正确部署,因此链接指向错误位置

例如,
将以
/hello/index
而不是
/app2/hello/index
的形式生成链接

我不知道要发布的相关代码是什么,我们已经将其与其他应用程序进行了比较,并发现这两个表现出这种行为的应用程序没有明显的不同。但只有这两个(十几个)应用程序曾经以这种方式中断

如果您有任何想法,知道是什么原因导致了这一情况,或者知道应该在哪里查找,我们将不胜感激。

编辑:正在使用的插件:

compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
provided "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile 'org.grails.plugins:cache:4.0.0.M2'
compile 'org.grails.plugins:cache-ehcache:3.0.0.M1'
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-core:4.3.10.Final"
compile "org.hibernate:hibernate-ehcache:4.3.10.Final"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.14.1"
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
已解决('ish)

我们终于找到了原因
grailsLinkGenerator
DefaultLinkGenerator
class)正在丢失
contextPath
,或者在启动时未正确设置。这会导致使用链接生成器单例生成的所有链接(这是大多数,但显然不是全部)在服务器根上生成

我们仍在计时,以确定这是否可以在
引导中运行,并推迟到服务器启动完成,但现在,作为一种解决方法,我们添加了一个不受保护的控制器操作来重置此操作,这似乎解决了问题(直到服务器下次重新启动)


仍然不知道为什么它只发生在某些服务器上的某些应用程序上(可能是应用程序启动的时间),但这至少可以让我们在不需要重新启动的情况下解决问题。

您要部署到哪个服务器/容器?还有,你在使用什么插件?你能用一个全新的应用程序重新创建这个问题吗?我们正在部署到tomcat,用build.gradle中的插件更新了这个问题。。。还有一些额外的内部插件,但这些是主要的第三方插件。除了两个(共13个)出现此问题的应用程序外,我们无法复制任何其他应用程序。大多数应用程序使用同一组第三方插件(或非常类似)
def resetContextPath() {
  grailsLinkGenerator.contextPath = grailsApplication.config.getProperty("server.contextPath")

  if (grailsLinkGenerator instanceof CachingLinkGenerator) {
    grailsLinkGenerator.clearCache()
  }
}