Skip to content

Application fails to start when an environment variable named SERVER is present #10945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vpateleeoc opened this issue Nov 6, 2017 · 10 comments
Labels
type: bug A general bug
Milestone

Comments

@vpateleeoc
Copy link

vpateleeoc commented Nov 6, 2017

I have created a small "Hello word" kind of an application to integrate JAX-RS (Jersey) with Spring Boot 2.05M on Spring STS running 3.9.1 release. When I try to run as Spring Boot application, it immediately throws this error:

2017-11-06 17:25:22.335  WARN 8208 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatServletWebServerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'serverPropertiesWebServerFactoryCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.class]: Unsatisfied dependency expressed through method 'serverPropertiesWebServerFactoryCustomizer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties': prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'server' to org.springframework.boot.autoconfigure.web.ServerProperties
2017-11-06 17:25:22.335  INFO 8208 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-11-06 17:25:22.335 ERROR 8208 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Binding to target [Bindable@1ddae9b5 type = org.springframework.boot.autoconfigure.web.ServerProperties, value = 'provided', annotations = array<Annotation>[[empty]]] failed:

    Property: server
    Value: FIELD01
    Origin: System Environment Property "SERVER"
    Reason: No converter found capable of converting from type [java.lang.String] to type [org.springframework.boot.autoconfigure.web.ServerProperties]

Action:

Update your application's configuration
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 6, 2017
@wilkinsona
Copy link
Member

Your environment variable named SERVER is causing the problem. Can you remove it?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Nov 6, 2017
@vpateleeoc
Copy link
Author

vpateleeoc commented Nov 7, 2017 via email

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 7, 2017
@wilkinsona
Copy link
Member

Is there any other solution to resolve this issue?

Unfortunately not, no. This is a bug in the binder in Spring Boot 2.0 which we'll have to fix.

@wilkinsona wilkinsona added priority: high type: bug A general bug and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Nov 10, 2017
@wilkinsona wilkinsona added this to the 2.0.0.M7 milestone Nov 10, 2017
@wilkinsona wilkinsona changed the title "APPLICATION FAILED TO START" message gets displayed when starting Spring Boot application Application fails to start when an environment variable named SERVER is present Nov 10, 2017
@Bessonov
Copy link

Similar problem with Spring Boot 1.5.3.RELEASE and ignoreUnknownFields = false for @ConfigurationProperties.

@wilkinsona
Copy link
Member

wilkinsona commented Nov 27, 2017

@Bessonov You shouldn't be binding any configuration properties of your own from the server.* namespace and Boot's ServerProperties is already configured to ignore unknown fields.

@Bessonov
Copy link

This happens with my own namespace and I can control passed environment variables. But I think that isn't always possible and ignoreUnknownFields = false is just to strong for environment variables.

@wilkinsona
Copy link
Member

@Bessonov That sounds like a different problem to me. You may be interested in #3450 and #3427.

@chennaiyan
Copy link

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-02-19 13:23:16.716 ERROR 8268 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
any idea to solve this problem

@MahmoudAlzoghbi
Copy link

MahmoudAlzoghbi commented Apr 24, 2018

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-04-24 02:15:44.645 ERROR 10376 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field storeRepo in com.swe.controllers.AdminController required a bean of type 'com.swe.repositories.StoreRepository' that could not be found.


Action:

Consider defining a bean of type 'com.swe.repositories.StoreRepository' in your configuration.

@snicoll
Copy link
Member

snicoll commented Apr 24, 2018

@MahmoudAlzoghbi this error has nothing to do with the scope of this issue. Please ask questions on StackOverflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

7 participants