vert-x3/vertx-config

Missing transitive dependency on jackson-databind in vertx-config-yaml

Closed this issue · 1 comments

onyn commented

vertx-config-yaml example in vartx-config doc throws exception:

Stack trace
Exception in thread "main" java.util.ServiceConfigurationError: io.vertx.config.spi.ConfigProcessor: io.vertx.config.yaml.YamlProcessor Unable to get public no-arg constructor
	at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:583)
	at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:674)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1233)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1265)
	at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1300)
	at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1385)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:132)
	at io.vertx.config.spi.utils.Processors.<clinit>(Processors.java:41)
	at io.vertx.config.impl.ConfigRetrieverImpl.<init>(ConfigRetrieverImpl.java:120)
	at io.vertx.config.ConfigRetriever.create(ConfigRetriever.java:53)
	at Main.main(Main.java:17)
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
	at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3143)
	at java.base/java.lang.Class.getConstructor0(Class.java:3348)
	at java.base/java.lang.Class.getConstructor(Class.java:2157)
	at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:661)
	at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:658)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:551)
	at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:669)
	... 9 more
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	... 17 more

Because dependency on com.fasterxml.jackson.core:jackson-databind is missing.

Reproducer

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>hello</groupId>
    <artifactId>world</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>12</maven.compiler.source>
        <maven.compiler.target>12</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-config-yaml</artifactId>
            <version>4.0.0-milestone3</version>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-config</artifactId>
            <version>4.0.0-milestone3</version>
        </dependency>
        <!-- Exception is gone if uncomment this dependency -->
        <!--<dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.9.1</version>
        </dependency>-->
    </dependencies>
</project>

Main.java

import io.vertx.config.ConfigRetriever;
import io.vertx.config.ConfigRetrieverOptions;
import io.vertx.config.ConfigStoreOptions;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;

public class Main {

    public static void main(String[] args) {
        Vertx vx = Vertx.vertx();
        ConfigRetrieverOptions cro = new ConfigRetrieverOptions().addStore(
            new ConfigStoreOptions()
                .setType("file")
                .setFormat("yaml")
                .setConfig(new JsonObject().put("path", "config.yml"))
        );
        ConfigRetriever.create(vx, cro).getConfig(ar -> {
            if (ar.succeeded()) {
                System.out.println(ar.result().toString());
            } else {
                ar.cause().printStackTrace();
            }
            vx.close();
        });
    }
}
gaol commented

jackson-databind has been added to vertx-config-yaml from 4.0.0-mileston4, so this should be fixed as well.