Reputation: 2025
Recently I ported the HVDF project's dropwizard version from 0.6.2 to 0.8.2.Once I try to run the application I get the following error.I provide the config class and yml file below:
Config 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
I get the following error 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])
Upvotes: 3
Views: 4006
Reputation: 231
If you are using maven shade plugin, use necessary transformers.
adding ServicesResourceTransformer to your shade plugin configuration may solve the problem. read 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>
Upvotes: 9
Reputation: 2025
The problem was that DiscoverableSubtypeResolver class which jackson uses to dynamically load the class types and set their configuration could not find the src/main/resource folder due to some Build Path problems.But when I added this resource folder to my build path everything worked fine.
Upvotes: 2