Property conversion exception when linking Spring Boot container by name
mszarlinski opened this issue · 1 comments
mszarlinski commented
I created two Spring Boot apps and dockerized them according to this tutorial. Let's call them server
and client
. My goal is to execute a single GET request from client
to server
to retrieve some data. Everything works if I start a server
container with following command:
$ docker run -p 8082:8080 --name client --link 1d7
where 1d7
is generated ID for a server
container. Nevertheless, when I change 1d7
to container name ("server"), I get the following output:
2016-11-14 06:08:39.544 INFO 1 --- [ main] p.m.docker.ClientAppApplication : Starting ClientAppApplication on 354778ed8d25 with PID 1 (/app.jar started by root in /)
2016-11-14 06:08:39.559 INFO 1 --- [ main] p.m.docker.ClientAppApplication : No active profile set, falling back to default profiles: default
2016-11-14 06:08:39.819 INFO 1 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@108c4c35: startup date [Mon Nov 14 06:08:39 UTC 2016]; root of context hierarchy
2016-11-14 06:08:42.345 ERROR 1 --- [ main] o.s.b.b.PropertiesConfigurationFactory : Properties configuration failed validation
2016-11-14 06:08:42.345 ERROR 1 --- [ main] o.s.b.b.PropertiesConfigurationFactory : Field error in object 'server' on field 'port': rejected value [tcp://172.17.0.2:8080]; codes [typeMismatch.server.port,typeMismatch.port,typeMismatch.java.lang.Integer,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [server.port,port]; arguments []; default message [port]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer' for property 'port'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.lang.Integer]]
2016-11-14 06:08:42.348 WARN 1 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties': Could not bind properties to ServerProperties (prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.validation.BindException: org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanPropertyBindingResult: 1 errors
Field error in object 'server' on field 'port': rejected value [tcp://172.17.0.2:8080]; codes [typeMismatch.server.port,typeMismatch.port,typeMismatch.java.lang.Integer,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [server.port,port]; arguments []; default message [port]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer' for property 'port'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.lang.Integer]]
2016-11-14 06:08:42.360 ERROR 1 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Binding to target org.springframework.boot.autoconfigure.web.ServerProperties@627551fb failed:
Property: server.port
Value: tcp://172.17.0.2:8080
Reason: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer' for property 'port'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.lang.Integer]
Action:
Update your application's configuration
Any suggestions?
mszarlinski commented
It was caused by server name clash:
http://stackoverflow.com/questions/37102273/environment-variables-and-value-cant-work-together-on-spring-boot