2

I got the error "Failed to parse configuration at: logging.appenders" when I ran a basic Dropwizard.io (v0.8.1) project using "java -jar target\helloDropwizard-1.0-SNAPSHOT.jar server".

Full error message:

Failed to parse configuration at: logging.appenders.[0]; 
Could not resolve type id 'console' into a subtype of [simple type, class io.dropwizard.logging.AppenderFactory]: known type ids = [AppenderFactory] at [Source: N/A; line: -1, column: -1] (through reference chain: io.dropwizard.
Configuration["logging"]->io.dropwizard.logging.LoggingFactory["appenders"]->java.util.ArrayList[0])

My pom.xml

<properties>
    <dropwizard.version>0.8.1</dropwizard.version>
</properties>

<dependencies>

    <!-- Dropwizard -->
    <dependency>
        <groupId>io.dropwizard</groupId>
        <artifactId>dropwizard-core</artifactId>
        <version>${dropwizard.version}</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>com.hello.helloDropwizard.App</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
Tunaki
  • 132,869
  • 46
  • 340
  • 423
Rafael Leonhardt
  • 404
  • 5
  • 15

2 Answers2

6

I needed to add ServiceResourceTransformer into shade-plugin.

<executions>
    <execution>
        <phase>package</phase>
        <goals>
            <goal>shade</goal>
        </goals>
        <configuration>
            <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                    <mainClass>com.hello.helloDropwizard.App</mainClass>
                </transformer>
                <!-- SEE HERE!!!! -->
                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                <!-- -->
            </transformers>
        </configuration>
    </execution>
</executions>

See more info in:

James Conkling
  • 3,235
  • 2
  • 25
  • 37
Rafael Leonhardt
  • 404
  • 5
  • 15
0

The proper solution to this issue is to add the appenders in the META-inf file.

See https://www.dropwizard.io/en/stable/manual/core.html#logging

Dimitrios
  • 445
  • 1
  • 4
  • 14