Note: this is not cross-posting, asking different questions (related ClassCastError when share objects between webapp)
I have two webapps running at two different contexts on the same tomcat instance, when the 2nd apps tried to get the first app context, regardless the name I input, the object is the same context, which is wrong.
public void contextInitialized(ServletContextEvent sce) {
ServletContext context= sce.getServletContext().getContext("/bling");
ServletContext context2= sce.getServletContext().getContext("/bla");
Both objects context and context2 have this object id org.apache.catalina.core.ApplicationContextFacade@4376.
I'm using tomcat7. Any tips? tks
Update: Tks for all good suggestions. The problem just happens if the 2nd webapps (where the above snippet is) is deployed at ROOT of the server (a must in my structure, cannot change). Any more hints. Tks.
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.