“module java.base does not “opens java.nio.charset” to unnamed module” in new Spring resource

So, I am building out architecture for user functionality in a new app, written in Java 17 and Spring Boot 3.2.5. I’m consistently getting error logs containing the message above.

Here is the domain object I’m using, less getters and setters:

public class User extends RepresentationModel<User> {

    private final String email;
    private final String password;
    private final String firstName;
    private final String lastName;

    @JsonCreator
    public User(@JsonProperty("email") String email, @JsonProperty("password") String password, @JsonProperty("firstName") String firstName, @JsonProperty("lastName") String lastName) {
        this.email = email;
        this.password = password;
        this.firstName = firstName;
        this.lastName = lastName;
    }
}

I’m using Mongo for my persistence layer, and using a bean to assemble a MongoTemplate from the required, overridden methods in the extended, abstract Mongo configuration interface:

@Configuration
public class MongoGeneral extends AbstractMongoClientConfiguration {

    @Value("${spring.data.mongodb.username}")
    private String username;

    @Value("${spring.data.mongodb.password}")
    private String password;

    @Override
    @NonNull
    protected String getDatabaseName() {
        return "flawless-beans";
    }

    @Override
    @NonNull
    public MongoClient mongoClient() {
        ConnectionString connectionString = new ConnectionString("mongodb+srv://" + username + ":" + password + "@cluster0.2ahn6zq.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0");
        System.out.println(username+", "+password);
        MongoClientSettings mongoClientSettings = MongoClientSettings.builder()
                .applyConnectionString(connectionString)
                .build();
        return MongoClients.create(mongoClientSettings);
    }

    @Bean(name = "mongoTemplate")
    MongoTemplate mongoTemplate() {
        return new MongoTemplate(new SimpleMongoClientDatabaseFactory(mongoClient(), getDatabaseName()));
    }

}

Just to do a conceptual task, I’m using the main class to do a pull for all the objects; I’ll remove it when I’m ready to abstract things out:

    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(MongoGeneral.class);
        MongoTemplate mongoTemplate = context.getBean("mongoTemplate", MongoTemplate.class);
        mongoTemplate.findAll(User.class);
        SpringApplication.run(FlawlessBeansJavaSpringApiApplication.class, args);
    }

Problem is, I keep getting these errors, and neither Google nor experimentation have helped:

Exception in thread "main" java.lang.reflect.InaccessibleObjectException: Unable to make protected java.nio.charset.Charset(java.lang.String,java.lang.String[]) accessible: module java.base does not "opens java.nio.charset" to unnamed module @55141def
    at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367)

There are many more lines after that, but none under new headings; this seems to be an error with many causes, so research hasn’t born fruit. However, these are the last three lines:

    at org.springframework.data.mongodb.core.MongoTemplate.getCollectionName(MongoTemplate.java:505)
    at org.springframework.data.mongodb.core.MongoTemplate.findAll(MongoTemplate.java:1852)
    at com.mistermorse.flawlessbeansjavaspringapi.FlawlessBeansJavaSpringApiApplication.main(FlawlessBeansJavaSpringApiApplication.java:17)

This last log is the line executing mongoTemplate.findAll(User.class); I’m not surprisedby this, because the app starts fine when that line is commented out, and only breaks on re-addition.

I can start the app without console errors even when I purposely break the config password, so I expect connection errors, but this seems local (and these errors, if Google results are to be considered, occur in lots of places).

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật