Search code examples
javamavenservletsapache-axis

How to resolve a dependency conflict caused by adding Axis2 to a Maven multi-module project


We have a multi-module Maven project with dependencies on javax.servlet-api 3.0.1. When we added an Axis2 1.6.2 dependency to one of our modules we started getting compilation errors. I believe this is due to conflicts between our dependency:

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>

and an Axis2 dependency:

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
    </dependency>

I'm not sure how to resolve this issue. Also don't understand the difference between the javax.servlet-api and servlet-api artifacts.

I have uploaded a small sample project that demonstrates the problem. https://github.com/chakatodd/axis2_dependency_woes

If the Axis2 dependency is remove from the module2/pom.xml the compilation problems are resolved.

Thank you for any insight you can offer.


Solution

  • try with exclusions:

    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2</artifactId>
        <version>1.6.2</version>
        <exclusions>
            <exclusion>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>