2

Disclojure: I am not a Java developer and I have little knowledge in Maven.

I am facing a problem with Clojure/Lein. I am developing a project that uses two external libraries/projects that are un-related. Both of the uses the Sesame RDF library. One of them is Any23 which uses Sesame 2.x but the other uses the version 4.x. The problem is that Any23 won't work with Sesame 4.x and the other library won't work with Sesame 2.x.

This means that :exclusions one or the other in my project.clj file won't work.

Do any solution exists to fix such dependencies issues or am I stuck?

Neoasimov
  • 1,111
  • 2
  • 10
  • 17

1 Answers1

2

There aren't any easy answers for this problem. Here are some options:

  • Upgrade Any23 to use Sesame 4.x
  • Use something like Maven Shade to rename one of the Sesame packages so that they can both be loaded on the same classpath. You may run into trouble if you try to use or share objects between the two libraries.
  • Use Clojure OSGI to isolate the packages. (This is probably the most difficult option, although also the most 'correct').

For more info, see Java, Classpath, Classloading => Multiple Versions of the same jar/project and Wikipedia's entry on JAR Hell.

Community
  • 1
  • 1
Daniel Compton
  • 13,878
  • 4
  • 40
  • 60
  • 1
    I guess you could also have as an option to split your project in 2 halves that communicate with each other (via REST or a file or stdin/out) – Timothy Pratley Feb 11 '16 at 04:30
  • @TimothyPratley yes I could, in fact it was because I was merging two projects that were communicating using REST that I ended-up with that issue :D – Neoasimov Feb 12 '16 at 19:23
  • @daniel-campton thanks! This is what I was fearing. For now, I found the namespace that was causing issue and changed the code not to use it. Since no other code is shared between the two it is now working. I will wait until Sesame get renamed into an Eclipse project in order to have two fully distinct projects :) thanks! – Neoasimov Feb 12 '16 at 19:25