-
Notifications
You must be signed in to change notification settings - Fork 191
java.lang.NoClassDefFoundError: javax/inject/Inject: javax.inject.Inject when upgrading to Spring Boot 3.3.1 #1948
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
Comments
Yes. I see the issue. Add this to your dependencies :
|
Thank you. |
Hello, is there any plan to fix this issue? |
@mikereiche could you please consider reverting this change? It breaks Spring Boot's build as It's also unusual that |
Looking... |
Any ideas how to avoid the issue in the original post?
|
Reverted. |
@raman-khrapavitski what version of Spring Boot were you using prior to the upgrade? I'd like to understand exactly what changed to cause the problem. @mikereiche Fundamentally, the problem is that QueryDSL, despite using the I'm not sure how likely any changes to QueryDSL are at this point so we may need to figure out a compromise that works with its current state. Something else to consider here are the forthcoming changes to annotation processing. Java 21 emits a note warning about a future change in behavior. That note is:
This means that those using Java 21 and later are likely going to want to configure annotation processors and "normal" compile dependencies separately. For Gradle users, that would mean using the |
@wilkinsona - Andy I've gone around (unsuccessfully) a few times with this starting at with #1917, #1926, #1929, #1948, #1987 So far the best I've come up with where the customer needs to add javax.inject dependency to their project if they want to use querydsl-codegen. Going back to the beginning - why is javax.inject not allowed by spring-boot? I understand that spring-boot now uses jakarta, but that shouldn't rule out something else using javax.inject. Is there are security issue? |
This seems to be what is causing the user issues. Even though they don't have any annotated classes, its still calling the annotation processor because it found it on the classpath. I thought I handled this by emitting a warning from the annotation processor and exiting nicely. Caused by: java.lang.ClassNotFoundException: javax.inject.Inject |
In the sample repo provided by the user - the issue can be avoided by skipping the annotation processing
|
There's no security issue but we don't want it to be on the classpath by default. The intent here is to avoid causing confusion where a user tries to use |
To prevent a user from using @javax.inject.Inject (or Name etc) instead of the jakarta.inject.Inject etc? What about com.mycompany.Inject? Are we going to prohibit using any class name that is already used?
I got my hands slapped last time I tried that - #1514 |
The concern is specifically with
I think @mp911de's concern there was that the changes introduced a dependency cycle between the Spring Data Couchbase repository and the Spring Boot repository. I share Mark's concern as we want to avoid cycles between repository. Separating an annotation processing module out of the current, single core module would not introduce a dependency cycle. It wouldn't change any of the current dependencies, just restructure things so that some of them are isolated in a separate module that's specific to annotation processing. Of course, Mark may have other grounds for objection here, and any change should be discussed with him, but I would expect any objection to be different to the one raised with #1514. |
I left a comment on #1990. MongoDB ships with an annotation processor that doesn't cause that sort of trouble. See #1990 (comment) for how MongoDB defines its annotation processor and I highly suggest following that path instead of tearing the Spring Data Couchbase module apart just a few days before the RC1 release. |
Fixed in 5.4.0-RC1, 5.3.5, 5.2.11 |
Hi, our team upgraded to Spring Boot 3.3.1 and are running into a compilation error with:
java.lang.NoClassDefFoundError: javax/inject/Inject: javax.inject.Inject
Here is sample of project where issue can be reproduced - link
Looks like this problem similar to this closed issue: #1926
The text was updated successfully, but these errors were encountered: