13

I have a maven project that depends on both Woodstox and XStream. Unfortunately XStream also depends on Woodstox, but a version slightly older than what I need. In the meantime though, the artifact names of the Woodstox libs changed, so maven won't consider them multiple versions of the same artifact. But the package and class names are the same, which means there is a conflict at runtime.

Now, I could obviously hack the old woodstox jar out of the build (a war file in our case) somehow but what is the proper way of solving this type of problem?

biziclop
  • 48,926
  • 12
  • 77
  • 104

2 Answers2

18

You could try excluding woodstox dependency in your dependency declaration for xstream.

  <dependency>
        <groupId>xstream.group</groupId>
        <artifactId>xstream</artifactId>
        <version>a.b.c</version>
        <exclusions>
            <exclusion>
                <groupId>woodstox.group</groupId>
                <artifactId>woodstox</artifactId>
            </exclusion>
        </exclusions>
  </dependency>
Jama A.
  • 15,680
  • 10
  • 55
  • 88
Raghuram
  • 51,854
  • 11
  • 110
  • 122
  • 6
    +1, but unfortunately that requires that the new version has the same class and package names as the old version and is otherwise backwards compatible – Sean Patrick Floyd Jan 28 '11 at 11:08
5

If you are lucky, the solution suggested by Raghuram will work.

If not, you will have to create a modified version of the XStream jar, probably using the Maven Shade Plugin, merging both XStream woodstox into one Jar, renaming all woodstox packages.

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588