dropwizard managed object exception while startup

206 views
Skip to first unread message

Burak DEDE

unread,
Mar 13, 2015, 8:40:58 AM3/13/15
to dropwiz...@googlegroups.com
Hi everyone,

I am trying to initialize a managed object (third party soap client) with the start of dropwizard and use it through Resource to make some calls according to jersey method mapping. It seems fine when I try to initialize the object manually, and injecting manually to resource class by giving credentials. (need to get session id to make calls to soap web client) but no luck when try to wire it through Configuration & ConfigurationFactory pattern. Suspecting there is some kind of immature initialization going on that its giving this exception cause same thing manually not getting any error but its looks wrong to do that way.


Here is the pattern I am doing and exception I am getting. 

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:117)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:135)
at com.sun.proxy.$Proxy56.openSession(Unknown Source)
at com.odeal.util.SmsSoapClient.<init>(SmsSoapClient.java:45)
at com.odeal.factory.SmsSoapClientFactory.buildSoapClient(SmsSoapClientFactory.java:55)
at com.odeal.App.run(App.java:32)
at com.odeal.App.run(App.java:14)
at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:42)
at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:76)
at io.dropwizard.cli.Cli.run(Cli.java:70)
at io.dropwizard.Application.run(Application.java:73)
at com.odeal.App.main(App.java:17)



// config.yaml file
smsProvider:
username: //my username
password: // password
sender: // some info


public class SmsServiceConfiguration extends Configuration{


@NotNull
private SmsSoapClientFactory smsSoapClientFactory = new SmsSoapClientFactory();

@JsonCreator
public SmsServiceConfiguration(@JsonProperty("smsProvider") SmsSoapClientFactory smsSoapClientFactory) {
this.smsSoapClientFactory = smsSoapClientFactory;
}

@JsonProperty("smsProvider")
public SmsSoapClientFactory getSmsSoapClientFactory() {
return smsSoapClientFactory;
}

}


public class SmsSoapClientFactory {

private String username;

private String password;

private String sender;

private SmsSoapClient smsSoapClient;

private KeenClient keenClient;

@JsonProperty
public String getUsername() {
return username;
}

@JsonProperty
public void setUsername(String username) {
this.username = username;
}

@JsonProperty
public String getPassword() {
return password;
}

@JsonProperty
public void setPassword(String password) {
this.password = password;
}

@JsonProperty
public String getSender() {
return sender;
}

@JsonProperty
public void setSender(String sender) {
this.sender = sender;
}


public SmsSoapClient buildSoapClient(Environment env) {
if (smsSoapClient != null) { return smsSoapClient; }

final SmsSoapClient client= new SmsSoapClient(getUsername(), getPassword());

env.lifecycle().manage(new Managed() {
@Override
public void start() throws Exception {
                client.openSession(); // this is where exception occurs making just simple session init call
            }

@Override
public void stop() throws Exception {
}
});

this.smsSoapClient = client;

return smsSoapClient;
}

}


// application class run method

@Override
public void run(SmsServiceConfiguration configuration, Environment environment) throws Exception {
final SmsSoapClient smsSoapClient = configuration.getSmsSoapClientFactory().buildSoapClient(environment);

// register resources = endpoints
environment.jersey().register(new SmsResource(smsSoapClient));
}


Carlo Barbara

unread,
Mar 17, 2015, 10:21:11 AM3/17/15
to dropwiz...@googlegroups.com
I would launch this with an IDE and attach a debugger. You can then verify if your configuration is being deserialized properly. If that's the case, it's a problem with the way your wiring your client.

--
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/d/optout.

Burak DEDE

unread,
Mar 17, 2015, 5:09:21 PM3/17/15
to dropwiz...@googlegroups.com
Did that Carlo, I find no problem with configuration and deserialization process. Nothing special in wiring process simple configuration factory class and buildX method that returns soapClient. I could able to wire mock object into Resource class with no problem, does not make sense why this one fails.

--
You received this message because you are subscribed to a topic in the Google Groups "dropwizard-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dropwizard-user/td6Sjl4UUxU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dropwizard-us...@googlegroups.com.

Burak DEDE

unread,
Mar 18, 2015, 5:24:46 AM3/18/15
to dropwiz...@googlegroups.com
Ok I think I found the problem, its related to yaml file. As you see my password field has a type string but I did not save it between the quotes inside the yaml file. So while debugging I find out that configuration factory just ignoring the leading zero of the password, thats why I am getting soap exception cause its not getting any valid session with that password!!. In order to confirm the problem I added new field 'something' to my yaml as regular text no quotes or anything and give it a type <String> with leading zero and again its as I expected its ignored. Hope it helps others with same weird situtation.
Reply all
Reply to author
Forward
0 new messages