Introducing New Dependency Problem into maven Project

Posted by scotchegg78 on Mon, 01 Jul 2019 21:19:52 +0200

The previous article described the problem of release s without definite version numbers.

Describe recent problems in the system.

One day this email suddenly appeared in the development environment.

Normal as follows

It's particularly strange why the theme has disappeared and the content seems to be scrambled.

With shallow mail knowledge, guess it was sent as an attachment.

First, check that the configuration for sending mail has not changed. Secondly, we found that the pom file has changed, presumably this is where the problem arises.

Small partners introduce new components such as

<dependency>
    <groupId>org.apache.axis2</groupId>
    <artifactId>axis2-adb</artifactId>
    <version>1.4</version>
</dependency>

Is there any doubt that the maven arbitration led to a change in one of the jar versions previously relied on?

So the dependencies will be generated twice

New dependencies

activation-1.1.jar                              commons-pool2-2.4.2.jar                 jboss-logging-3.2.1.Final.jar  shiro-core-1.3.0.jar
annogen-0.1.0.jar                               core-3.2.1.jar                          jedis-2.7.3.jar                shiro-ehcache-1.3.0.jar
annotations-2.0.1.jar                           countUp.js-1.7.0.jar                    jgroups-3.6.6.Final.jar        shiro-quartz-1.3.0.jar
ant-1.7.0.jar                                   data-biz-model-1.0.23.jar               jline-0.9.94.jar               shiro-redis-2.4.2.1-RELEASE.jar
ant-launcher-1.7.0.jar                          data-biz-rmi-1.0.23.jar                 joda-time-2.9.3.jar            shiro-spring-1.3.0.jar
aopalliance-1.0.jar                             data-biz-vo-1.0.23.jar                  jpinyin-1.1.8.jar              shiro-web-1.3.0.jar
aspectjweaver-1.8.9.jar                         data-utility-1.0.23.jar                 jquery-raty-2.5.2.jar          slf4j-api-1.7.25.jar
axiom-api-1.2.7.jar                             dom4j-1.6.1.jar                         json-20090211.jar              spring-aop-3.2.8.RELEASE.jar
axiom-dom-1.2.7.jar                             dozer-5.2.0.jar                         json-lib-2.2.2-jdk15.jar       spring-beans-3.2.8.RELEASE.jar
axiom-impl-1.2.7.jar                            dubbo-2.5.3.jar                         jsp-api-2.2.jar                spring-context-3.2.8.RELEASE.jar
axis2-adb-1.4.jar                               ECharts-2.2.0.2.jar                     jstl-1.2.jar                   spring-context-support-3.2.8.RELEASE.jar
axis2-kernel-1.4.jar                            ehcache-2.10.1.jar                      kryo-shaded-3.0.0.jar          spring-core-3.2.8.RELEASE.jar
backport-util-concurrent-3.1.jar                ehcache-core-2.5.3.jar                  log4j-over-slf4j-1.7.7.jar     spring-data-redis-1.6.2.RELEASE.jar
bcprov-jdk15-1.45.jar                           ezmorph-1.0.4.jar                       logback-access-1.1.7.jar       spring-expression-3.2.8.RELEASE.jar
biz-mapper-1.0-SNAPSHOT.jar                     fastjson-1.2.24.jar                     logback-classic-1.1.7.jar      spring-jdbc-3.2.8.RELEASE.jar
biz-model-1.0-SNAPSHOT.jar                      fst-2.42.jar                            logback-core-1.1.7.jar         spring-security-core-4.2.1.RELEASE.jar
biz-rmi-1.0-SNAPSHOT.jar                        geronimo-activation_1.1_spec-1.0.1.jar  logback-ext-spring-0.1.4.jar   spring-tx-3.2.8.RELEASE.jar
biz-rmi-impl-1.0-SNAPSHOT.jar                   geronimo-javamail_1.4_spec-1.2.jar      mail-1.4.4.jar                 spring-web-3.2.8.RELEASE.jar
biz-schedule-1.0-SNAPSHOT.jar                   geronimo-jms_1.1_spec-1.1.jar           minlog-1.3.0.jar               spring-webmvc-3.2.8.RELEASE.jar
biz-service-1.0-SNAPSHOT.jar                    geronimo-stax-api_1.0_spec-1.0.1.jar    mybatis-3.3.0.jar              stax-api-1.0.1.jar
biz-service-impl-1.0-SNAPSHOT.jar               guava-18.0.jar                          mybatis-spring-1.2.3.jar       utility-1.0-SNAPSHOT.jar
biz-vo-1.0-SNAPSHOT.jar                         hibernate-validator-5.2.4.Final.jar     neethi-2.0.4.jar               validation-api-1.1.0.Final.jar
carzoneAgent-1.0.2.jar                          httpclient-4.4.jar                      netty-3.2.5.Final.jar          woden-api-1.0M8.jar
carzone-erp-api-supplychain-1.0.10-RELEASE.jar  httpcore-4.4.jar                        netty-3.7.0.Final.jar          woden-impl-dom-1.0M8.jar
carzone-erp-core-1.0.10-RELEASE.jar             httpcore-nio-4.0-beta1.jar              objenesis-2.1.jar              wsdl4j-1.6.2.jar
carzone-platform-exception-1.1.RELEASE.jar      j2cache-core-1.4.0.jar                  ognl-3.0.11.jar                wstx-asl-3.2.4.jar
carzone-platform-validate-2.1.RELEASE.jar       j2cache-shiro-1.0.2.jar                 okhttp-3.2.0.jar               xalan-2.7.0.jar
Chart.js-2.1.3.jar                              j2cache-spring-1.0.1.jar                okio-1.6.0.jar                 xercesImpl-2.8.1.jar
classmate-1.1.0.jar                             jackson-annotations-2.6.1.jar           optimist-1.2.0.jar             xml-apis-1.3.04.jar
commons-beanutils-1.8.3.jar                     jackson-core-2.6.1.jar                  pinyin4j-2.5.0.jar             xmlbeans-2.6.0.jar
commons-codec-1.9.jar                           jackson-core-asl-1.9.2.jar              poi-3.12.jar                   xmlParserAPIs-2.6.0.jar
commons-collections-3.2.1.jar                   jackson-databind-2.6.1.jar              poi-ooxml-3.12.jar             XmlSchema-1.4.2.jar
commons-fileupload-1.2.1.jar                    jackson-mapper-asl-1.9.2.jar            poi-ooxml-schemas-3.12.jar     zkclient-0.1.jar
commons-httpclient-3.1.jar                      java-sdk-3.13.jar                       quartz-1.6.1.jar               zookeeper-3.4.6.jar
commons-io-2.4.jar                              javassist-3.11.0.GA.jar                 quartz-all-1.6.1.jar
commons-lang-2.6.jar                            javassist-3.19.0-GA.jar                 rapid-core-4.0.jar
commons-logging-1.1.1.jar                       jaxen-1.1.1.jar                         reflections-0.9.10.jar

Old dependence

activation-1.1.jar                             countUp.js-1.7.0.jar                 jgroups-3.6.6.Final.jar       quartz-1.6.1.jar
annotations-2.0.1.jar                          data-biz-model-1.0.23.jar            jline-0.9.94.jar              quartz-all-1.6.1.jar
aopalliance-1.0.jar                            data-biz-rmi-1.0.23.jar              joda-time-2.9.3.jar           rapid-core-4.0.jar
aspectjweaver-1.8.9.jar                        data-biz-vo-1.0.23.jar               jpinyin-1.1.8.jar             reflections-0.9.10.jar
bcprov-jdk15-1.45.jar                          data-utility-1.0.23.jar              jquery-raty-2.5.2.jar         shiro-core-1.3.0.jar
biz-mapper-1.0-SNAPSHOT.jar                    dozer-5.2.0.jar                      json-20090211.jar             shiro-ehcache-1.3.0.jar
biz-model-1.0-SNAPSHOT.jar                     dubbo-2.5.3.jar                      json-lib-2.2.2-jdk15.jar      shiro-quartz-1.3.0.jar
biz-rmi-1.0-SNAPSHOT.jar                       ECharts-2.2.0.2.jar                  jsp-api-2.2.jar               shiro-redis-2.4.2.1-RELEASE.jar
biz-rmi-impl-1.0-SNAPSHOT.jar                  ehcache-2.10.1.jar                   jstl-1.2.jar                  shiro-spring-1.3.0.jar
biz-schedule-1.0-SNAPSHOT.jar                  ehcache-core-2.5.3.jar               kryo-shaded-3.0.0.jar         shiro-web-1.3.0.jar
biz-service-1.0-SNAPSHOT.jar                   ezmorph-1.0.4.jar                    log4j-1.2.16.jar              slf4j-api-1.7.25.jar
biz-service-impl-1.0-SNAPSHOT.jar              fastjson-1.2.24.jar                  logback-access-1.1.7.jar      spring-aop-3.2.8.RELEASE.jar
biz-vo-1.0-SNAPSHOT.jar                        fst-2.42.jar                         logback-classic-1.1.7.jar     spring-beans-3.2.8.RELEASE.jar
carzoneAgent-1.0.2.jar                         guava-18.0.jar                       logback-core-1.1.7.jar        spring-context-3.2.8.RELEASE.jar
carzone-erp-api-supplychain-1.0.9-RELEASE.jar  hibernate-validator-5.2.4.Final.jar  logback-ext-spring-0.1.4.jar  spring-context-support-3.2.8.RELEASE.jar
carzone-erp-core-1.0.9-RELEASE.jar             httpclient-4.4.jar                   mail-1.4.4.jar                spring-core-3.2.8.RELEASE.jar
carzone-platform-exception-1.1.RELEASE.jar     httpcore-4.4.jar                     minlog-1.3.0.jar              spring-data-redis-1.6.2.RELEASE.jar
carzone-platform-validate-2.1.RELEASE.jar      j2cache-core-1.4.0.jar               mybatis-3.3.0.jar             spring-expression-3.2.8.RELEASE.jar
Chart.js-2.1.3.jar                             j2cache-shiro-1.0.2.jar              mybatis-spring-1.2.3.jar      spring-jdbc-3.2.8.RELEASE.jar
classmate-1.1.0.jar                            j2cache-spring-1.0.1.jar             netty-3.2.5.Final.jar         spring-security-core-4.2.1.RELEASE.jar
commons-beanutils-1.8.3.jar                    jackson-annotations-2.6.1.jar        netty-3.7.0.Final.jar         spring-tx-3.2.8.RELEASE.jar
commons-codec-1.9.jar                          jackson-core-2.6.1.jar               objenesis-2.1.jar             spring-web-3.2.8.RELEASE.jar
commons-collections-3.2.1.jar                  jackson-core-asl-1.9.2.jar           ognl-3.0.11.jar               spring-webmvc-3.2.8.RELEASE.jar
commons-fileupload-1.2.1.jar                   jackson-databind-2.6.1.jar           okhttp-3.2.0.jar              stax-api-1.0.1.jar
commons-httpclient-3.1.jar                     jackson-mapper-asl-1.9.2.jar         okio-1.6.0.jar                utility-1.0-SNAPSHOT.jar
commons-io-2.4.jar                             java-sdk-3.13.jar                    optimist-1.2.0.jar            validation-api-1.1.0.Final.jar
commons-lang-2.6.jar                           javassist-3.11.0.GA.jar              pinyin4j-2.5.0.jar            xmlbeans-2.6.0.jar
commons-logging-1.1.1.jar                      javassist-3.19.0-GA.jar              poi-3.12.jar                  zkclient-0.1.jar
commons-pool2-2.4.2.jar                        jboss-logging-3.2.1.Final.jar        poi-ooxml-3.12.jar            zookeeper-3.4.6.jar
core-3.2.1.jar                                 jedis-2.7.3.jar                      poi-ooxml-schemas-3.12.jar

Comparisons show that

The components of geronimo-javamail_1.4_spec-1.2.jar are strange (why? Haha Experience

By viewing dependencies

Verify that the jar is by

Introduction of axis2-adb construction

It was found that the jar contains

javax.mail.internet.MimeMultipart

 

And java-mail also includes

The questions are as follows:

  1. So why were these two jar s not judged by maven? (maven will only arbitrate for the same build in GA, and not for the highest version, but for the shortest path.)
  2. Why does Java load geronimo-java mail instead of mail, which involves the loading mechanism of tomcat classloader

When an application needs to go to a class, it loads the class in the following order:

1 Bootstrap bootstrap bootstrap bootstrap bootstrap bootstrap bootstrap bootstrap bootstrap bootstrap bootstrap bootstrap bootstrap bootstrap loader

2 Loading with system Class Loader

3. Loading in WEB-INF/classes with application class loader

4. Loading in WEB-INF/lib with application class loader

5. Loading in CATALINA_HOME/lib using the common class loader

 

So the same lib is based on sorting (different machines and different systems may have different sorting)

So in introducing new builds, you need to figure out whether dependencies are necessary and whether some of them need to be excluded (the most common is the jar of servlet s, which can be configured through scope)

So summarize the knowledge points as follows:

  1. maven Arbitration
  2. Component scope
  3. tomcat class loading mechanism

When introducing components, we need to pay attention to whether the original component versions (such as post-arbitration version changes) are affected, and we need to compare the jar versions before and after.

Amend as follows

Good habits are worth having: Define dependency management as much as possible by managing dependency through this element with half the effort.

Topics: Spring snapshot Shiro Ehcache