Failed to connect to MBean server at port 9001: Could not invoke shutdown operation: Connection refused to host: 127.0.0.1

Viewed 1264

I am using this plugin to generate a JSON file during the build time. I have created a test profile in configuration and using the below command to run.

mvn clean install -Dgpg.skip -Dspring.profiles.active=test -P test

It's giving an error message. Failed to connect to MBean server at port 9001: Could not invoke shutdown operation: Connection refused to host: 127.0.0.1

I am having bootstrap.properties in my src/main/resources. So I created application-test.properties in same folder src/main/resources.

I am using this configuration in the springdoc-openapi-maven-plugin.

<plugin>
                <groupId>org.springdoc</groupId>
                <artifactId>springdoc-openapi-maven-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                
                <configuration>
                <useTestClasspath>true</useTestClasspath>
                <profiles>
                        <profile>test</profile>
                    </profiles>
                    <apiDocsUrl>http://localhost:8083/registrationprocessor/v1/registrationstatus/v2/api-docs?group=Registration%20Status</apiDocsUrl>
                    <outputFileName>openapi.json</outputFileName>
                    <outputDir>${project.build.directory}</outputDir>
                    <skip>false</skip>
                </configuration>
                
            </plugin>

Full Error message:

{"@timestamp":"2021-05-21T12:17:21.856+05:30","@version":"1","message":"Could not locate PropertySource: Invalid URL: localhost","logger_name":"org.springframework.cloud.config.client.ConfigServicePropertySourceLocator","thread_name":"main","level":"WARN","level_value":30000,"appName":"registration-processor,application"}
{"@timestamp":"2021-05-21T12:17:21.866+05:30","@version":"1","message":"The following profiles are active: dev","logger_name":"io.mosip.registration.processor.status.api.RegistrationStatusApiApplication","thread_name":"main","level":"INFO","level_value":20000,"appName":"registration-processor,application"}
{"@timestamp":"2021-05-21T12:17:21.891+05:30","@version":"1","message":"Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6eb82908: startup date [Fri May 21 12:17:21 IST 2021]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@172ca72b","logger_name":"org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext","thread_name":"main","level":"INFO","level_value":20000,"appName":"registration-processor,application"}
{"@timestamp":"2021-05-21T12:17:22.147+05:30","@version":"1","message":"Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [io.mosip.registration.processor.status.api.RegistrationStatusApiApplication]; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'mosip.auth.adapter.impl.basepackage' in value \"${mosip.auth.adapter.impl.basepackage}\"","logger_name":"org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext","thread_name":"main","level":"WARN","level_value":30000,"appName":"registration-processor,application"}
{"@timestamp":"2021-05-21T12:17:22.156+05:30","@version":"1","message":"Application run failed","logger_name":"org.springframework.boot.SpringApplication","thread_name":"main","level":"ERROR","level_value":40000,"stack_trace":"org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [io.mosip.registration.processor.status.api.RegistrationStatusApiApplication]; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'mosip.auth.adapter.impl.basepackage' in value \"${mosip.auth.adapter.impl.basepackage}\"\n\tat org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184)\n\tat org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316)\n\tat org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)\n\tat org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)\n\tat org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)\n\tat org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)\n\tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)\n\tat org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)\n\tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)\n\tat org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:327)\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)\n\tat io.mosip.registration.processor.status.api.RegistrationStatusApiApplication.main(RegistrationStatusApiApplication.java:30)\nCaused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'mosip.auth.adapter.impl.basepackage' in value \"${mosip.auth.adapter.impl.basepackage}\"\n\tat org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:172)\n\tat org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124)\n\tat org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:237)\n\tat org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:211)\n\tat org.springframework.core.env.AbstractEnvironment.resolveRequiredPlaceholders(AbstractEnvironment.java:567)\n\tat org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.resolveBasePackage(ClassPathScanningCandidateComponentProvider.java:481)\n\tat org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:420)\n\tat org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:316)\n\tat org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:275)\n\tat org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:132)\n\tat org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:288)\n\tat org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)\n\tat org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:202)\n\tat org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:170)\n\t... 13 common frames omitted\n","appName":"registration-processor,application"}
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  49.449 s
[INFO] Finished at: 2021-05-21T12:17:22+05:30
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "test" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.4.RELEASE:start (pre-integration-test) on project registration-processor-registration-status-service: Could not figure out if the application has started: Failed to connect to MBean server at port 9001: Could not invoke shutdown operation: Connection refused to host: 127.0.0.1; nested exception is: 
[ERROR]     java.net.ConnectException: Connection refused (Connection refused)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I am setting dev profile in my bootstrap.properties in src/main/resources.

spring.profiles.active=dev

When I change this to

spring.profiles.active=dev, test

It's successfully generating openapi.json giving this warning [WARNING] The requested profile "test" could not be activated because it does not exist. with this command mvn clean install -Dgpg.skip -Dspring.profiles.active=test -P test. But I want the test profile should be considered from mvn command so I used -Dspring.profiles.active=test but still it's not considering my test profile until I explicitly put it in my bootstrap.

The full codebase can be found here as I didn't push to these things as it's having issues. Any help would be appreciated.

0 Answers
Related