I need to perform a Solr query from my Quarkus application. I started using SolrJ, which worked well.
However, to be able to create a native image, I had to configure this:
quarkus.native.additional-build-args=--initialize-at-run-time=.apache.http.impl.auth
quarkus.ssl.native=true
Then everything worked fine using HttpSolrClient
.
However, our installation requires me to use ZooKeeper. So I rewrote my client using CloudHttp2SolrClient
, which worked well in dev mode.
But as soon as I wanted to create a native image, I got more errors because of class initialization.
So the configuration is now
quarkus.native.additional-build-args=--initialize-at-run-time=.apache.http.impl.auth\\,.apache.zookeeper\\,.apache.solr.client.solrj.routing
quarkus.ssl.native=true
With this, I can build the image and start the container.
But when I try to use that code, I get
.apache.solrmon.SolrException: java.io.IOException: Couldn't instantiate .apache.zookeeper.ClientCnxnSocketNIO
...
Caused by: java.io.IOException: Couldn't instantiate .apache.zookeeper.ClientCnxnSocketNIO
at .apache.zookeeper.ZooKeeper.getClientCnxnSocket(ZooKeeper.java:3407)
...
Caused by: java.lang.ClassNotFoundException: .apache.zookeeper.ClientCnxnSocketNIO
at [email protected]/java.lang.Class.forName(DynamicHub.java:1132)
Zookeeper is apparently dynamically getting classes, which of course doesn't play well with Quarkus.
So: How can I fix this? I saw that there is a Quarkus Zookeeper Client. But I don't know whether I can run a Solr query from it.
Does anyone have any experience with querying Solr from Quarkus?