Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

service registration example is not working #229

Closed
simon1212 opened this issue Mar 28, 2017 · 5 comments
Closed

service registration example is not working #229

simon1212 opened this issue Mar 28, 2017 · 5 comments

Comments

@simon1212
Copy link

simon1212 commented Mar 28, 2017

It looks like consul client 0.14.0 is using the wrong version of jackson-datatype-guava.

When i execute

    @Test
    public void testServiceRegistration() throws Exception {

        final Consul consul = Consul.builder().build(); // connect to Consul on localhost
        final AgentClient agentClient = consul.agentClient();

        final String serviceName = "MyService";
        final String serviceId = "1";

        agentClient.register(8080, 3L, serviceName, serviceId);
    }

I get the following exception:

java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.ReferenceType.upgradeFrom(Lcom/fasterxml/jackson/databind/JavaType;Lcom/fasterxml/jackson/databind/JavaType;)Lcom/fasterxml/jackson/databind/type/ReferenceType;

	at com.fasterxml.jackson.datatype.guava.GuavaTypeModifier.modifyType(GuavaTypeModifier.java:44)
	at com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:525)
	at com.fasterxml.jackson.databind.type.TypeFactory.constructType(TypeFactory.java:470)
	at com.fasterxml.jackson.databind.cfg.MapperConfig.constructType(MapperConfig.java:280)
	at com.fasterxml.jackson.databind.cfg.MapperConfig.introspectClassAnnotations(MapperConfig.java:310)
	at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.removeIgnorableTypes(BeanSerializerFactory.java:674)
	at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.findBeanProperties(BeanSerializerFactory.java:545)
	at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.constructBeanSerializer(BeanSerializerFactory.java:361)
	at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.findBeanSerializer(BeanSerializerFactory.java:272)
	at com.fasterxml.jackson.databind.ser.BeanSerializerFactory._createSerializer2(BeanSerializerFactory.java:225)
	at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:153)
	at com.fasterxml.jackson.databind.SerializerProvider._createUntypedSerializer(SerializerProvider.java:1203)
	at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1176)
	at com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:517)
	at com.fasterxml.jackson.databind.SerializerProvider.findTypedValueSerializer(SerializerProvider.java:724)
	at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.forRootType(ObjectWriter.java:1349)
	at com.fasterxml.jackson.databind.ObjectWriter.<init>(ObjectWriter.java:109)
	at com.fasterxml.jackson.databind.ObjectMapper._newWriter(ObjectMapper.java:654)
	at com.fasterxml.jackson.databind.ObjectMapper.writerWithType(ObjectMapper.java:3161)
	at retrofit2.converter.jackson.JacksonConverterFactory.requestBodyConverter(JacksonConverterFactory.java:67)
	at retrofit2.Retrofit.nextRequestBodyConverter(Retrofit.java:277)
	at retrofit2.Retrofit.requestBodyConverter(Retrofit.java:258)
	at retrofit2.ServiceMethod$Builder.parseParameterAnnotation(ServiceMethod.java:678)
	at retrofit2.ServiceMethod$Builder.parseParameter(ServiceMethod.java:333)
	at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:202)
	at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:166)
	at retrofit2.Retrofit$1.invoke(Retrofit.java:145)
	at com.orbitz.consul.$Proxy9.register(Unknown Source)
	at com.orbitz.consul.AgentClient.register(AgentClient.java:180)
	at com.orbitz.consul.AgentClient.register(AgentClient.java:184)
	at com.orbitz.consul.AgentClient.register(AgentClient.java:147)
	at com.orbitz.consul.AgentClient.register(AgentClient.java:80)
	at com.mytest.consul.connection.ServiceClientTest.test2(ServiceClientTest.java:109)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.mockito.internal.junit.JUnitRule$1.evaluate(JUnitRule.java:16)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

This solved the problem for me:

<dependency>
            <groupId>com.orbitz.consul</groupId>
            <artifactId>consul-client</artifactId>
            <version>0.14.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>jackson-datatype-guava</artifactId>
                    <groupId>com.fasterxml.jackson.datatype</groupId>
                </exclusion>
            </exclusions>
</dependency>
<dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-guava</artifactId>
            <version>2.6.6</version>
</dependency>

See also:
FasterXML/jackson-datatype-guava#78

@rickfast
Copy link
Owner

Since you already fixed it, how about a pull request.

@rickfast
Copy link
Owner

Unit tests are passing, and they perform registrations. Are you sure there's not a conflict with your other dependencies

@simon1212
Copy link
Author

pretty sure there where no other dependencies on this. i'm trying to reproduce the problem in the consul-client repo.

@simon1212
Copy link
Author

ok there is a dependency conflict in my project. sorry for wasting your time. thanks for the fast response!

@rickfast
Copy link
Owner

No problem

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants