【问题标题】:How to fix springboot error Failed to retrieve RMIServer stub: javax.naming.CommunicationException error during JRMP connection establishment如何修复springboot错误无法检索RMIServer存根:JRMP连接建立期间javax.naming.CommunicationException错误
【发布时间】:2021-04-26 05:01:39
【问题描述】:

我对@9​​87654321@ maven 项目和docker 中的cassandra 有疑问。 我想执行 mvn verify 并在 pre-integration-test 中启动 cassandra docker 和 api 服务器,执行测试然后在 post-integration-test 中停止服务器但我遇到错误 Could not contact Spring Boot application: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment;

我已经创建了github repo,所以你可以很容易地重现错误。

复制步骤

git clone https://github.com/gandra/docker-cassandra-with-initial-seed.git
cd docker-cassandra-with-initial-seed
mvn verify

这将产生如下错误:

[INFO]
[INFO] --- spring-boot-maven-plugin:2.2.2.RELEASE:start (api-server-start) @ docker-cassandra-with-initial-seed ---
[INFO] Attaching agents: []
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  18.501 s
[INFO] Finished at: 2021-01-21T18:39:05+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.2.RELEASE:start (api-server-start) on project docker-cassandra-with-initial-seed: Could not contact Spring Boot application: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
[ERROR]     java.io.EOFException]
[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/MojoFailureException

知道如何解决。

附言 我正在使用 mac,这个解决方案也适用于 mac 和 linux。

【问题讨论】:

    标签: docker maven spring-data-cassandra spring-boot-starter jrmp


    【解决方案1】:

    代码https://github.com/gandra/docker-cassandra-with-initial-seed 已修复,现在可以使用。

    基本上有两件事发生了变化:

    1. 从 docker-cassandra.sh 中删除了端口映射 9001。
    2. docker-cassandra.sh 的 cassandra_start 函数中添加了 sleep 20 秒,以便让 cassandra 有时间正确启动。不太好,但至少可以工作。

    现在以下代码应该可以与 1 个成功执行的集成测试一起使用:

    git clone https://github.com/gandra/docker-cassandra-with-initial-seed.git
    cd docker-cassandra-with-initial-seed
    mvn verify
    

    【讨论】:

      【解决方案2】:

      如果您使用的是 Windows,2020 年解决的一个问题有点难以找到(here Github 上的完整线程,如果您想阅读完整的故事)。
      回顾一下,解决方案是修复jmxPort。例如:

          <plugin>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-maven-plugin</artifactId>
              <configuration>
                <jmxPort>9011</jmxPort>
              </configuration>
          [...]
      

      【讨论】:

        【解决方案3】:

        这里的问题是他试图使用一个已经在使用的端口。 我在使用 spring boot(不是 cassandra)时遇到了类似的问题。

        我认为解决这个问题的两种方法:

        第一种方式:

        1. 找到正在使用该端口的程序(在我的例子中,它是端口 9001 上的“Intel(R) Graphics Command Center”)。 (可以在命令提示符下使用 netstat /a /b)或使用 tcpview(外部免费程序)
        2. 禁用程序
        3. 利润

        第二种方式

        在 spring-boot-maven-plugin 的 pom 中配置 jmx 端口 (来自 Sixro 的回答) 但是,我不喜欢这种方式,因为您基本上强制项目中的其他人使用您的解决方法,而问题出在您的机器上。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-11-24
          • 2020-12-29
          • 1970-01-01
          • 2022-01-13
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-08-28
          相关资源
          最近更新 更多