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

We developed the JEE5 web application (WAR) and launched it in production in accordance with WebLogic 11g (10.3.5).

Now the same application should be deployed as separate applications for different clients (different URLs, different data) in the same WebLogic.

I managed to complete the first part by setting the various context roots after deployment for each of them.

But I have yet to use different data sources. And since I want to avoid client-specific builds, persistence.xml is the same for all applications, as well as the name of the save unit.

What is the best setting for this scenario? Can I make separate assemblies and other WARs, or do I need to separate managed servers or domains from the server, or is there a better way to solve it?

+4
source share
3 answers

It seems to me that I saw in the Oracle documentation that having multiple domains is the only way to separate data sources with the same storage unit name, which is bad, because it basically means using two WLSs at the same time.

For this reason, I decided to go about creating separate WAR files (which I tried to avoid initially) in order to include client-specific persistence.xml files and specify client-specific data sources in WLS.

0
source

ServletContextListener.contextInitialized can look at ServletContext and find out which deployment it is

in web.xml, define the servlet context listener:

 <listener> <listener-class>com.path.YourServletContextListener</listener-class> </listener> 

and then in YourServletContextListener.java add the contextInitialized method, for example:

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

I believe that you can use this name to select from several data sources that you have configured. depending on how you were deployed, you will create another database connection and get the correct application data.

0
source

I know that this branch is very old, but answering so that it helps someone with the same question stumble over this thread.

The latest version of weblogic 12.2.1 has a multi-user version (presumably an add-on) that allows you to run the same applications in the same domain.

Edit: Weblogic 12.2.1 introduces a concept called "Sections". Partitions are both a configuration and a temporary subdivision of a weblog domain. In one weblogic domain, you can create multiple partitions. Each section will have one or more resource groups. Resource groups are a logical grouping of weblogic repositories such as data sources, jms, Java EE applications, etc. For example, to achieve what the original messages set, we create a resource group template with a web application and a data source as resources. In the data source configuration, we can provide the place owner variable instead of the actual URL as the database URL. Then we can create two sections that reference this resource group template (each section will now have a separate web application and data source). Each section will override the database URL property there, creating two data sources with the same JNDI name. In each section, we create a virtual host / port so that the client can use it to access the application running in the corresponding sections.

More detailed and detailed information about this can be found at https://blogs.oracle.com/WebLogicServer/entry/domain_partitions_for_multi_tenancy

0
source

Source: https://habr.com/ru/post/1402834/


All Articles