Configure spring cloud contract and Zuul proxy in the same project -
i have problem integrating spring-cloud-contract service on consumer side. in service use feign (to call other services) , zuul (for routing) spring-cloud. problem happens when try run test annotated @autoconfigurestubrunner. simple class:
@runwith(springrunner.class) @springboottest @autoconfigurestubrunner(ids = {"group:artifact:+:stubs:8080"}, workoffline = true) public class withcontracttests { @test public void test() {} }
in output can see stubs started properly:
o.s.c.c.stubrunner.stubrunnerexecutor : stubs running runningstubs [namesandports={group:artifact:1.0.0-snapshot:stubs=8080}]
and have error while creating spring context:
caused by: java.lang.unsupportedoperationexception: null @ java.util.abstractlist.add(abstractlist.java:148) ~[na:1.8.0_91] @ java.util.abstractlist.add(abstractlist.java:108) ~[na:1.8.0_91] @ java.util.abstractcollection.addall(abstractcollection.java:344) ~[na:1.8.0_91] @ org.springframework.cloud.contract.stubrunner.spring.cloud.stubrunnerdiscoveryclient.getservices(stubrunnerdiscoveryclient.java:139) ~[spring-cloud-contract-stub-runner-1.0.0.rc1.jar:1.0.0.rc1] @ org.springframework.cloud.netflix.zuul.filters.discovery.discoveryclientroutelocator.locateroutes(discoveryclientroutelocator.java:105) ~[spring-cloud-netflix-core-1.2.0.rc1.jar:1.2.0.rc1] @ org.springframework.cloud.netflix.zuul.filters.discovery.discoveryclientroutelocator.locateroutes(discoveryclientroutelocator.java:43) ~[spring-cloud-netflix-core-1.2.0.rc1.jar:1.2.0.rc1] @ org.springframework.cloud.netflix.zuul.filters.simpleroutelocator.dorefresh(simpleroutelocator.java:152) ~[spring-cloud-netflix-core-1.2.0.rc1.jar:1.2.0.rc1] @ org.springframework.cloud.netflix.zuul.filters.discovery.discoveryclientroutelocator.refresh(discoveryclientroutelocator.java:155) ~[spring-cloud-netflix-core-1.2.0.rc1.jar:1.2.0.rc1] @ org.springframework.cloud.netflix.zuul.web.zuulhandlermapping.setdirty(zuulhandlermapping.java:61) ~[spring-cloud-netflix-core-1.2.0.rc1.jar:1.2.0.rc1] @ org.springframework.cloud.netflix.zuul.zuulconfiguration$zuulrefreshlistener.onapplicationevent(zuulconfiguration.java:180) ~[spring-cloud-netflix-core-1.2.0.rc1.jar:1.2.0.rc1] @ org.springframework.context.event.simpleapplicationeventmulticaster.invokelistener(simpleapplicationeventmulticaster.java:166) ~[spring-context-4.3.2.release.jar:4.3.2.release] @ org.springframework.context.event.simpleapplicationeventmulticaster.multicastevent(simpleapplicationeventmulticaster.java:138) ~[spring-context-4.3.2.release.jar:4.3.2.release] @ org.springframework.context.support.abstractapplicationcontext.publishevent(abstractapplicationcontext.java:382) ~[spring-context-4.3.2.release.jar:4.3.2.release] @ org.springframework.context.support.abstractapplicationcontext.publishevent(abstractapplicationcontext.java:388) ~[spring-context-4.3.2.release.jar:4.3.2.release] @ org.springframework.context.support.abstractapplicationcontext.publishevent(abstractapplicationcontext.java:336) ~[spring-context-4.3.2.release.jar:4.3.2.release] @ org.springframework.context.support.abstractapplicationcontext.finishrefresh(abstractapplicationcontext.java:877) ~[spring-context-4.3.2.release.jar:4.3.2.release] @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:544) ~[spring-context-4.3.2.release.jar:4.3.2.release] @ org.springframework.cloud.context.named.namedcontextfactory.createcontext(namedcontextfactory.java:110) ~[spring-cloud-context-1.1.2.release.jar:1.1.2.release] @ org.springframework.cloud.context.named.namedcontextfactory.getcontext(namedcontextfactory.java:79) ~[spring-cloud-context-1.1.2.release.jar:1.1.2.release] @ org.springframework.cloud.context.named.namedcontextfactory.getinstance(namedcontextfactory.java:115) ~[spring-cloud-context-1.1.2.release.jar:1.1.2.release] @ org.springframework.cloud.netflix.feign.feignclientfactorybean.getoptional(feignclientfactorybean.java:139) ~[spring-cloud-netflix-core-1.2.0.rc1.jar:1.2.0.rc1] @ org.springframework.cloud.netflix.feign.feignclientfactorybean.feign(feignclientfactorybean.java:84) ~[spring-cloud-netflix-core-1.2.0.rc1.jar:1.2.0.rc1] @ org.springframework.cloud.netflix.feign.feignclientfactorybean.getobject(feignclientfactorybean.java:157) ~[spring-cloud-netflix-core-1.2.0.rc1.jar:1.2.0.rc1] @ org.springframework.beans.factory.support.factorybeanregistrysupport.dogetobjectfromfactorybean(factorybeanregistrysupport.java:168) ~[spring-beans-4.3.2.release.jar:4.3.2.release]
what interesting same error occurs in spring-cloud-contract example: https://github.com/spring-cloud/spring-cloud-contract/tree/master/samples/standalone/dsl/http-client after adding zuul project. adding zuul mean adding spring-cloud-starter-zuul dependency , @enablezuulproxy annotation. after can see following error while executing test:
java.lang.unsupportedoperationexception: null @ java.util.abstractlist.add(abstractlist.java:148) ~[na:1.8.0_91] @ java.util.abstractlist.add(abstractlist.java:108) ~[na:1.8.0_91] @ java.util.abstractcollection.addall(abstractcollection.java:344) ~[na:1.8.0_91] @ org.springframework.cloud.contract.stubrunner.spring.cloud.stubrunnerdiscoveryclient.getservices(stubrunnerdiscoveryclient.java:139) ~[spring-cloud-contract-stub-runner-1.0.0.build-20160922.090756-647.jar:1.0.0.build-snapshot] @ org.springframework.cloud.netflix.zuul.filters.discovery.discoveryclientroutelocator.locateroutes(discoveryclientroutelocator.java:105) ~[spring-cloud-netflix-core-1.2.0.build-20160922.110240-890.jar:1.2.0.build-snapshot] @ org.springframework.cloud.netflix.zuul.filters.discovery.discoveryclientroutelocator.locateroutes(discoveryclientroutelocator.java:43) ~[spring-cloud-netflix-core-1.2.0.build-20160922.110240-890.jar:1.2.0.build-snapshot] @ org.springframework.cloud.netflix.zuul.filters.simpleroutelocator.dorefresh(simpleroutelocator.java:152) ~[spring-cloud-netflix-core-1.2.0.build-20160922.110240-890.jar:1.2.0.build-snapshot] @ org.springframework.cloud.netflix.zuul.filters.discovery.discoveryclientroutelocator.refresh(discoveryclientroutelocator.java:155) ~[spring-cloud-netflix-core-1.2.0.build-20160922.110240-890.jar:1.2.0.build-snapshot] @ org.springframework.cloud.netflix.zuul.web.zuulhandlermapping.setdirty(zuulhandlermapping.java:61) ~[spring-cloud-netflix-core-1.2.0.build-20160922.110240-890.jar:1.2.0.build-snapshot] @ org.springframework.cloud.netflix.zuul.zuulconfiguration$zuulrefreshlistener.onapplicationevent(zuulconfiguration.java:180) ~[spring-cloud-netflix-core-1.2.0.build-20160922.110240-890.jar:1.2.0.build-snapshot] @ org.springframework.context.event.simpleapplicationeventmulticaster.invokelistener(simpleapplicationeventmulticaster.java:166) ~[spring-context-4.3.2.release.jar:4.3.2.release] @ org.springframework.context.event.simpleapplicationeventmulticaster.multicastevent(simpleapplicationeventmulticaster.java:138) ~[spring-context-4.3.2.release.jar:4.3.2.release] @ org.springframework.context.support.abstractapplicationcontext.publishevent(abstractapplicationcontext.java:382) ~[spring-context-4.3.2.release.jar:4.3.2.release] @ org.springframework.context.support.abstractapplicationcontext.publishevent(abstractapplicationcontext.java:336) ~[spring-context-4.3.2.release.jar:4.3.2.release] @ org.springframework.context.support.abstractapplicationcontext.finishrefresh(abstractapplicationcontext.java:877) ~[spring-context-4.3.2.release.jar:4.3.2.release] @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:544) ~[spring-context-4.3.2.release.jar:4.3.2.release] @ org.springframework.boot.springapplication.refresh(springapplication.java:759) ~[spring-boot-1.4.0.build-20160728.175440-591.jar:1.4.0.build-snapshot] @ org.springframework.boot.springapplication.refreshcontext(springapplication.java:369) ~[spring-boot-1.4.0.build-20160728.175440-591.jar:1.4.0.build-snapshot] @ org.springframework.boot.springapplication.run(springapplication.java:313) ~[spring-boot-1.4.0.build-20160728.175440-591.jar:1.4.0.build-snapshot] @ org.springframework.boot.test.context.springbootcontextloader.loadcontext(springbootcontextloader.java:111) [spring-boot-test-1.4.0.build-20160728.175440-528.jar:1.4.0.build-snapshot] @ org.springframework.test.context.cache.defaultcacheawarecontextloaderdelegate.loadcontextinternal(defaultcacheawarecontextloaderdelegate.java:98) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.springframework.test.context.cache.defaultcacheawarecontextloaderdelegate.loadcontext(defaultcacheawarecontextloaderdelegate.java:116) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.springframework.test.context.support.defaulttestcontext.getapplicationcontext(defaulttestcontext.java:83) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.springframework.test.context.web.servlettestexecutionlistener.setuprequestcontextifnecessary(servlettestexecutionlistener.java:189) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.springframework.test.context.web.servlettestexecutionlistener.preparetestinstance(servlettestexecutionlistener.java:131) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.springframework.test.context.testcontextmanager.preparetestinstance(testcontextmanager.java:230) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.springframework.test.context.junit4.springjunit4classrunner.createtest(springjunit4classrunner.java:228) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.springframework.test.context.junit4.springjunit4classrunner$1.runreflectivecall(springjunit4classrunner.java:287) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:12) [junit-4.12.jar:4.12] @ org.springframework.test.context.junit4.springjunit4classrunner.methodblock(springjunit4classrunner.java:289) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.springframework.test.context.junit4.springjunit4classrunner.runchild(springjunit4classrunner.java:247) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.springframework.test.context.junit4.springjunit4classrunner.runchild(springjunit4classrunner.java:94) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.junit.runners.parentrunner$3.run(parentrunner.java:290) [junit-4.12.jar:4.12] @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:71) [junit-4.12.jar:4.12] @ org.junit.runners.parentrunner.runchildren(parentrunner.java:288) [junit-4.12.jar:4.12] @ org.junit.runners.parentrunner.access$000(parentrunner.java:58) [junit-4.12.jar:4.12] @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:268) [junit-4.12.jar:4.12] @ org.springframework.test.context.junit4.statements.runbeforetestclasscallbacks.evaluate(runbeforetestclasscallbacks.java:61) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.springframework.test.context.junit4.statements.runaftertestclasscallbacks.evaluate(runaftertestclasscallbacks.java:70) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.junit.runners.parentrunner.run(parentrunner.java:363) [junit-4.12.jar:4.12] @ org.springframework.test.context.junit4.springjunit4classrunner.run(springjunit4classrunner.java:191) [spring-test-4.3.2.release.jar:4.3.2.release] @ org.junit.runner.junitcore.run(junitcore.java:137) [junit-4.12.jar:4.12] @ com.intellij.junit4.junit4ideatestrunner.startrunnerwithargs(junit4ideatestrunner.java:117) [junit-rt.jar:na] @ com.intellij.junit4.junit4ideatestrunner.startrunnerwithargs(junit4ideatestrunner.java:42) [junit-rt.jar:na] @ com.intellij.rt.execution.junit.junitstarter.preparestreamsandstart(junitstarter.java:253) [junit-rt.jar:na] @ com.intellij.rt.execution.junit.junitstarter.main(junitstarter.java:84) [junit-rt.jar:na] @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ~[na:1.8.0_91] @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) ~[na:1.8.0_91] @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) ~[na:1.8.0_91] @ java.lang.reflect.method.invoke(method.java:498) ~[na:1.8.0_91] @ com.intellij.rt.execution.application.appmain.main(appmain.java:147) [idea_rt.jar:na]
do need additional configuration when using zuul stub runner?
oh boy mistake. can file issue in contract? until have override existing class woth sth doesn't add servers list returned delegate creates new list servers added. haven't tested against zuul :/
it's been fixed (hopefully) here - https://github.com/spring-cloud/spring-cloud-contract/issues/82
Comments
Post a Comment