【发布时间】:2013-03-18 11:18:25
【问题描述】:
注意:这不是交叉发帖,问不同的问题(相关ClassCastError when share objects between webapp)
我有两个 webapps 在同一个 tomcat 实例上的两个不同上下文中运行,当第二个应用程序尝试获取第一个应用程序上下文时,无论我输入的名称是什么,对象都是相同的上下文,这是错误的。
public void contextInitialized(ServletContextEvent sce) {
ServletContext context= sce.getServletContext().getContext("/bling");
ServletContext context2= sce.getServletContext().getContext("/bla");
对象 context 和 context2 都有这个对象 id org.apache.catalina.core.ApplicationContextFacade@4376。
我正在使用tomcat7。有小费吗? tks
更新: 感谢所有好的建议。 如果第二个 webapps(上面的 sn-p 所在的位置)部署在服务器的 ROOT(我的结构中必须,不能更改),就会出现问题。还有什么提示。谢了。
【问题讨论】:
-
@LuiggiMendoza 你可能错了,手册上说:
The given path must be begin with "/", is interpreted relative to the server's document root and is matched against the context roots of other web applications hosted on this container. -
@panky1986 您的链接与问题完全无关。
标签: java tomcat web-applications