How to deploy the same web application twice on WebLogic 11g?

后端 未结 3 1391
生来不讨喜
生来不讨喜 2020-12-11 19:06

We have developed a JEE5 web application (WAR) and running it in production under WebLogic 11g (10.3.5).

Now the same application should be deployed as separate appl

3条回答
  •  一生所求
    2020-12-11 19:23

    ServletContextListener.contextInitialized can look at the ServletContext and figure out which deployment is which

    in web.xml, define a servlet context listener:

    
      com.path.YourServletContextListener
    
    

    and then in YourServletContextListener.java, add a contextInitialized method like this:

    public void contextInitialized(ServletContextEvent sce)
    {
      ServletContext sc = sce.getServletContext();
      String name = sc.getContextPath();
      ...
    }
    

    my thought is that you can use that name to select from multiple data sources that you have configured. depending on how you've been deployed, you'll make a different database connection and have the correct application's data.

提交回复
热议问题