Skip to content

ServletEndpointManagementContextConfiguration not consistent with JerseyAutoConfiguration #15625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nioertel opened this issue Jan 4, 2019 · 2 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@nioertel
Copy link

nioertel commented Jan 4, 2019

While upgrading from Spring Boot 2.1.0 to 2.1.1 some of our tests started failing as the ApplicationContext couldn't be loaded because of:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.autoconfigure.web.servlet.JerseyApplicationPath' available
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:343)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:335)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1101)
	at org.springframework.boot.actuate.autoconfigure.endpoint.web.ServletEndpointManagementContextConfiguration$JerseyServletEndpointManagementContextConfiguration.servletEndpointRegistrar(ServletEndpointManagementContextConfiguration.java:98)

I created a minimal project to reproduce the issue:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>jersey-issue</groupId>
	<artifactId>jersey-issue</artifactId>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.1.RELEASE</version>
	</parent>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jersey</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>
</project>

Two classes under src/test/java:
DummyApplication.java:

package test;

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DummyApplication {
}

DummyTest.java:

package test;

import org.assertj.core.api.BDDAssertions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class DummyTest {

	@Test
	public void dummyTest() {
		BDDAssertions.assertThat(true).isTrue();
	}

}

When downgrading to Spring Boot 2.1.0.RELEASE, the test runs green.
Running on JDK 1.8.0_112, Maven 3.5.2

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 4, 2019
@nioertel
Copy link
Author

nioertel commented Jan 4, 2019

As there is no assurance that an actual ResourceConfig bean is present here:

@ConditionalOnClass(ResourceConfig.class)
ServletEndpointManagementContextConfiguration::JerseyServletEndpointManagementContextConfiguration

I feel it was not safe to add

JerseyApplicationPath jerseyApplicationPath = this.context
       .getBean(JerseyApplicationPath.class);

in Spring Boot 2.1.1.

@mbhave
Copy link
Contributor

mbhave commented Jan 5, 2019

Since JerseyWebEndpointManagementContextConfiguration adds a ResourceConfig bean if one isn't present, this might be an ordering issue.

@mbhave mbhave added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 5, 2019
@mbhave mbhave added this to the 2.1.x milestone Jan 5, 2019
@mbhave mbhave self-assigned this Feb 7, 2019
@mbhave mbhave modified the milestones: 2.1.x, 2.1.3 Feb 9, 2019
@mbhave mbhave closed this as completed in 26da45a Feb 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

3 participants