Skip to content
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

NPE thrown when using spring boot devtools #5

Closed
gclayburg opened this issue May 28, 2021 · 3 comments
Closed

NPE thrown when using spring boot devtools #5

gclayburg opened this issue May 28, 2021 · 3 comments

Comments

@gclayburg
Copy link
Owner

This prevents the app from restarting correctly.

The workaround is to disable devtools

2021-05-27 18:29:25.609  INFO 19242 --- [  restartedMain] c.g.memuser.MemuserApplication           : Starting MemuserApplication on gary-XPS-13-9360 with PID 19242 (/home/gclaybur/dev/memuser/out/production/classes started by gclaybur in /home/gclaybur/dev/memuser)
2021-05-27 18:29:25.610  INFO 19242 --- [  restartedMain] c.g.memuser.MemuserApplication           : The following profiles are active: secure
2021-05-27 18:29:25.612  WARN 19242 --- [  restartedMain] o.s.boot.SpringApplication               : Error handling failed (org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7df0ae3 has not been refreshed yet)
2021-05-27 18:29:25.614 ERROR 19242 --- [  restartedMain] o.s.boot.SpringApplication               : Application startup failed

java.lang.NullPointerException: null
	at io.undertow.servlet.spec.ServletContextImpl.getInitParameter(ServletContextImpl.java:421) ~[undertow-servlet-1.4.27.Final.jar:1.4.27.Final]
	at org.springframework.web.context.support.ServletContextPropertySource.getProperty(ServletContextPropertySource.java:45) ~[spring-web-4.3.24.RELEASE.jar:4.3.24.RELEASE]
	at org.springframework.web.context.support.ServletContextPropertySource.getProperty(ServletContextPropertySource.java:32) ~[spring-web-4.3.24.RELEASE.jar:4.3.24.RELEASE]
	at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:81) ~[spring-core-4.3.24.RELEASE.jar:4.3.24.RELEASE]
	at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:61) ~[spring-core-4.3.24.RELEASE.jar:4.3.24.RELEASE]
	at org.springframework.core.env.AbstractEnvironment.getProperty(AbstractEnvironment.java:531) ~[spring-core-4.3.24.RELEASE.jar:4.3.24.RELEASE]
	at com.garyclayburg.upbanner.DebugDumper.dumpAll(DebugDumper.java:85) ~[upbanner-core-2.3.0.jar:2.3.0]
	at com.garyclayburg.upbanner.AppNameSpringApplicationRunListener.contextLoaded(AppNameSpringApplicationRunListener.java:52) ~[upbanner-core-2.3.0.jar:2.3.0]
	at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:66) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE]
	at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:356) [spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:301) [spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE]
	at org.springframework.boot.SpringApplication$run.call(Unknown Source) [spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE]
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) [groovy-all-2.4.17.jar:2.4.17]
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) [groovy-all-2.4.17.jar:2.4.17]
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136) [groovy-all-2.4.17.jar:2.4.17]
	at com.garyclayburg.memuser.MemuserApplication.main(MemuserApplication.groovy:39) [classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.21.RELEASE.jar:1.5.21.RELEASE]
@gclayburg
Copy link
Owner Author

Depending on how your app is started, this issue could also result in your app starting, but failing to show the banner.

@gclayburg
Copy link
Owner Author

Fixed in 5afa64f

@gclayburg
Copy link
Owner Author

The fix here will result in upbanner probing the environment only once during intial app startup. If you are using something like devtools to quickly reload the app without restarting the JVM, upbanner will just print the same banner it did during initial startup. This is to avoid application lifecycle conflicts between devtools and upbanner. As a practical matter, it is unlikely your app change that triggered the application restart would change the environment that upbanner probes. If your change does modify the environment, it is best to completely restart your app anyway.

It is possible to force upbanner to attempt to re-probe the environment on application restart. Using this flag is not recommended.

upbanner.force-recompute=true

The default is false.

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

No branches or pull requests

1 participant