Tagbangers Blog

Talking from "Correct the classpath of your application" to a typical mistake that beginners tend to make when dealing with error messages

Hello everyone, how are you doing?

I'm sorry that I didn't introduce myself in my previous blog. I just forgot to do so, lol.

I'm Lanbo, a newbie back-end software engineer at Tagbangers.

And as a newbie who is not talented, I faced many problems on the road of programming. 

By solving the problems I often learn something valuable, which I feel like if I could know that earlier that would save my time and life!

Therefore, today I would like to share one of them, and hope this can help someone.

The Error Message

Without further ado, let's have a look on the error message I'd like to talk about.

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:    


org.hibernate.search.elasticsearch.client.impl.DefaultElasticsearchClientFactory.createClient(DefaultElasticsearchClientFactory.java:92)

The following method did not exist:    


org.elasticsearch.client.RestClientBuilder.setMaxRetryTimeoutMillis(I)Lorg/elasticsearch/client/RestClientBuilder;

The method's class, org.elasticsearch.client.RestClientBuilder, is available from the following locations:    

        jar:file:/Users/pei/.m2/repository/org/elasticsearch/client/elasticsearch-rest-client/7.6.2/elasticsearch-rest-client-7.6.2.jar!/org/elasticsearch/client/RestClientBuilder.class

The class hierarchy was loaded from the following locations:    

org.elasticsearch.client.RestClientBuilder: file:/Users/pei/.m2/repository/org/elasticsearch/client/elasticsearch-rest-client/7.6.2/elasticsearch-rest-client-7.6.2.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.client.RestClientBuilder


Process finished with exit code 1

Have you read it? And have you read this current line?

I bet $100 that you read every word of the above line but you certainly did not read most of the error message!

It's normal. 

Chances are, even you spend time trying reading entire error message, you may get stuck in the first few lines quickly. 

This is especially true for those long ones (yes this one is a SHORT one!).

Solution?

What beginners like me tend to do is, grab some keywords and, Google it. All hail Google oriented programming!

Then I reached this stack overflow question (yes, all hail to SO oriented programming too!). Most of the times, this will give you the correct answer to fixing your problem.

Unfortunately, it was not the answer. It is not rare though, we just keep googling since often your problems are asked hundreds of times instead of several times. 

You will finally find the answer somewhere sometime.


Will you?


At least it worked for me most times. But it didn't, for this time, despite that I spent almost a day on it. 

There are many pages with similar error messages, but they just not the same one to mine.


I became anxious and losing patient, almost wanted to give it up.

Then I took a rest, and came back to this the other day with another way to try.

Solution!

I go back to read the error message, words by words, trying to understand as much as I can.

It turns out that I misunderstood the error message. The very last line suggests

Correct the classpath of your application so that it contains a single, compatible version of org.hibernate.search.engine.Version

When searching for this message, others mostly have problems with dependencies repeated in different places. 

That makes me think mine is the same reason. That is not.


The key is not that the version is not single, but is that it is not compatible.


Simply,

org.hibernate.search.elasticsearch.client.impl.DefaultElasticsearchClientFactory.createClient()

this method is calling

org.elasticsearch.client.RestClientBuilder.setMaxRetryTimeoutMillis()

but as the error message pointed out, it does not exist.

It does not exist not because it was there but the computer failed to find out that. It is simply just not there. elasticsearch 7.6.2 has no such method; it has been removed since elasticsearch 7.

As a solution, I downgrade my elasticsearch to 6.8.13 and everything works well now. Just add this to pom.xml/<properties>

<elasticsearch.version>6.8.13</elasticsearch.version>


Of course, as a beginner I'm not sure if my solution is correct/optimized. 

If there is a better/more proper solution please kindly let me know!


Review and some thoughts


I will still try to Google for most problems I meet in the future, but if you failed this way in rare cases, don't be too frustrated. 

Calm done and try to read the error messages with some patience - you may find it surprisingly understandable! 

Otherwise, just hands up and give it up to the pros (sigh...)