I have a project using Jersey 2.7 with multiple servlets, working properly. When I switch to Jersey 2.12, I have an inconsistent behavior, where only one of the servlets is properly constructed (i.e. the constructor for the subclass of ResourceConfig is not even called). It looks like there's some contention between them during the servlets initialization.
Here's my web.xml:
<servlet>
<servlet-name>app1-bootstrap</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.bootstrap.App1JerseyBootstrap</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>app2-bootstrap</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.bootstrap.App2JerseyBootstrap</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>app2-bootstrap</servlet-name>
<url-pattern>/rest/dynamic/v1/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>app1-bootstrap</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
And here is the CTOR for app1 (not always called):
@Slf4j
public class App1JerseyBootstrapextends ResourceConfig {
@javax.inject.Inject
public App1JerseyBootstrap(ServiceLocator serviceLocator) {
...
CTOR for app2 (sometimes called once, sometimes twice):
public class App2JerseyBootstrap extends ResourceConfig {
public App2JerseyBootstrap () {
...
What am I doing wrong? I've looked through Jersey documentation regarding migration, and didn't find anything related. Thanks!