library version mismatch between direct dep and indirect dep

57 views Asked by At

My project is using toml and config parser, the library is '1.0.0', in the mean time antlr4 is used to parse another piece of input data, but the project fails to run with following error:

ANTLR Tool version 4.7.2 used for code generation does not match the current runtime version 4.13.1
ANTLR Runtime version 4.7.2 used for parser compilation does not match the current runtime version 4.13.1
Exception in thread "main" java.lang.Exception InInitializerError

The project seems to be that tomlj also use antlr4, but it is using 4.7.2 instead of 4.13.1. Is there anyway to fix this without having to use 4.7.2 in my project? The dependency is configured in project pom.xml:

<dependency>
    <groupId>org.tomlj</groupId>
    <artifactId>tomlj</artifactId>
    <version>1.0.0</version>
</dependency>
<dependency>
    <groupId>org.antlr</groupId>
    <artifactId>antlr4</artifactId>
    <version>4.13.1</version>
</dependency>
1

There are 1 answers

0
Bart Kiers On

If tomlj uses API's from the ANTLR 4.7.2 library not available in 4.13.1, then things cannot be expected to work. So you'd have to add the 4.7.2 dependecy, or try to exclude version 4.7.2 from your POM:

<dependency>
    <groupId>org.tomlj</groupId>
    <artifactId>tomlj</artifactId>
    <version>1.0.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-runtime</artifactId>
        </exclusion>
    </exclusions>
</dependency>

and then try running your code again. If that also does not work, try using version 1.1.0 of tomlj, which seems to be using a newer version of ANTLR (but still an older version, so keep the <exclusions>).