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

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

java.lang.IllegalStateException: WebApplicationObjectSupport instance [] does not run within a ServletContext. Make sure the object is fully configured! 33 
  at 34 
  at org.springframework.web.servlet.mvc.ServletWrappingController.access$200( 35 
  at org.springframework.web.servlet.mvc.ServletWrappingController$DelegatingServletConfig.getServletContext( 36 
  at co.elastic.apm.agent.servlet.JavaxUtil.getInfoFromServletContext( 37 
  at co.elastic.apm.agent.servlet.JavaxServletVersionInstrumentation$JavaxInit$AdviceClass.onEnter( 38 
  at 39 
  at org.springframework.web.servlet.mvc.ServletWrappingController.afterPropertiesSet( 40 
  at 41 
  at 42 
  at 43 
  at 44 
  at$doGetBean$0( 45 
  at 46 
  at 47 
  at 48 
  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate( 49 
  at 50 
  at 51 
  at 52 
  at 53 
  at 54 
  at 55 
  at 56 
  at 57 
  at 58 
  at 59 
  at$doGetBean$0( 60  
  at 61 
  at 62 
  at 63 
  at 64 
  at 65 
  at 66 
  at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh( 67 
  at org.springframework.boot.SpringApplication.refresh( 68 
  at org.springframework.boot.SpringApplication.refreshContext( 69 
  at 70 
  at 71 
  at 72 
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 73 
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke( 74 
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke( 75 
  at java.base/java.lang.reflect.Method.invoke( 76 
  at 77 
  at org.springframework.boot.loader.Launcher.launch( 78 
  at org.springframework.boot.loader.Launcher.launch( 79 
  at org.springframework.boot.loader.JarLauncher.main(

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

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 and see if the error is eliminated.
Hopefully, everything else works as expected.

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


java.lang.IllegalStateException: WebApplicationObjectSupport instance [] does not run within a ServletContext. Make sure the object is fully configured!




at org.springframework.web.servlet.mvc.ServletWrappingController.access$200(


at org.springframework.web.servlet.mvc.ServletWrappingController$DelegatingServletConfig.getServletContext(


at co.elastic.apm.agent.servlet.adapter.JavaxServletApiAdapter.getServletContextFromServletConfig(


at co.elastic.apm.agent.servlet.servicename.InitServiceNameInstrumentation$JavaxInitServiceNameInstrumentation$AdviceClass.onEnter(

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 config. Since we don't want to disable all servlet instrumentations, I added the ability to disable this one specifically.
Please download this snapshot 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 to learn more about available options.

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

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 [] does not run within a ServletContext. Make sure the object is fully configured!

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
If you set log_file, then it will contain only agent logging.

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

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, 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

@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

Version 1.31.0 has been released with the related fix. The reported errors should not contain the stack traces above.

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