Why is the dropwizard setting not working?

I recently ported the dropwizard version of the HVDF project from 0.6.2 to 0.8.2. When I try to run the application, I get the following error. I provide the config class and yml file below:

Configuration class:

package com.mongodb.hvdf;

import io.dropwizard.Configuration;

import java.util.LinkedHashMap;
import java.util.Map;

import com.mongodb.hvdf.configuration.MongoGeneralConfiguration;

public class HVDFConfiguration extends Configuration {

    public MongoGeneralConfiguration mongodb = new MongoGeneralConfiguration();
    public Map<String, Object> services = new LinkedHashMap<String, Object>();
}

      

Yaml file:

server:
  applicationConnectors:
    - type: http
      port: 8080

      

The following error appears at runtime:

config.yml has an error:
  * Failed to parse configuration at: server.applicationConnectors.[0]; Could not resolve type id 'http' into a subtype of [simple type, class io.dropwizard.jetty.ConnectorFactory]
 at [Source: N/A; line: -1, column: -1] (through reference chain: com.mongodb.hvdf.HVDFConfiguration["server"]->io.dropwizard.server.DefaultServerFactory["applicationConnectors"]->java.util.ArrayList[0])

      

+3


source to share


2 answers


The problem was that the DiscoverableSubtypeResolver class, which Jackson uses to dynamically load class types and set their configuration, could not find the src / main / resource folder due to some Path Path issues. But when I added this resource folder to my build path everything works fine.



+1


source


If you are using maven shade plugin use the required transformers.

adding ServicesResourceTransformer to your shadow plugin config might fix the problem. more about transformers ( here ).



<configuration>
<transformers>
    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
        <mainClass>com.yb.exercise.dw.App</mainClass>
    </transformer>
</transformers>

      

+9


source







All Articles