1

I am using ElasticSearch and JackRabbit (or...I am trying too). JackRabbit seems to be depending on Lucene 3.6.x and ElasticSearch is depending on 4.3.1. I am using Maven and JBoss 7.1.1. I get Lucene 4.3.1 on the classpath but then h*** is breaking loose in the log because JackRabbit requires something from the older Lucene.

How do I solve this?

LuckyLuke
  • 47,771
  • 85
  • 270
  • 434

2 Answers2

3

you will need to take the conflicting libraries that you wish to use (elastic search and jackrabbit) and make both into jboss as7 modules. with jboss 7 modular classloading you can "contain" each of them with its own dependencies as a separate module and expose to your application only the api that you use.

its a bit complicated (full docs here) but will allow you to have each of them use their own version of lucene - they will each be packed into a module with all of theor dependency tree.

EDIT - there's some more info on how to export only some of a module's content in te jboss modules documentation. you want to make sure you dont export lucene out of any of the modules

radai
  • 23,949
  • 10
  • 71
  • 115
  • Okey, so I should install ElasticSearch and Jackrabbit in JBoss and then I can use two different versions? – LuckyLuke Jul 25 '13 at 13:44
  • But if you look at all the dependencies for http://mvnrepository.com/artifact/org.elasticsearch/elasticsearch/0.90.2 does that mean that I have to install all of them as a module too? – LuckyLuke Jul 25 '13 at 13:48
  • @LuckyLuke- you can install elastic search and all of its dependencies (so everything in that list you linked) as a single jboss module, that will only expose elastic search. there's an exmaple of how to do this for drools here - http://www.samaxes.com/2012/11/running-drools-5-4-0-final-as-a-jboss-as-7-module/, just to see how they list all of drools' dependencies – radai Jul 25 '13 at 14:02
  • @LuckyLuke - you coudl have maven do it for you. create an empty maven project that depends just on the ElasticSearch libs you need, then bind an invocation of the maven dependency plugin to copy all your your dependencies - http://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html - it should include the transitives as well. see here too - http://stackoverflow.com/questions/11973889/copy-dependencies-transitive-and-not-transitive – radai Jul 25 '13 at 14:15
0

You can create two custom classloaders instances and load ElasticSearch class with one of them and JackRabbit with the other. The first one must be loading classes from Lucene 3.6.x jar, the other from v.4.3.1 jar

Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275
  • why not? they will have classloader that jboss provided for the app as the parent, they will try to find Lucene classes first then delegate to parent – Evgeniy Dorofeev Jul 25 '13 at 14:18
  • and you will need to place them where normal jboss classloading wont find them and access them with special code that sets the context class loader. and if you try anything fancy with them (like write them as part of jms or infinispan) you'll be in a world of pain. jboss has custom classloading. use it. – radai Jul 25 '13 at 14:30