Sharing open source containers (Spring / Spring Security / Hibernate / etc) in web applications

We have a bunch of open source Java EE applications, like the ones mentioned above. WEB-INF / lib for each application has the following common banks:

antlr-2.7.6.jar* aopalliance-1.0.jar* asm-3.3.1.jar* aspectjrt-1.6.8.jar* aspectjweaver-1.6.8.jar* cglib-2.2.jar* commons-beanutils-1.8.3.jar* commons-collections-3.1.jar* commons-dbcp-1.4.jar* commons-digester-2.1.jar* commons-fileupload-1.1.1.jar* commons-io-2.0.1.jar* commons-logging-1.1.1.jar* commons-pool-1.5.6.jar* dom4j-1.6.1.jar* hibernate-jpa-2.0-api-1.0.0.Final.jar* hibernate-tools.jar* hibernate-validator-4.1.0.Final.jar* hibernate3.jar* jackson-all-1.7.5.jar* javassist-3.12.0.GA.jar* javax.inject.jar* log4j-1.2.16.jar* org.springframework.aop-3.0.5.RELEASE.jar* org.springframework.asm-3.0.5.RELEASE.jar* org.springframework.beans-3.0.5.RELEASE.jar* org.springframework.context-3.0.5.RELEASE.jar* org.springframework.context.support-3.0.5.RELEASE.jar* org.springframework.core-3.0.5.RELEASE.jar* org.springframework.expression-3.0.5.RELEASE.jar* org.springframework.jdbc-3.0.5.RELEASE.jar* org.springframework.orm-3.0.5.RELEASE.jar* org.springframework.transaction-3.0.5.RELEASE.jar* org.springframework.web-3.0.5.RELEASE.jar* org.springframework.web.servlet-3.0.5.RELEASE.jar* poi-3.7-20101029.jar* slf4j-api-1.6.1.jar* slf4j-ext-1.6.1.jar* slf4j-log4j12-1.6.1.jar* spring-security-acl-3.0.5.RELEASE.jar* spring-security-aspects-3.0.5.RELEASE.jar* spring-security-config-3.0.5.RELEASE.jar* spring-security-core-3.0.5.RELEASE.jar* spring-security-taglibs-3.0.5.RELEASE.jar* spring-security-web-3.0.5.RELEASE.jar* testng-6.0.1.jar* tiles-api-2.2.2.jar* tiles-core-2.2.2.jar* tiles-jsp-2.2.2.jar* tiles-servlet-2.2.2.jar* tiles-template-2.2.2.jar* validation-api-1.0.0.GA.jar* 

We are faced with errors of deployment pergents, each war is a little 20 MB, and third-party banks are the main one.

Since all applications are in the same version for all open source projects, I wonder if this will be normal if I switch to Spring, Spring Security, Spring Tiles, Hibernate, Hibernate, third-party jars (cglib, antlr, etc. .d.), logging and apache-commons. * to the TOMCAT / lib folder.

I remember, starting with the Struts days (2003 or 2004), each web application had to have its own copy of struts bars, and the separation at the application server level was discouraged. Does this frustration apply (other than version)?

As an auxiliary question: is there a general rule according to which third-party banks may or may not be divided (if it is not clearly indicated in the documents?

I would appreciate any help. Thanks.

+4
source share
1 answer

Depending on how you download the application, you can probably transfer most (or all) of these cans (test it and find out). What you need to be careful are frameworks that rely on loading from static initializers. If I remember correctly, Struts configured itself from a static initializer that read the struts-config file. Since the static initializer starts only when the class is first loaded, it will not work in the common class loaders.

Moreover, your problem may not end simply by moving banners to a common bootloader. Spring and Hibernate will create many dynamic classes at runtime for AOP entities and proxies (to support transactions, etc.) that will be in the constant generation. Typically, for applications that are heavy on Spring and Hibernate, you will have to increase the permento space (for example, using the -XX:MaxPermSize in Oracle HotSpot VM).

+3
source

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


All Articles