简体   繁体   English

更改Tomcat 8上已停止的应用程序的上下文路径

[英]Change of context path of stopped applications on Tomcat 8

Im working on a Tomcat application. 我正在处理Tomcat应用程序。 I just updated from Tomcat 7 to Tomcat 8 using the migration guide. 我刚刚使用迁移指南从Tomcat 7更新到了Tomcat 8。 After I did this, I recognized that the context path of the applications deployed on the server behaves different now. 完成此操作后,我认识到服务器上部署的应用程序的上下文路径现在的行为有所不同。

I am requesting the context path in a jsp. 我在jsp中请求上下文路径。 deployed in the ROOT directory using: 使用以下命令部署在ROOT目录中:

application.getContext("app").getContextPath()

The result is the context path of the application: /app 结果是应用程序的上下文路径: / app

The context path is always the same, if the application is running or stopped. 如果应用程序正在运行或停止,则上下文路径始终相同。

After upgrading to Tomcat 8.0.33 the behavior is different. 升级到Tomcat 8.0.33后,行为有所不同。 When the application is stopped, the context path that I get is an empty path (which results in pointing to ROOT). 当应用程序停止时,我得到的上下文路径为空路径(这导致指向ROOT)。 The context path of the runnnig application is still the same: /app runnnig应用程序的上下文路径仍然相同: / app

I studied the migration guide and change log but I did not find any change which explains the different behavior. 我研究了迁移指南和更改日志,但是没有找到任何解释不同行为的更改。 I also googles a lot and have no clue what explains this behavior. 我也用谷歌搜索很多,不知道是什么原因解释了这种行为。

Can anybody help me finding out what the problem is? 有人可以帮我找出问题所在吗?

I think I did not clear enough explain what I am doing. 我想我没有足够清楚地解释我在做什么。 I do not want the current context path of the application. 我不需要应用程序的当前上下文路径。

On the Tomcat are various numbers of applications deployed (let the names be /app1, /app2, ..., /app10). 在Tomcat上部署了各种应用程序(名称分别为/app1、/app2、...、/app10)。 Inside the jsp, deployed in ROOT, I want the to find out which applications are actually deployed on the server. 在部署在ROOT中的jsp内,我希望找出服务器上实际部署了哪些应用程序。 I am doing this by asking for the ServletContext of the other applications: 我通过询问其他应用程序的ServletContext来做到这一点:

application.getContext( "/app1);
application.getContext( "/app2);
...

When I then asking for the context path of the application it is either empty (application is not deployed) or I get the actual path (eg /app1) for a deployed application (started or stopped): 然后,当我询问应用程序的上下文路径时,它为空(未部署应用程序)或获取已部署的应用程序(启动或停止)的实际路径(例如/ app1):

application.getContext("/appX").getContextPath()

Thats how I create a list of deployed applications. 那就是我如何创建已部署应用程序的列表。 But now on Tomcat 8 I get an empty context path not only for applications which are not deployed, but also for applications which are deployed but stopped. 但是现在在Tomcat 8上,不仅对于未部署的应用程序,而且对于已部署但已停止的应用程序,我都获得一个空的上下文路径。 This is a different behavior as it was on Tomcat 7. 这是与Tomcat 7不同的行为。

I hope I could make clearer now what´s my problem. 我希望我现在可以弄清楚我的问题是什么。

Unfortunately I could not find out what´s the issue. 不幸的是,我找不到问题所在。 Instead I rewrote my code to use the tomcat manager endpoints. 相反,我重写了代码以使用tomcat管理器端点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM