0

I have a maven EAR project with five moduls (EAR,JPA,WSVC,WSVCRouter,Properties). When i trigger the build, I want to prevent stax-api from building as part of EAR. I have googled and found out the exceptions tag, I have used it in all the places where I have dependency tag but still this jar is not excluded. Can anyone please help me on this. Thanks !!!

<dependencies>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>


      <exclusions>
                         <exclusion>
                                <groupId>stax</groupId>
                                <artifactId>stax-api</artifactId>
                    </exclusion>
            </exclusions>
    </dependency>

</dependencies>  

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.cnasurety.framework</groupId>
            <artifactId>framework-common</artifactId>
            <version>1.0.0.2</version>
           <exclusions>
                         <exclusion>
                                <groupId>stax</groupId>
                                <artifactId>stax-api</artifactId>
                    </exclusion>
            </exclusions>   
        </dependency>


        <dependency>
            <groupId>com.cnasurety.framework</groupId>
            <artifactId>framework-jpa</artifactId>
            <version>1.0.0.4</version>

        <exclusions>
                         <exclusion>
                                <groupId>stax</groupId>
                                <artifactId>stax-api</artifactId>
                    </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.cnasurety.testutils</groupId>
            <artifactId>test-utilities</artifactId>
            <version>1.0.0.5</version>
            <scope>test</scope>

        <exclusions>
                         <exclusion>
                                <groupId>stax</groupId>
                                <artifactId>stax-api</artifactId>
                    </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.cna.tech.framework</groupId>
            <artifactId>service-invocation</artifactId>
            <version>1.1.0.0</version>

        <exclusions>
                         <exclusion>
                                <groupId>stax</groupId>
                                <artifactId>stax-api</artifactId>
                    </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.cna.tech.framework</groupId>
            <artifactId>service-invocation-cxf</artifactId>
            <version>1.0.3.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-common-utilities</artifactId>
                </exclusion>
                 <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-javamail_1.4_spec</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-servlet_3.0_spec</artifactId>
            </exclusion>


            <exclusion>
                        <groupId>stax</groupId>
                        <artifactId>stax-api</artifactId>
            </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-tools-common</artifactId>
            <version>${cxf.version}</version>
            <exclusions>
            <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-javamail_1.4_spec</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-servlet_3.0_spec</artifactId>
            </exclusion>


            <exclusion>
                        <groupId>stax</groupId>
                        <artifactId>stax-api</artifactId>
            </exclusion>
        </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf.version}</version>
            <exclusions>
            <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-javamail_1.4_spec</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-servlet_3.0_spec</artifactId>
            </exclusion>


            <exclusion>
                        <groupId>stax</groupId>
                        <artifactId>stax-api</artifactId>
            </exclusion>
        </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>${cxf.version}</version>
            <exclusions>
            <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-javamail_1.4_spec</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-servlet_3.0_spec</artifactId>
            </exclusion>


            <exclusion>
                        <groupId>stax</groupId>
                        <artifactId>stax-api</artifactId>
            </exclusion>
        </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-databinding-jaxb</artifactId>
            <version>${cxf.version}</version>
            <exclusions>
            <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-javamail_1.4_spec</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-servlet_3.0_spec</artifactId>
            </exclusion>


            <exclusion>
                        <groupId>stax</groupId>
                        <artifactId>stax-api</artifactId>
            </exclusion>
        </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.5</version>

        <exclusions>
                         <exclusion>
                                <groupId>stax</groupId>
                                <artifactId>stax-api</artifactId>
                    </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>5.0</version>

        <exclusions>
                         <exclusion>
                                <groupId>stax</groupId>
                                <artifactId>stax-api</artifactId>
                    </exclusion>
            </exclusions>

        </dependency>

        <!-- SLF4J logging API and implementation -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.25</version>

        <exclusions>
                         <exclusion>
                                <groupId>stax</groupId>
                                <artifactId>stax-api</artifactId>
                    </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.25</version>

        <exclusions>
                         <exclusion>
                                <groupId>stax</groupId>
                                <artifactId>stax-api</artifactId>
                    </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>jta</artifactId>
            <version>1.1</version>

        <exclusions>
                         <exclusion>
                                <groupId>stax</groupId>
                                <artifactId>stax-api</artifactId>
                    </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

enter code here
Jackson2489
  • 11
  • 3
  • 10
  • You seemed to add exclusions without thinking about it. Check first where the dependency `stax-api` is coming from...This can be done by using `mvn dependency:tree`... – khmarbaise Aug 23 '18 at 07:38

1 Answers1

1

Did you try the mvn dependency:tree to see if any other library don't use the stax-api?

In this link shows that 348 other libs use the stax-api.

Other thing you can try it`s use bannedDependencies.

Best Regards

Renan Souza
  • 71
  • 2
  • 12
  • Hi Renan Souza, Thanks very much for your help. This helped me in finding out the exact problem in where the dependency is present and now the Stax2 api is not part of the build. Apache - CXF common utils requires this jar. Thanks again :) – Jackson2489 Aug 23 '18 at 18:15
  • Hi I have removed the stax api from the build thanks to your suggestions But im unable to remove another jar (neethi.jar from the build). I have found in the dependency tree from where it is being used, but still neethi,jar is not getting removed from the EAR file. please advise – Jackson2489 Aug 23 '18 at 21:57
  • Hi Jackson, for this dependency I found [those](https://mvnrepository.com/artifact/org.apache.neethi/neethi/usages) libs. Are your project private or can you share on GitHub? – Renan Souza Aug 23 '18 at 23:36
  • Hi Renan Souza, Thanks again, I have added exclusion to all CXF dependencies and now i got it removed from the ear. Thanks again !!! – Jackson2489 Aug 24 '18 at 19:54
  • Jackson2489, can you help me and mark as resolved :D – Renan Souza Aug 27 '18 at 14:34