A binding to HttpCommandExecutorService was already configured error

87 views
Skip to first unread message

Koper, Dies

unread,
Jan 30, 2013, 1:34:10 AM1/30/13
to jclou...@googlegroups.com
Hi,

I have a modified HttpCommandExecutorServiceModule that installs my
subclass of JavaUrlHttpCommandExecutorService. I added this service
module to defaultModules() of the builder in my FGCPApiMetadata class.
My expect tests now fail with a guice creation error. I suppose I need
to bind this module in another place for the expect tests to work. Where
and how?

com.google.inject.CreationException: Guice creation errors:

1) A binding to org.jclouds.http.HttpCommandExecutorService was already
configured at
org.jclouds.rest.internal.BaseRestApiExpectTest$ExpectModule.configure(B
aseRestApiExpectTest.java:237).
at
org.jclouds.fujitsu.fgcp.http.ChangeReturnCodeTo500IfErrorJavaUrlHttpCom
mandExecutorServiceModule.configure(ChangeReturnCodeTo500IfErrorJavaUrlH
ttpCommandExecutorServiceModule.java:40)

1 error
...
at
org.jclouds.rest.internal.BaseRestApiExpectTest.createInjector(BaseRestA
piExpectTest.java:560)

I tried adding the following method to my expect test class, but that
gave me even more guice errors:

@Override
protected Module createModule() {
return new TestFGCPRestClientModule() {

@Override
public void configure() {
super.configure();
install(new
ChangeReturnCodeTo500IfErrorJavaUrlHttpCommandExecutorServiceModule());
}
};

Cheers,
Dies

Adrian Cole

unread,
Jan 30, 2013, 8:18:18 PM1/30/13
to jclou...@googlegroups.com
taking a wild guess here as I don't have the contents of:
ChangeReturnCodeTo500IfErrorJavaUrlHttpCommandExecutorServiceModule

What I think you want to do is just make a linked binding.

ex. bind(JavaUrlHttpCommandExecutorService.class).to(YourSub.class);

don't attempt to rebind HttpCommandExecutorService.class directly.

-A
> --
> You received this message because you are subscribed to the Google Groups "jclouds-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jclouds-dev...@googlegroups.com.
> To post to this group, send email to jclou...@googlegroups.com.
> Visit this group at http://groups.google.com/group/jclouds-dev?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Koper, Dies

unread,
Jan 30, 2013, 8:23:39 PM1/30/13
to jclou...@googlegroups.com
> taking a wild guess here as I don't have the contents of:
> ChangeReturnCodeTo500IfErrorJavaUrlHttpCommandExecutorServiceModule

@ConfiguresHttpCommandExecutorService
public class
ChangeReturnCodeTo500IfErrorJavaUrlHttpCommandExecutorServiceModule
extends AbstractModule {

@Override
protected void configure() {
install(new SSLModule());

bind(HttpCommandExecutorService.class).to(ChangeReturnCodeTo500IfErrorJa
vaUrlHttpCommandExecutorService.class)
.in(Scopes.SINGLETON);
}
}

This is aligned with JavaUrlHttpCommandExecutorServiceModule#configure.
I can try changing HttpCommandExecutorService.class to
JavaUrlHttpCommandExecutorService.class.

Which I bind in FGCPApiMetadata:

.defaultModules(
ImmutableSet.<Class<? extends Module>> of(
FGCPComputeServiceContextModule.class,

ChangeReturnCodeTo500IfErrorJavaUrlHttpCommandExecutorServiceModule.clas
s,
FGCPRestClientModule.class));

And that's not working for the except tests.

Regards,
Dies Koper

Koper, Dies

unread,
Jan 30, 2013, 9:27:33 PM1/30/13
to jclou...@googlegroups.com
I've made that change and now get:

com.google.inject.CreationException: Guice creation errors:

1) No implementation for
com.google.common.base.Supplier<javax.net.ssl.SSLContext> annotated with
@com.google.inject.name.Named(value=untrusted) was bound.
while locating
com.google.common.base.Supplier<javax.net.ssl.SSLContext> annotated with
@com.google.inject.name.Named(value=untrusted)
for parameter 8 at
org.jclouds.fujitsu.fgcp.http.ChangeReturnCodeTo500IfErrorJavaUrlHttpCom
mandExecutorService.<init>(ChangeReturnCodeTo500IfErrorJavaUrlHttpComman
dExecutorService.java:70)
at
org.jclouds.fujitsu.fgcp.config.FGCPRestClientModule.configure(FGCPRestC
lientModule.java:139)

2) No implementation for javax.net.ssl.HostnameVerifier annotated with
@com.google.inject.name.Named(value=untrusted) was bound.
while locating javax.net.ssl.HostnameVerifier annotated with
@com.google.inject.name.Named(value=untrusted)
for parameter 7 at
org.jclouds.fujitsu.fgcp.http.ChangeReturnCodeTo500IfErrorJavaUrlHttpCom
mandExecutorService.<init>(ChangeReturnCodeTo500IfErrorJavaUrlHttpComman
dExecutorService.java:70)
at
org.jclouds.fujitsu.fgcp.config.FGCPRestClientModule.configure(FGCPRestC
lientModule.java:139)

2 errors
at
com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Er
rors.java:435)
at
com.google.inject.internal.InternalInjectorCreator.initializeStatically(
InternalInjectorCreator.java:154)
...
at
org.jclouds.fujitsu.fgcp.services.ErrorResponseExpectTest.testIllegalSta
teDueToSystemReconfiguration(ErrorResponseExpectTest.java:37)

Regards,
Dies Koper


> -----Original Message-----
> From: jclou...@googlegroups.com [mailto:jclouds-
> d...@googlegroups.com] On Behalf Of Koper, Dies
> Sent: Thursday, 31 January 2013 12:24 PM
> To: jclou...@googlegroups.com
> Subject: RE: A binding to HttpCommandExecutorService was already
> configured error
>
> > taking a wild guess here as I don't have the contents of:
> >
> ChangeReturnCodeTo500IfErrorJavaUrlHttpCommandExecutorServiceModul
> e
>
> @ConfiguresHttpCommandExecutorService
> public class
> ChangeReturnCodeTo500IfErrorJavaUrlHttpCommandExecutorServiceModul
Reply all
Reply to author
Forward
0 new messages