Spring

 What causes "java.lang.AssertionError: null at org.apache.catalina.mapper.Mapper.internalMap(Mapper.java:744)"?

Steven Calderwood's profile image
Steven Calderwood posted Oct 29, 2020 12:55 PM

Has anyone ever seen the following error from tomcat occur? We have had this happen twice this week; we are using Spring Bot 2.2.10 which has Tomcat 9.0.38:

java.lang.AssertionError: null

at org.apache.catalina.mapper.Mapper.internalMap(Mapper.java:744)

at org.apache.catalina.mapper.Mapper.map(Mapper.java:702)

at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:696)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:337)

at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)

at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)

at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)

at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.base/java.lang.Thread.run(Unknown

 

What we've experienced twice this week is the app instance performs fine for days, then will start having this happen for a handful of requests and over the course of the next several hours the frequency of occurrence will increase to the point where the instance can no longer handle any request without triggering this error

Daniel Mikusa's profile image
Daniel Mikusa

>This is typically caused by an application or library retaining a reference to a request, response, InputStream, OutputStream etc. beyond the lifetime of the original request (Tomcat recycles these objects and you end up with two threads trying to use the same object).

 

from: https://bz.apache.org/bugzilla/show_bug.cgi?id=64859#c1

 

The code in question is checking if the MappingData has a host set.

 

https://github.com/apache/tomcat/blob/9.0.38/java/org/apache/catalina/mapper/Mapper.java#L739-L744

 

>Map the specified host name and URI, mutating the given mapping data

 

The method is supposed to populate that data in-place. If it's being reused as is the assertion from the bug entry then would make sense.

 

When things get into that messed up state, you might want to take some heap dumps and look through them for instances of MappingData objects and check to see what is referencing them. Perhaps you can spot something odd going on there, like one of your Controller's retaining references to one of the object Mark mentioned, or perhaps look at your controllers to see what they are retaining references to, again, with an eye for anything that might hold onto one of the objects mentioned.