PersistentProviderRegistrations.writeProviders() throws NPE if it tries to persist a provider with null layer or app context. The NPE is caused by passing null to Writer.write(). However, it is acceptable for a Provider to have its layer and/or app context null. It is allowed by the spec and there is logic which supports this in the AuthConfigFactoryImpl. So the layer and the app context should be treated as optional, just as the description is treated.
This pull request contains a test case which illustrates the problem and a fix for it: https://github.com/apache/tomcat/pull/89
Again, many thanks. Fixed in: - trunk for 9.0.2 onwards - 8.5.x for 8.5.24 onwards