Dealing with “java.lang.VerifyError: Cannot inherit from final class” in Scala using Maven.

Mahdi
2 min readAug 24, 2020

Time and time again this error has hunted me, so I decided that once and for all, I’m going to journal the details and steps I take to resolve it. Please note that this error might occur for multiple reasons and that the details and solutions in this article might not apply to your case, but I do try to begin with a short description of the error and where it comes from so you can continue your search for a solution with more confidence.

This issue arises from Java’s VerifyError Class which in turn extends the LinkageError class. VerifyError Class is responsible for flagging any inconsistency withing your dependency trees. Typically there are 3 known scenarios where you’ll encounter this error:

  1. The class aims to extend another class declared as final
  2. The method aims to override a super method declared as final
  3. The wrong argument is passed to a method

If you believe that your issue is caused by one of the mistakes above please refer to the following article by Sotirios-Efstathios (Stathis) Maneas where he covers the points above in more detail.

If you’re using Maven for managing dependencies and run into this issue you’ll have to execute the following maven commands:

  1. Clean
  2. Compile
  3. Install

Now it is worth mentioning maven does not always execute the following procedures with 100% accuracy which can leave you with headaches. So I have found that if the issue persists you can try and directly call the reimport action of maven. EX: in IntelliJ IDEA you can execute this procedure by right-clicking on your code block selecting maven and simply clicking the reimport option.

--

--