Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchMethodError in OcrFieldHighlighter with Solr 9.7 #457

Closed
thomaslow opened this issue Sep 11, 2024 · 3 comments · Fixed by kitodo/kitodo-presentation#1335
Closed

NoSuchMethodError in OcrFieldHighlighter with Solr 9.7 #457

thomaslow opened this issue Sep 11, 2024 · 3 comments · Fixed by kitodo/kitodo-presentation#1335
Assignees
Labels
bug Something isn't working

Comments

@thomaslow
Copy link

Hello DBMDZ-Team,

there is an incompatibility with the recently released Solr 9.7. Version 9.7 depends on Lucene 9.11.1, which changed the constructor of FieldHighlighter , which doesn't match OcrFieldHighlighter any more.

kitodo_presentation_devel_solr_1 2024-09-11T10:42:09.422326000+02:00 Caused by: java.lang.NoSuchMethodError: 'void org.apache.lucene.search.uhighlight.FieldHighlighter.<init>(java.lang.String, org.apache.lucene.search.uhighlight.FieldOffsetStrategy, java.text.BreakIterator, org.apache.lucene.search.uhighlight.PassageScorer, int, int, org.apache.lucene.search.uhighlight.PassageFormatter)'
kitodo_presentation_devel_solr_1 2024-09-11T10:42:09.422349000+02:00    at com.github.dbmdz.solrocr.lucene.OcrFieldHighlighter.<init>(OcrFieldHighlighter.java:54) ~[?:?]
kitodo_presentation_devel_solr_1 2024-09-11T10:42:09.422374000+02:00    at solrocr.OcrHighlighter.getOcrFieldHighlighter(OcrHighlighter.java:678) ~[?:?]
kitodo_presentation_devel_solr_1 2024-09-11T10:42:09.422422000+02:00    at solrocr.OcrHighlighter.highlightOcrFields(OcrHighlighter.java:343) ~[?:?]
kitodo_presentation_devel_solr_1 2024-09-11T10:42:09.422454000+02:00    at com.github.dbmdz.solrocr.solr.SolrOcrHighlighter.doHighlighting(SolrOcrHighlighter.java:122) ~[?:?]
kitodo_presentation_devel_solr_1 2024-09-11T10:42:09.422494000+02:00    at solrocr.OcrHighlightComponent.process(OcrHighlightComponent.java:134) ~[?:?]
kitodo_presentation_devel_solr_1 2024-09-11T10:42:09.422526000+02:00    at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:456) ~[?:?]
kitodo_presentation_devel_solr_1 2024-09-11T10:42:09.422549000+02:00    at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:226) ~[?:?]
kitodo_presentation_devel_solr_1 2024-09-11T10:42:09.422581000+02:00    at org.apache.solr.core.SolrCore.execute(SolrCore.java:2880) ~[?:?]
kitodo_presentation_devel_solr_1 2024-09-11T10:42:09.422602000+02:00    at org.apache.solr.servlet.HttpSolrCall.executeCoreRequest(HttpSolrCall.java:890) ~[?:?]
kitodo_presentation_devel_solr_1 2024-09-11T10:42:09.422626000+02:00    at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:576) ~[?:?]
kitodo_presentation_devel_solr_1 2024-09-11T10:42:09.422647000+02:00    ... 47 more

Steps to reproduce the behavior

Run kitodo/kitodo-presentation functional tests with Solr 9.7 and solr-ocrhighlighting-0.9.0.jar.

The issue does not occur with Solr 9.6.

Cheers,
Thomas

@jbaiter
Copy link
Member

jbaiter commented Sep 11, 2024

Thanks for reporting, I'll start work on Solr 9.7 compatibility soon, likely not before October 1st though, I'm on vacation for the next two weeks.

jbaiter added a commit that referenced this issue Sep 12, 2024
This one was fun. Lucene 9.11 changed the signature for the
`FieldHighlighter` constructor to add an 8th parameter.

This meant that we had to call different constructors for different
Solr/Lucene versions. Unfortunately, Java requires that the superclass
constructor invocation must be the first top-level statement in a
subclass constructor, i.e. dynamic selection is not possible in Java.

It is however no problem at the bytecode level, and so we supply a
handcrafted (via `jasm`) `FieldHighlighterAdapter.class` that does the
dynamic superclass constructor invocation.

It's shipped as a precompiled .class (along with the commented .jasm
source code and build instructions) since I could for the life of me
figure out how to integrate jasm into the maven build.

Maven woes also required removing the JavaDoc plugin, since that was
unable to pick up the .class from the resources directory. Since the
plugin is not really used as a library anyway, I think this is an
acceptable tradeoff.
jbaiter added a commit that referenced this issue Sep 12, 2024
This one was fun. Lucene 9.11 changed the signature for the
`FieldHighlighter` constructor to add an 8th parameter.

This meant that we had to call different constructors for different
Solr/Lucene versions. Unfortunately, Java requires that the superclass
constructor invocation must be the first top-level statement in a
subclass constructor, i.e. dynamic selection is not possible in Java.

It is however no problem at the bytecode level, and so we supply a
handcrafted (via `jasm`) `FieldHighlighterAdapter.class` that does the
dynamic superclass constructor invocation.

It's shipped as a precompiled .class (along with the commented .jasm
source code and build instructions) since I could for the life of me
figure out how to integrate jasm into the maven build.

Maven woes also required removing the JavaDoc plugin, since that was
unable to pick up the .class from the resources directory. Since the
plugin is not really used as a library anyway, I think this is an
acceptable tradeoff.
jbaiter added a commit that referenced this issue Sep 12, 2024
This one was fun. Lucene 9.11 changed the signature for the
`FieldHighlighter` constructor to add an 8th parameter.

This meant that we had to call different constructors for different
Solr/Lucene versions. Unfortunately, Java requires that the superclass
constructor invocation must be the first top-level statement in a
subclass constructor, i.e. dynamic selection is not possible in Java.

It is however no problem at the bytecode level, and so we supply a
handcrafted (via `jasm`) `FieldHighlighterAdapter.class` that does the
dynamic superclass constructor invocation.

It's shipped as a precompiled .class (along with the commented .jasm
source code and build instructions) since I could not for the life of
me figure out how to integrate jasm into the maven build.

Maven woes also required removing the JavaDoc plugin, since that was
unable to pick up the .class from the resources directory. Since the
plugin is not really used as a library anyway, I think this is an
acceptable tradeoff.
jbaiter added a commit that referenced this issue Sep 12, 2024
This one was fun. Lucene 9.11 changed the signature for the
`FieldHighlighter` constructor to add an 8th parameter.

This meant that we had to call different constructors for different
Solr/Lucene versions. Unfortunately, Java requires that the superclass
constructor invocation must be the first top-level statement in a
subclass constructor, i.e. dynamic selection is not possible in Java.

It is however no problem at the bytecode level, and so we supply a
handcrafted (via `jasm`) `FieldHighlighterAdapter.class` that does the
dynamic superclass constructor invocation.

It's shipped as a precompiled .class (along with the commented .jasm
source code and build instructions) since I could not for the life of
me figure out how to integrate jasm into the maven build.

Maven woes also required removing the JavaDoc plugin, since that was
unable to pick up the .class from the resources directory. Since the
plugin is not really used as a library anyway, I think this is an
acceptable tradeoff.
@jbaiter
Copy link
Member

jbaiter commented Sep 13, 2024

Latest release 0.9.1 with support for Solr 9.7 was just released, please give it a try!

@thomaslow
Copy link
Author

Thank you for your quick response and the update release. Your changes seem to work, see kitodo/kitodo-presentation#1335. Have a nice vacation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants