diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle index 62389be57548..df0edcbf8e90 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle @@ -109,7 +109,6 @@ dependencies { } optional("org.hibernate.validator:hibernate-validator") optional("org.influxdb:influxdb-java") - optional("org.jolokia:jolokia-core") optional("org.liquibase:liquibase-core") { exclude group: "javax.xml.bind", module: "jaxb-api" } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaEndpoint.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaEndpoint.java deleted file mode 100644 index bdc668852b5c..000000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaEndpoint.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.jolokia; - -import java.util.Map; -import java.util.function.Supplier; - -import org.jolokia.http.AgentServlet; - -import org.springframework.boot.actuate.endpoint.annotation.Endpoint; -import org.springframework.boot.actuate.endpoint.web.EndpointServlet; -import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint; - -/** - * {@link Endpoint @Endpoint} to expose a Jolokia {@link AgentServlet}. - * - * @author Phillip Webb - * @since 2.0.0 - */ -@ServletEndpoint(id = "jolokia") -public class JolokiaEndpoint implements Supplier { - - private final Map initParameters; - - public JolokiaEndpoint(Map initParameters) { - this.initParameters = initParameters; - } - - @Override - public EndpointServlet get() { - return new EndpointServlet(AgentServlet.class).withInitParameters(this.initParameters); - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaEndpointAutoConfiguration.java deleted file mode 100644 index 2c7676bd5491..000000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaEndpointAutoConfiguration.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.jolokia; - -import org.jolokia.http.AgentServlet; - -import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; -import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * {@link EnableAutoConfiguration Auto-configuration} for the {@link JolokiaEndpoint}. - * - * @author Phillip Webb - * @since 2.0.0 - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnWebApplication(type = Type.SERVLET) -@ConditionalOnClass(AgentServlet.class) -@ConditionalOnAvailableEndpoint(endpoint = JolokiaEndpoint.class) -@EnableConfigurationProperties(JolokiaProperties.class) -public class JolokiaEndpointAutoConfiguration { - - @Bean - public JolokiaEndpoint jolokiaEndpoint(JolokiaProperties properties) { - return new JolokiaEndpoint(properties.getConfig()); - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaProperties.java deleted file mode 100644 index be93aff631f6..000000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaProperties.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.jolokia; - -import java.util.HashMap; -import java.util.Map; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Configuration properties for Jolokia. - * - * @author Christian Dupuis - * @author Dave Syer - * @author Stephane Nicoll - * @since 2.0.0 - */ -@ConfigurationProperties(prefix = "management.endpoint.jolokia") -public class JolokiaProperties { - - /** - * Jolokia settings. Refer to the documentation of Jolokia for more details. - */ - private final Map config = new HashMap<>(); - - public Map getConfig() { - return this.config; - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/package-info.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/package-info.java deleted file mode 100644 index e4d8b101c77a..000000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Auto-configuration for actuator Jolokia support. - */ -package org.springframework.boot.actuate.autoconfigure.jolokia; diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring.factories b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring.factories index 7b26c7f4e2ed..2a60a1406324 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring.factories @@ -31,7 +31,6 @@ org.springframework.boot.actuate.autoconfigure.info.InfoEndpointAutoConfiguratio org.springframework.boot.actuate.autoconfigure.integration.IntegrationGraphEndpointAutoConfiguration,\ org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthContributorAutoConfiguration,\ org.springframework.boot.actuate.autoconfigure.jms.JmsHealthContributorAutoConfiguration,\ -org.springframework.boot.actuate.autoconfigure.jolokia.JolokiaEndpointAutoConfiguration,\ org.springframework.boot.actuate.autoconfigure.ldap.LdapHealthContributorAutoConfiguration,\ org.springframework.boot.actuate.autoconfigure.liquibase.LiquibaseEndpointAutoConfiguration,\ org.springframework.boot.actuate.autoconfigure.logging.LogFileWebEndpointAutoConfiguration,\ diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JolokiaEndpointAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JolokiaEndpointAutoConfigurationIntegrationTests.java deleted file mode 100644 index 74ba6b3d448f..000000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JolokiaEndpointAutoConfigurationIntegrationTests.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.integrationtest; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; -import org.springframework.boot.actuate.autoconfigure.endpoint.web.ServletEndpointManagementContextConfiguration; -import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration; -import org.springframework.boot.actuate.autoconfigure.jolokia.JolokiaEndpointAutoConfiguration; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration; -import org.springframework.boot.actuate.autoconfigure.web.servlet.ServletManagementContextAutoConfiguration; -import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; -import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration; -import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration; -import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration; -import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; -import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.annotation.DirtiesContext; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Integration tests for {@link JolokiaEndpointAutoConfiguration}. - * - * @author Stephane Nicoll - */ -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, - properties = "management.endpoints.web.exposure.include=jolokia") -@DirtiesContext -class JolokiaEndpointAutoConfigurationIntegrationTests { - - @Autowired - private TestRestTemplate restTemplate; - - @Test - void jolokiaIsExposed() { - ResponseEntity response = this.restTemplate.getForEntity("/actuator/jolokia", String.class); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).contains("\"agent\""); - assertThat(response.getBody()).contains("\"request\":{\"type\""); - } - - @Test - void search() { - ResponseEntity response = this.restTemplate.getForEntity("/actuator/jolokia/search/java.lang:*", - String.class); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).contains("GarbageCollector"); - } - - @Test - void read() { - ResponseEntity response = this.restTemplate.getForEntity("/actuator/jolokia/read/java.lang:type=Memory", - String.class); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).contains("NonHeapMemoryUsage"); - } - - @Test - void list() { - ResponseEntity response = this.restTemplate - .getForEntity("/actuator/jolokia/list/java.lang/type=Memory/attr", String.class); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).contains("NonHeapMemoryUsage"); - } - - @Configuration(proxyBeanMethods = false) - @MinimalWebConfiguration - @Import({ JacksonAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, - JolokiaEndpointAutoConfiguration.class, EndpointAutoConfiguration.class, WebEndpointAutoConfiguration.class, - ServletManagementContextAutoConfiguration.class, ManagementContextAutoConfiguration.class, - ServletEndpointManagementContextConfiguration.class }) - static class Application { - - } - - @Target(ElementType.TYPE) - @Retention(RetentionPolicy.RUNTIME) - @Documented - @Import({ ServletWebServerFactoryAutoConfiguration.class, DispatcherServletAutoConfiguration.class, - ValidationAutoConfiguration.class, WebMvcAutoConfiguration.class, JacksonAutoConfiguration.class, - ErrorMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class }) - protected @interface MinimalWebConfiguration { - - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaEndpointAutoConfigurationTests.java deleted file mode 100644 index 902defaef0b0..000000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaEndpointAutoConfigurationTests.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.jolokia; - -import java.util.Collection; -import java.util.Collections; - -import org.jolokia.http.AgentServlet; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.actuate.autoconfigure.endpoint.web.ServletEndpointManagementContextConfiguration; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration; -import org.springframework.boot.actuate.autoconfigure.web.servlet.ServletManagementContextAutoConfiguration; -import org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint; -import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointDiscoverer; -import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration; -import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext; -import org.springframework.boot.test.context.runner.WebApplicationContextRunner; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.util.ReflectionTestUtils; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link JolokiaEndpointAutoConfiguration}. - * - * @author Christian Dupuis - * @author Andy Wilkinson - * @author Stephane Nicoll - */ -class JolokiaEndpointAutoConfigurationTests { - - private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(DispatcherServletAutoConfiguration.class, - ManagementContextAutoConfiguration.class, ServletManagementContextAutoConfiguration.class, - ServletEndpointManagementContextConfiguration.class, JolokiaEndpointAutoConfiguration.class, - TestConfiguration.class)); - - @Test - void jolokiaServletShouldBeEnabledByDefault() { - this.contextRunner.withPropertyValues("management.endpoints.web.exposure.include=jolokia").run((context) -> { - ExposableServletEndpoint endpoint = getEndpoint(context); - assertThat(endpoint.getRootPath()).isEqualTo("jolokia"); - Object servlet = ReflectionTestUtils.getField(endpoint.getEndpointServlet(), "servlet"); - assertThat(servlet).isInstanceOf(AgentServlet.class); - }); - } - - @Test - void jolokiaServletWhenEndpointNotExposedShouldNotBeDiscovered() { - this.contextRunner.run((context) -> { - Collection endpoints = context.getBean(ServletEndpointsSupplier.class) - .getEndpoints(); - assertThat(endpoints).isEmpty(); - }); - } - - @Test - void jolokiaServletWhenDisabledShouldNotBeDiscovered() { - this.contextRunner.withPropertyValues("management.endpoint.jolokia.enabled=false") - .withPropertyValues("management.endpoints.web.exposure.include=jolokia").run((context) -> { - Collection endpoints = context.getBean(ServletEndpointsSupplier.class) - .getEndpoints(); - assertThat(endpoints).isEmpty(); - }); - } - - @Test - void jolokiaServletWhenHasCustomConfigShouldApplyInitParams() { - this.contextRunner.withPropertyValues("management.endpoint.jolokia.config.debug=true") - .withPropertyValues("management.endpoints.web.exposure.include=jolokia").run((context) -> { - ExposableServletEndpoint endpoint = getEndpoint(context); - assertThat(endpoint.getEndpointServlet()).extracting("initParameters") - .isEqualTo(Collections.singletonMap("debug", "true")); - }); - } - - private ExposableServletEndpoint getEndpoint(AssertableWebApplicationContext context) { - Collection endpoints = context.getBean(ServletEndpointsSupplier.class).getEndpoints(); - return endpoints.iterator().next(); - } - - @Configuration(proxyBeanMethods = false) - static class TestConfiguration { - - @Bean - ServletEndpointDiscoverer servletEndpointDiscoverer(ApplicationContext applicationContext) { - return new ServletEndpointDiscoverer(applicationContext, null, Collections.emptyList()); - } - - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java index 67dcf86f57af..005d1bab1aa2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java @@ -16,11 +16,16 @@ package org.springframework.boot.actuate.autoconfigure.security.servlet; +import java.io.IOException; import java.time.Duration; import java.util.Base64; import java.util.function.Supplier; -import org.jolokia.http.AgentServlet; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.junit.jupiter.api.Test; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; @@ -159,7 +164,7 @@ static class TestServletEndpoint implements Supplier { @Override public EndpointServlet get() { - return new EndpointServlet(AgentServlet.class); + return new EndpointServlet(ExampleServlet.class); } } @@ -187,4 +192,12 @@ protected void configure(HttpSecurity http) throws Exception { } + static class ExampleServlet extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + } + + } + } diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 8ab36d9f9859..5ad163e3fb02 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -842,13 +842,6 @@ bom { ] } } - library("Jolokia", "1.7.1") { - group("org.jolokia") { - modules = [ - "jolokia-core" - ] - } - } library("jOOQ", "3.14.15") { prohibit("[3.15.0,)") { because "it requires Java 11" diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/jmx.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/jmx.adoc index af4626e31c18..ad3a52b2a439 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/jmx.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/jmx.adoc @@ -52,57 +52,3 @@ If you do not want to expose endpoints over JMX, you can set the configprop:mana exposure: exclude: "*" ---- - - - -[[actuator.jmx.jolokia]] -=== Using Jolokia for JMX over HTTP -Jolokia is a JMX-HTTP bridge that provides an alternative method of accessing JMX beans. -To use Jolokia, include a dependency to `org.jolokia:jolokia-core`. -For example, with Maven, you would add the following dependency: - -[source,xml,indent=0,subs="verbatim"] ----- - - org.jolokia - jolokia-core - ----- - -You can then expose the Jolokia endpoint by adding `jolokia` or `*` to the configprop:management.endpoints.web.exposure.include[] property. -You can then access it by using `/actuator/jolokia` on your management HTTP server. - -NOTE: The Jolokia endpoint exposes Jolokia's servlet as an actuator endpoint. -As a result, it is specific to servlet environments, such as Spring MVC and Jersey. -The endpoint is not available in a WebFlux application. - - - -[[actuator.jmx.jolokia.customizing]] -==== Customizing Jolokia -Jolokia has a number of settings that you would traditionally configure by setting servlet parameters. -With Spring Boot, you can use your `application.properties` file. -To do so, prefix the parameter with `management.endpoint.jolokia.config.`, as the following example shows: - -[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ----- - management: - endpoint: - jolokia: - config: - debug: true ----- - - - -[[actuator.jmx.jolokia.disabling]] -==== Disabling Jolokia -If you use Jolokia but do not want Spring Boot to configure it, set the configprop:management.endpoint.jolokia.enabled[] property to `false`, as follows: - -[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ----- - management: - endpoint: - jolokia: - enabled: false ----- diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/build.gradle index 73e8a80d6ece..e009488c4aae 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/build.gradle @@ -11,8 +11,6 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-security")) implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) - runtimeOnly("org.jolokia:jolokia-core") - testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testRuntimeOnly("org.apache.httpcomponents:httpclient") { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/main/java/smoketest/actuator/customsecurity/SampleActuatorCustomSecurityApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/main/java/smoketest/actuator/customsecurity/SampleActuatorCustomSecurityApplication.java index e7cd3b911090..8ecc5d525507 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/main/java/smoketest/actuator/customsecurity/SampleActuatorCustomSecurityApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/main/java/smoketest/actuator/customsecurity/SampleActuatorCustomSecurityApplication.java @@ -16,8 +16,19 @@ package smoketest.actuator.customsecurity; +import java.io.IOException; +import java.util.function.Supplier; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.springframework.boot.SpringApplication; +import org.springframework.boot.actuate.endpoint.web.EndpointServlet; +import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; @SpringBootApplication public class SampleActuatorCustomSecurityApplication { @@ -26,4 +37,27 @@ public static void main(String[] args) { SpringApplication.run(SampleActuatorCustomSecurityApplication.class, args); } + @Bean + TestServletEndpoint servletEndpoint() { + return new TestServletEndpoint(); + } + + @ServletEndpoint(id = "se1") + static class TestServletEndpoint implements Supplier { + + @Override + public EndpointServlet get() { + return new EndpointServlet(ExampleServlet.class); + } + + } + + static class ExampleServlet extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + } + + } + } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java index 17913301f46e..94e777394576 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java @@ -125,27 +125,27 @@ void actuatorSecureEndpointWithAuthorizedUser() { @Test void secureServletEndpointWithAnonymous() { - ResponseEntity entity = restTemplate().getForEntity("/actuator/jolokia", String.class); + ResponseEntity entity = restTemplate().getForEntity("/actuator/se1", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); - entity = restTemplate().getForEntity(getManagementPath() + "/actuator/jolokia/list", String.class); + entity = restTemplate().getForEntity(getManagementPath() + "/actuator/se1/list", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); } @Test void secureServletEndpointWithUnauthorizedUser() { - ResponseEntity entity = userRestTemplate().getForEntity(getManagementPath() + "/actuator/jolokia", + ResponseEntity entity = userRestTemplate().getForEntity(getManagementPath() + "/actuator/se1", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN); - entity = userRestTemplate().getForEntity(getManagementPath() + "/actuator/jolokia/list", String.class); + entity = userRestTemplate().getForEntity(getManagementPath() + "/actuator/se1/list", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN); } @Test void secureServletEndpointWithAuthorizedUser() { - ResponseEntity entity = adminRestTemplate().getForEntity(getManagementPath() + "/actuator/jolokia", + ResponseEntity entity = adminRestTemplate().getForEntity(getManagementPath() + "/actuator/se1", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - entity = adminRestTemplate().getForEntity(getManagementPath() + "/actuator/jolokia/list", String.class); + entity = adminRestTemplate().getForEntity(getManagementPath() + "/actuator/se1/list", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); }