Skip to content

ApplicationModules.of(…) throws NoClassDefFoundError when using the jMolecules Kotlin library #801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
breun opened this issue Sep 6, 2024 · 3 comments
Assignees
Labels
in: core Core module meta model type: bug Something isn't working
Milestone

Comments

@breun
Copy link

breun commented Sep 6, 2024

I'm trying out Spring Modulith 1.2.3 with a Spring Boot 3.3.3 project that is written in Kotlin. On the Verifying Application Module Structure page I read about jMolecules, and I found that jmolecules-ddd has a Kotlin counterpart called kmolecules-ddd.

However, after adding org.jmolecules:kmolecules-ddd to my project, I got java.lang.NoClassDefFoundError: org/jmolecules/ddd/annotation/Module when calling org.springframework.modulith.core.ApplicationModuleInformation#of for Spring Modulith application module verification and documentation generation.

This seems to happen because JMoleculesTypes.isPresent() returns true, because org.jmolecules.ddd.annotation.Entity is present (provided by kmolecules-ddd), but JMoleculesModule.supports(lookup) then tries to look up org.jmolecules.ddd.annotation.Module, which is not provided by kmolecules-ddd (although it is indeed provided by jmolecules-ddd).

@breun
Copy link
Author

breun commented Sep 6, 2024

@BoundedContext and @Module were added to jmolecules-ddd via xmolecules/jmolecules#20, but weren't added to kmolecules-ddd. I've created xmolecules/jmolecules#126 for this.

@breun
Copy link
Author

breun commented Sep 6, 2024

I'm now thinking that these annotations are probably missing from kmolecules-ddd, because these are package-level annotations and Kotlin doesn't provide a way to define package-level annotations.

Maybe it's then best to let Spring Modulith not fail when org.jmolecules.ddd.annotation.Module is not present?

@odrotbohm odrotbohm changed the title ApplicationModules.of throws NoClassDefFoundError for org.jmolecules.ddd.annotation.Module when using kmolecules-ddd ApplicationModules.of(…) throws NoClassDefFoundError` when using the jMolecules Kotlin library Sep 6, 2024
@odrotbohm odrotbohm changed the title ApplicationModules.of(…) throws NoClassDefFoundError` when using the jMolecules Kotlin library ApplicationModules.of(…) throws NoClassDefFoundError when using the jMolecules Kotlin library Sep 6, 2024
@odrotbohm odrotbohm self-assigned this Sep 6, 2024
@odrotbohm odrotbohm added in: core Core module meta model type: bug Something isn't working labels Sep 6, 2024
@odrotbohm odrotbohm added this to the 1.3 M3 milestone Sep 6, 2024
odrotbohm added a commit that referenced this issue Sep 12, 2024
As @module is absent from the Kotlin flavor of jMolecules, code that refers to that is now guarded with a more specific check for that type in particular.
@odrotbohm
Copy link
Member

An improve guard should be in place. Feel free to give the snapshots a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Core module meta model type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants