Skip to content

JerseyWebApplicationInitializer always gets loaded, setting a ServletContext initParameter #45289

Closed
@evandongen

Description

@evandongen

Summary:
The JerseyWebApplicationInitializer always gets loaded, setting a ServletContext initParameter contextConfigLocation to a value which breaks another WebApplicationInitalizer which already has a value for configLocation.

Details
Hi, I'm trying to incorporate springdoc (swagger / openapi docs) in our spring application, the console of the Frank!Framework. This console is a spring boot application which is bootstrapped when starting the framework.

Springdoc introduces the spring-boot-autoconfigure dependency to our application. When spring-boot-autoconfigure is present, it will load org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration.JerseyWebApplicationInitializer, defined in the JerseyAutoConfiguration. Jersey is not present, so this auto configuration won't be loaded. But, this inner static class doesn't have a @ConditionalOn* annotation which makes sure it gets loaded (in our application), setting the contextConfigLocation initParameter to <NONE> in the servletContext. This results in overriding the context config location of our WebApplicationInitializer, which in turn makes sure our application doesn't start anymore, see the attached stacktrace. The error is: Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/<NONE>].

If I debug and make sure this <NONE> init parameter is set to 'null' in org.springframework.web.context.ContextLoader#configureAndRefreshWebApplicationContext, so it isn't overriding the configLocation of the webapplicationContext, our application starts like I would expect.

I can't seem to override this init parameter (you can only set this to a non-null value or check if the value is set). I think that Conditional loading of the JerseyWebApplicationInitializer will fix this issue. Other static inner classes use conditional loading in that file as well, for instance the JacksonResourceConfigCustomizer right below it.

I've discussed this with a few other contributors to our framework and we all think that this JerseyWebApplicationInitializer shouldn't be loaded. We are using spring boot 3.4.4.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions