Exception in dropwizard service while creating Jersey Client

980 views
Skip to first unread message

Paras Goel

unread,
Mar 13, 2013, 1:23:53 PM3/13/13
to dropwiz...@googlegroups.com
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

Coda Hale

unread,
Mar 13, 2013, 1:25:10 PM3/13/13
to dropwiz...@googlegroups.com
You need to indent the bits of your YAML file after "httpClient". It's being parsed as an empty string, and Jackson can't make a JerseyClientConfiguration out of an empty string.

---
Coda Hale
http://codahale.com



--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Paras Goel

unread,
Mar 13, 2013, 2:14:15 PM3/13/13
to dropwiz...@googlegroups.com
Thanks, you are genius,

It is working now :-)
Reply all
Reply to author
Forward
0 new messages