Lucene versions conflict when migrating from Xpert.ivy v4 to Axon.ivy v5.1.4
Our project have encountered an urgent situation in which we have to migrate all modules into Axon.ivy v5.1.4. The migration have some serious trouble with Lucene.
Our project uses Lucene v3.6.0 and we have the `lucene-core-v3.6.0.jar` in our `buildpath`. After migrating into Axon.ivy 5.1.4, the project cannot built anymore since we get strange complilation error:
Errors occurred during the build.
Errors running builder 'Ivy Web Service Process Class Builder' on project 'test'.
Bad return type
Exception Details:
Location:
ch/test/lucene/LuceneManager.analyzer()Lorg/apache/lucene/analysis/Analyzer; @10: areturn
Reason:
Type 'org/apache/lucene/analysis/standard/StandardAnalyzer' (current frame, stack[0]) is not assignable to 'org/apache/lucene/analysis/Analyzer' (from method signature)
Current Frame:
bci: @10
flags: { }
locals: { }
stack: { 'org/apache/lucene/analysis/standard/StandardAnalyzer' }
Bytecode:
0000000: bb00 f459 b200 28b7 00f6 b0
We found out that the Axon.ivy has upgraded Lucene to v4.5.1 which contains a lots of incompatible changes compared to Lucene v3.6.0. **The problem is we could not find a way to force the Axon.ivy build the project with `lucene-core-v3.6.0.jar` instead of the built-in `lucene-core-v4.5.1.jar`**
UPDATE
====
We later tried to upgrade our implementation into Lucene 4.5.1 but got several other problems:
(1) Axon.ivy issues warnings about we are trying to access Lucene API.
(2) Start the project in Axon.ivy Designer will encounter `ClassNotFoundException`:
Caused by: java.lang.NoClassDefFoundError: org/apache/lucene/analysis/Analyzer
at ch.soreco.alag.ria.service.taskindex.LucenceHandler.startLuceneInstance(LucenceHandler.java:6)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at ch.ivyteam.ivy.scripting.internal.types.IvyJavaMethod.invokeImpl(IvyJavaMethod.java:73)
... 35 more
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.analysis.Analyzer
at ch.ivyteam.ivy.java.internal.IvyProjectClassLoader.loadClass(IvyProjectClassLoader.java:243)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 41 more
.. even if all the jars are shipped with Axon.ivy.
(3) If we try to include the jars file into our projects (in the classpath), the build will halt with the `Bad Return Type` error above.
QUESTIONS
====
- How could we force the Axon.ivy to build our projects using the `lucene-core-v3.6.0` instead of the `lucene-core-v4.5.1` shipped with Axon.ivy?
- Why do we get strange problems when building the projects with built-in Lucene library of Axon.ivy v5.1.4?
SAMPLE PROJECTS
====
I attach in this email the two sample projects which illustrate the problems we are facing. We tested the two with AxonIvyDesigner5.1.4.48243_Windows_x64:
- [`use_built_in_lucene.iar`][1]: This project illustrates the problem which we cannot built the project if it uses Lucene's classes.
- [`use_external_lucene.iar`][2]: This project illustrates the problem which we purposely include the Lucene's jar files but the project still fails.
UPDATE 2 (extend the answer)
====
The solution from Reguel Wermelinger which suggest to repack all the classes in `lucene-core-v3.6.0.jar` in different package name works.
1- Download [JarJar][3] (hosted on Google Code, if you read this after 25.01.2016, please search it on GitHub).
2 - Put the file `lucene-core-v3.6.0.jar` at the same directory at JarJar.
3 - Create a text file, namely `rules.txt`, contains one line
rule org.apache.lucene.** org.apache.lucene.v3_6_0.@1
4 - Execute the command
$ java -jar jarjar.jar rules.txt lucene-core-v3.6.0.jar lucene-core-v3.6.0-repacked.jar
5 - Done!
You can download the already-repackged [`lucene-core-v3.6.0-repacked.jar`][4]
Please note that this is only a work-around. The Axon.ivy still has problem if you use the Lucene v4.5.1 shipped with it.
[1]: https://app.box.com/s/ggaz5cuiip9g6wb1bdq2l1js7xxi2emx
[2]: https://app.box.com/s/j8gkpnxnmr9oydyelxy446ej7urqb6d9https://app.box.com/s/j8gkpnxnmr9oydyelxy446ej7urqb6d9
[3]: https://code.google.com/p/jarjar/downloads/list
[4]: https://app.box.com/s/9efw6bxhm8gkws25gd34d44qwu30662r