Hi All,
I am getting the below exception while running my service which is using jersey client.I have tried to get resolved but still I don't have clue for the solution.
Please help to get resolve this exception:
Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [simple type, class com.yammer.dropwizard.client.JerseyClientConfiguration] from String value; no single-String constructor/factory method (through reference chain: com.ge.workflow.MailPollerConfiguration["httpClient"])
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator._createFromStringFallbacks(StdValueInstantiator.java:422)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromString(StdValueInstantiator.java:298)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromString(BeanDeserializer.java:424)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:129)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:375)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:107)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:308)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:2768)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1477)
at com.yammer.dropwizard.config.ConfigurationFactory.build(ConfigurationFactory.java:63)
at com.yammer.dropwizard.config.ConfigurationFactory.build(ConfigurationFactory.java:48)
at com.yammer.dropwizard.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:83)
at com.yammer.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:51)
at com.yammer.dropwizard.cli.Cli.run(Cli.java:53)
at com.yammer.dropwizard.Service.run(Service.java:61)
-----------------------------------------------
code snippet My Service class:
-----------------------------------------------
public void run(MailPollerConfiguration configuration,
Environment environment) throws NoSuchProviderException {
final Client jerseyClient = new JerseyClientBuilder().using(configuration.getJerseyClientConfiguration())
.using(environment)
.build();
MailMonitor monitorObj = new MailMonitor(jerseyClient);
environment.addResource(monitorObj);
environment.manage(new MailPollerManager(monitorObj));
}
--------------------------------------
snippet Configuration file:
---------------------------------------
@Valid
@NotNull
@JsonProperty
private JerseyClientConfiguration httpClient = new JerseyClientConfiguration();
public JerseyClientConfiguration getJerseyClientConfiguration() {
return httpClient;
}
---------------------------------------------
snippet yml file
-----------------------------------------------
#http Client property for jersey
httpClient:
# The socket timeout value. If a read or write to the underlying
# TCP/IP connection hasn't succeeded after this duration, a
# timeout exception is thrown.
timeout: 500ms
# The connection timeout value. If a TCP/IP connection cannot be
# established in this time, a timeout exception is thrown.
connectionTimeout: 500ms
# The time a TCP/IP connection to the server is allowed to
# persist before being explicitly closed.
timeToLive: 1 hour
# If true, cookies will be persisted in memory for the duration
# of the client's lifetime. If false, cookies will be ignored
# entirely.
cookiesEnabled: false