Skip to content

Class loading fails on an interrupted thread causing com.mongodb.event.ServerClosedEvent to fail to load when Mongo detects a cluster change #38611

Closed

Description

@manjian14

We've encountered a connectivity problem after migrating from Spring Boot 3.1.5/3.1.6 to 3.2.0. The error log points to a missing class:

java.lang.ClassNotFoundException: com.mongodb.event.ServerClosedEvent

This is affecting our connection to MongoDB "AWS DocumentDB." Any guidance or resolution on this matter would be greatly appreciated.

Opera Snapshot_2023-11-30_121747_us-east-1 console aws amazon com
Opera Snapshot_2023-11-30_121933_us-east-1 console aws amazon com

Activity

  1. changed the title [-]Connectivity Issue with MongoDB "AWS DocumentDB" After Upgrading to Spring Boot 3.2.0 from 3.1.5 | 3.16[/-] [+]Connectivity Issue with MongoDB "AWS DocumentDB" After Upgrading to Spring Boot 3.2.0 from 3.1.5 | 3.1.6[/+] on Nov 30, 2023
  2. added
    status: waiting-for-triage
    on Nov 30, 2023
  3. mhalbritter commented on Nov 30, 2023

    @mhalbritter
    Contributor

    Hello!

    I can't see any code from Boot in the stacktrace, besides the JAR loader. I'm not sure if this has something to do with the Uber JAR rewrite. Can you please try with the classic loader implementation and report back if that fixes the issue?

    See here for details: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.2-Release-Notes#nested-jar-support

  4. added
    status: waiting-for-feedback
    on Nov 30, 2023
  5. manjian14 commented on Nov 30, 2023

    @manjian14
    Author

    The connectivity issue with MongoDB "AWS DocumentDB" appears resolved after implementing the classic loader in Spring Boot 3.2.0:

    bootJar {
        archiveFileName = "${rootProject.name}.${archiveExtension.get()}"
        loaderImplementation = LoaderImplementation.CLASSIC
    }
    

    Any additional insights or recommendations moving forward would be appreciated.

  6. added
    status: feedback-provided
    and removed
    status: waiting-for-feedback
    on Nov 30, 2023
  7. mhalbritter commented on Nov 30, 2023

    @mhalbritter
    Contributor
  8. wilkinsona commented on Dec 5, 2023

    @wilkinsona
    Member

    @manjian14 The stack trace would suggest that the problem occurs when there's a change in the topology of the cluster but I haven't been able to reproduce it. Can you please provide a minimal sample and the steps to follow to cause the failure?

  9. added
    status: waiting-for-feedback
    and removed
    status: feedback-provided
    on Dec 5, 2023
  10. manjian14 commented on Dec 5, 2023

    @manjian14
    Author

    I've configured my application to connect to an AWS DocDB cluster using the standard driver configuration. Below is a snippet from my MongoDbConfiguration class:

    @Slf4j
    @Configuration
    @EnableMongoRepositories(value = "com.????")
    @ConditionalOnProperty(prefix = "mongo.connection", value = "string")
    public class MongoDbConfiguration extends AbstractMongoClientConfiguration {
    
        @Value("${mongo.connection.string}")
        private String connectionString;
    
        @Override
        @Primary
        @Bean
        public @NonNull MongoClient mongoClient() {
            return MongoClients.create(connectionString);
        }
    
        @Override
        protected @NonNull String getDatabaseName() {
            return "???";
        }
    }
    

    In this setup, I've embedded the username and password within the cluster URL. The cluster has two replica sets, one for reading and one for writing. Additionally, the database is not accessible from outside; access is restricted either by whitelisted IP addresses or by project roles within the ECS cluster.

    The AWS DocDB version is 5.0.0, the latest version as per AWS recommendations. The project is using Gradle version 8.5 and Java version 17. The base image is amazoncorretto:17-al2023-headful, and during the image build process, I've imported the SSL certificate using the keytool tool.

    If you have any specific questions or if there's anything else you'd like to know, feel free to ask!

  11. added
    status: feedback-provided
    and removed
    status: waiting-for-feedback
    on Dec 5, 2023
  12. philwebb commented on Dec 5, 2023

    @philwebb
    Member

    @manjian14 Is there any chance you could switch back to the DEFAULT loader implementation and try 3.2.1-SNAPSHOT? We've fixed a few bugs with the nested loader. I'm doubtful that we've caught this one, but I'd like to check since it seems hard for us to replicate the problem locally.

  13. 29 remaining items

  14. modified the milestones: 3.2.x, 3.2.1 on Dec 7, 2023
  15. philwebb commented on Dec 7, 2023

    @philwebb
    Member

    We've just pushed a fix for this. It would be much appreciated if someone could try the latest 3.2.1 SNAPSHOT with the default loader to see if we've fixed the problem.

  16. msievers commented on Dec 7, 2023

    @msievers

    @philwebb I'll give it a try and report back.

  17. msievers commented on Dec 7, 2023

    @msievers

    @philwebb It's still failing with 3.2.1-SNAPSHOT. Was the last CI build completed successfully? It's orange, maybe the changes were not published/pushed, see

    https://ci.spring.io/teams/spring-boot/pipelines/spring-boot-3.2.x/jobs/build/builds/802

  18. philwebb commented on Dec 7, 2023

    @philwebb
    Member

    Gahh, those failures are a pain. It wasn't published but I also didn't get a notification. I've kicked it off again and I'll comment back here when it's done. Sorry about that.

  19. philwebb commented on Dec 8, 2023

    @philwebb
    Member

    Sorry @msievers, we're having some trouble with our CI right now and we haven't managed to publish jars yet.

  20. wilkinsona commented on Dec 9, 2023

    @wilkinsona
    Member

    @msievers Our CI's been fixed and a new snapshot 3.2.1-SNAPSHOT build has been published. Could you please give it a try if you have the time?

  21. msievers commented on Dec 11, 2023

    @msievers

    @philwebb @wilkinsona I can confirm that for my two use cases, one being our internal application and the other the application I created on GitHub to reproduce the error, the issue seems to have disappeared with the use of the current Spring Boot 3.2.1-SNAPSHOT version.

  22. wilkinsona commented on Dec 11, 2023

    @wilkinsona
    Member

    Thank you, @msievers. That's some greatly appreciated good news.

  23. added a commit that references this issue on Jan 25, 2024
    e697024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: regression

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions