# Java APM with new SpringBoot 2.6.7 is erroring out on Zuul components

**URL:** <https://discuss.elastic.co/t/java-apm-with-new-springboot-2-6-7-is-erroring-out-on-zuul-components/304248>\
**Category:** APM\
**Tags:** docker, java\
**Created:** [May 9, 2022, 12:07pm UTC](https://discuss.elastic.co/t/java-apm-with-new-springboot-2-6-7-is-erroring-out-on-zuul-components/304248 "2022-05-09T12:07:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kim\_Attree](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kim_attree/32/87043_2.png) [@Kim\_Attree](https://discuss.elastic.co/u/Kim_Attree)\
**Post date:** [May 9, 2022, 12:07pm UTC](https://discuss.elastic.co/t/java-apm-with-new-springboot-2-6-7-is-erroring-out-on-zuul-components/304248/1 "2022-05-09T12:07:35Z")

</div>

**Kibana version** : 7.16.1

**Elasticsearch version** : 7.16.1

**APM Server version** : 7.16.1

**APM Agent language and version** : 1.30.1

**Browser version** : n/a

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: docker build, java agent installed and added to entrypoint.

**Fresh install or upgraded from other version?** Fresh

**Is there anything special in your setup?** No

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**: n/a

**Steps to reproduce** :

1. SpringBoot 2.6.7
2. Spring Cloud Starter Netflix Zuul 2.2.10.RELEASE
3. OpenJDK 17 (eclipse-temurin:17.0.3\_7-jdk-alpine)
4. APM Agent 1.30.1

**Errors in browser console (if relevant)**: n/a

```auto
java.lang.IllegalStateException: WebApplicationObjectSupport instance [org.springframework.cloud.netflix.zuul.web.ZuulController@7e366c6f] does not run within a ServletContext. Make sure the object is fully configured! 33 
  at org.springframework.web.context.support.WebApplicationObjectSupport.getServletContext(WebApplicationObjectSupport.java:139) 34 
  at org.springframework.web.servlet.mvc.ServletWrappingController.access$200(ServletWrappingController.java:86) 35 
  at org.springframework.web.servlet.mvc.ServletWrappingController$DelegatingServletConfig.getServletContext(ServletWrappingController.java:199) 36 
  at co.elastic.apm.agent.servlet.JavaxUtil.getInfoFromServletContext(JavaxUtil.java:33) 37 
  at co.elastic.apm.agent.servlet.JavaxServletVersionInstrumentation$JavaxInit$AdviceClass.onEnter(JavaxServletVersionInstrumentation.java:40) 38 
  at com.netflix.zuul.http.ZuulServlet.init(ZuulServlet.java:55) 39 
  at org.springframework.web.servlet.mvc.ServletWrappingController.afterPropertiesSet(ServletWrappingController.java:153) 40 
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) 41 
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) 42 
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) 43 
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) 44 
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) 45 
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) 46 
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) 47 
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) 48 
  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) 49 
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) 50 
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) 51 
  at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) 52 
  at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) 53 
  at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) 54 
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) 55 
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) 56 
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) 57 
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) 58 
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) 59 
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) 60  
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) 61 
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) 62 
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) 63 
  at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:270) 64 
  at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:762) 65 
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:567) 66 
  at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) 67 
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) 68 
  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) 69 
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) 70 
  at lithium.application.LithiumShutdownSpringApplication.run(LithiumShutdownSpringApplication.java:16) 71 
  at lithium.ui.network.admin.UiNetworkAdminApplication.main(UiNetworkAdminApplication.java:63) 72 
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 73 
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) 74 
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 75 
  at java.base/java.lang.reflect.Method.invoke(Method.java:568) 76 
  at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) 77 
  at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) 78 
  at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) 79 
  at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)

```

**Provide logs and/or server output (if relevant)**: n/a

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [May 10, 2022, 7:47am UTC](https://discuss.elastic.co/t/java-apm-with-new-springboot-2-6-7-is-erroring-out-on-zuul-components/304248/2 "2022-05-10T07:47:13Z")

</div>

This error should have no effect on functionality, it only reflects an error trying to discover the Servlet API version for logging purposes. So the fix for this is just catching the exception more quietly. The version may still be discovered later on when a `Servlet#service` is invoked.  
Please try [this snapshot](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-java%2Fapm-agent-java-mbp/detail/PR-2627/2/artifacts) and see if the error is eliminated.  
Hopefully, everything else works as expected.

---

<div class="post-metadata">

**Author:** ![Kim\_Attree](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kim_attree/32/87043_2.png) [@Kim\_Attree](https://discuss.elastic.co/u/Kim_Attree)\
**Post date:** [May 10, 2022, 12:21pm UTC](https://discuss.elastic.co/t/java-apm-with-new-springboot-2-6-7-is-erroring-out-on-zuul-components/304248/3 "2022-05-10T12:21:43Z")

</div>

Hi Eyal,

Using the new snapshot agent jar:

> 2022-05-10 12:18:21,940 [main] INFO co.elastic.apm.agent.configuration.StartupInfo - Starting Elastic APM 1.30.2-SNAPSHOT.e3f7eee

Still getting that same error for now:

> 2022-05-10 12:18:42,173 [main] INFO co.elastic.apm.agent.servlet.JavaxUtil - Failed obtain ServletContext from ServletConfig org.springframework.web.servlet.mvc.ServletWrappingController$DelegatingServletConfig@1fdd5517. Stack trace printed in debug level
> 
> 121
> 
> java.lang.IllegalStateException: WebApplicationObjectSupport instance [org.springframework.cloud.netflix.zuul.web.ZuulController@46610fc9] does not run within a ServletContext. Make sure the object is fully configured!
> 
> 120
> 
> at org.springframework.web.context.support.WebApplicationObjectSupport.getServletContext(WebApplicationObjectSupport.java:139)
> 
> 119
> 
> at org.springframework.web.servlet.mvc.ServletWrappingController.access$200(ServletWrappingController.java:86)
> 
> 118
> 
> at org.springframework.web.servlet.mvc.ServletWrappingController$DelegatingServletConfig.getServletContext(ServletWrappingController.java:199)
> 
> 117
> 
> at co.elastic.apm.agent.servlet.adapter.JavaxServletApiAdapter.getServletContextFromServletConfig(JavaxServletApiAdapter.java:223)
> 
> 116
> 
> at co.elastic.apm.agent.servlet.servicename.InitServiceNameInstrumentation$JavaxInitServiceNameInstrumentation$AdviceClass.onEnter(InitServiceNameInstrumentation.java:99)

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [May 10, 2022, 1:43pm UTC](https://discuss.elastic.co/t/java-apm-with-new-springboot-2-6-7-is-erroring-out-on-zuul-components/304248/4 "2022-05-10T13:43:46Z")

</div>

Hmm, maybe this comes from your Spring error handling configuration...  
The agent shouldn't log the stack trace, unless you set it to log at `debug` level.

Since this should have no functionality effect, maybe the best workaround is to disable this specific instrumentation through the [`disable_instrumentations`](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-disable-instrumentations) config. Since we don't want to disable all `servlet` instrumentations, I added the ability to disable this one specifically.  
Please download [this snapshot](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-java%2Fapm-agent-java-mbp/detail/PR-2627/4/artifacts) and try it out with the following configuration: `disable_instrumentations=servlet-version`. If are not sure how to do that, check out the [configuration guide](https://www.elastic.co/guide/en/apm/agent/java/current/configuration.html#configuration) to learn more about available options.

I hope this eliminates the noise and let you enjoy the agent 🙂  
Looking forward for your feedback.

---

<div class="post-metadata">

**Author:** ![Kim\_Attree](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kim_attree/32/87043_2.png) [@Kim\_Attree](https://discuss.elastic.co/u/Kim_Attree)\
**Post date:** [May 10, 2022, 2:51pm UTC](https://discuss.elastic.co/t/java-apm-with-new-springboot-2-6-7-is-erroring-out-on-zuul-components/304248/5 "2022-05-10T14:51:30Z")

</div>

Hi Eyal,

I setup the necessary configuration and confirmed its picked up with the new snapshot:

> 2022-05-10 14:48:34,087 [main] INFO co.elastic.apm.agent.configuration.StartupInfo - Starting Elastic APM 1.30.2-SNAPSHOT.6b6a317 as ui-network-admin (1.12-82fb5e44) on Java 17.0.3 Runtime version: 17.0.3+7 VM version: 17.0.3+7 (Eclipse Adoptium) Linux 5.4.170+  
> 2022-05-10 14:48:34,088 [main] INFO co.elastic.apm.agent.configuration.StartupInfo - disable\_instrumentations: 'servlet-version' (source: Environment Variables)

Doesnt seem to have had the intended effect, same error:

> java.lang.IllegalStateException: WebApplicationObjectSupport instance [org.springframework.cloud.netflix.zuul.web.ZuulController@1bd6638] does not run within a ServletContext. Make sure the object is fully configured!  
> 122  
> at org.springframework.web.context.support.WebApplicationObjectSupport.getServletContext(WebApplicationObjectSupport.java:139)

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [May 11, 2022, 4:36am UTC](https://discuss.elastic.co/t/java-apm-with-new-springboot-2-6-7-is-erroring-out-on-zuul-components/304248/6 "2022-05-11T04:36:39Z")

</div>

Please share the entire stack trace you get with the latest snapshot and the added configuration.

If possible, set `log_level=debug` and share the entire log from startup through [https://gist.github.com/](https://gist.github.com/).  
If you set [`log_file`](https://www.elastic.co/guide/en/apm/agent/java/current/config-logging.html#config-log-file), then it will contain only agent logging.

---

<div class="post-metadata">

**Author:** ![Kim\_Attree](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kim_attree/32/87043_2.png) [@Kim\_Attree](https://discuss.elastic.co/u/Kim_Attree)\
**Post date:** [May 11, 2022, 8:12am UTC](https://discuss.elastic.co/t/java-apm-with-new-springboot-2-6-7-is-erroring-out-on-zuul-components/304248/7 "2022-05-11T08:12:51Z")

</div>

Hi @Eyal_Koren I PM'ed you the gist thank you.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [May 11, 2022, 10:06am UTC](https://discuss.elastic.co/t/java-apm-with-new-springboot-2-6-7-is-erroring-out-on-zuul-components/304248/8 "2022-05-11T10:06:29Z")

</div>

Thank you for providing it!  
It's another instrumentation that we do for `Servlet#init` (thus suffers from the same too-early `getServletContext` invocation).  
Please try [this snapshot](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-java%2Fapm-agent-java-mbp/detail/PR-2627/5/artifacts), first without the `disable_instrumentations` config, and if you still get stack traces, or you want to remove the single-line info loggings as well, then try with: `disable_instrumentations=servlet-version,servlet-service-name`

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [May 15, 2022, 7:05am UTC](https://discuss.elastic.co/t/java-apm-with-new-springboot-2-6-7-is-erroring-out-on-zuul-components/304248/9 "2022-05-15T07:05:57Z")

</div>

@Kim_Attree I'll be happy to get your feedback based on the instructions above, to know whether we can consider this as handled, or another step required

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [May 17, 2022, 11:31am UTC](https://discuss.elastic.co/t/java-apm-with-new-springboot-2-6-7-is-erroring-out-on-zuul-components/304248/10 "2022-05-17T11:31:11Z")

</div>

Version [1.31.0](https://www.elastic.co/guide/en/apm/agent/java/current/release-notes-1.x.html#release-notes-1.31.0) has been released with the related fix. The reported errors should not contain the stack traces above.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 7, 2022, 7:31am UTC](https://discuss.elastic.co/t/java-apm-with-new-springboot-2-6-7-is-erroring-out-on-zuul-components/304248/11 "2022-06-07T07:31:47Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
