springdoc / springdoc-openapi-maven-plugin

Library for OpenAPI 3 with spring-boot
https://springdoc.org
Apache License 2.0
141 stars 37 forks source link

Error while runnign mvn clean install -> Failed to connect to MBean server at port 9001 #18

Closed amalasj closed 3 years ago

amalasj commented 3 years ago

Getting below error while running mvn clean install, please help

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.0.RELEASE:start (pre-integration-test) on project abcd: Cou ld not figure out if the application has started: Failed to connect to MBean server at port 9001: Could not invoke shutdown operation: Spring application did not start before the configured timeout (30000ms -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.


Using below part in pom.xml

org.springdoc springdoc-openapi-ui 1.4.4
</dependencies>

<build>

    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>${maven.compiler.source}</source>
                <target>${maven.compiler.target}</target>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>${lombok.version}</version>
                    </path>
                    <path>
                        <groupId>org.mapstruct</groupId>
                        <artifactId>mapstruct-processor</artifactId>
                        <version>${mapstruct.version}</version>
                    </path>
                </annotationProcessorPaths>
            </configuration>

        </plugin>
        <plugin>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-maven-plugin</artifactId>
            <version>1.0</version>
            <executions>
                <execution>
                    <id>integration-test</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <apiDocsUrl>http://localhost:8080/v3/api-docs</apiDocsUrl>
                <outputFileName>openapi.json</outputFileName>
                <outputDir>${project.build.directory}</outputDir>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <mainClass>aaa.bbb.Abcd</mainClass>
            </configuration>
            <executions>
                <execution>
                    <id>pre-integration-test</id>
                    <goals>
                        <goal>start</goal>
                    </goals>
                </execution>
                <execution>
                    <id>post-integration-test</id>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <destFile>${sonar.jacoco.reportPath}</destFile>
            </configuration>
        </plugin>
    </plugins>
</build>

z0rb commented 3 years ago

I ran into a similar issue and increased the wait from 500ms to 1000ms. The application is just too fat and sometimes takes longer than 30s to fully start on my local machine:

                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <configuration>
                            <jvmArguments>-Dspring.application.admin.enabled=true</jvmArguments>
                            <addResources>true</addResources>
                        </configuration>
                        <executions>
                            <execution>
                                <id>pre-integration-test</id>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                                <configuration>
                                    <!-- Application may need longer than 60 * 500ms to start. Set to 60 * 1000ms. -->
                                    <wait>1000</wait>
                                </configuration>
                            </execution>
                            <execution>
                                <id>post-integration-test</id>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

Though I do have a problem that the server isn't shutting down properly and I have to kill the process somehow. But that might be a different issue.

bnasslahsen commented 3 years ago

@amalasj,

This is not reproducible. Make sure you use the last versions of springdoc-openapi and springdoc-openapi-maven-pluginbefore reporting any issues.

jcolladosp commented 2 years ago

I solved it adding to the pre-integration-test a configuration specifying the correct spring profile:

<configuration>
    <jvmArguments>-Dspring.application.admin.enabled=true -Dspring.profiles.active=qa</jvmArguments>
</configuration>
NathalieGprog commented 2 months ago

I solved it adding to the pre-integration-test a configuration specifying the correct spring profile:

<configuration>
  <jvmArguments>-Dspring.application.admin.enabled=true -Dspring.profiles.active=qa</jvmArguments>
</configuration>

Thanks. I solved my problem by removing my customed configuration.