spring-projects / spring-data-couchbase

Provides support to increase developer productivity in Java when using Couchbase. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-couchbase
Apache License 2.0
274 stars 190 forks source link

Compilation error due to QueryDSL annotation processor in Spring Data Couchbase 5.2.4 #1929

Closed ajschutte closed 5 months ago

ajschutte commented 5 months ago

We just upgraded to Spring Boot 3.2.4 and Spring Data Couchbase 5.2.4. We are getting the compilation error below. Adding that javax dependency is not an option since we migrated to jakarta. There also does not seem to be an obvious way to disable QueryDSL annotation processing, at least not with Maven. We are really not interested in using QueryDSL with Couchbase.

I temporarily got around the issue by doing this:

        <dependency>
            <groupId>com.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
            <version>${querydsl.version}</version>
            <classifier>jakarta</classifier>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-couchbase</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.querydsl</groupId>
                    <artifactId>querydsl-apt</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

Our previous version was 5.2.2, so something changed from 5.2.2 -> 5.2.4 that causes this.

The error is pretty easy to replicate with a minimal project (that does not include the legacy javax library).

Caused by: java.lang.NoClassDefFoundError: javax/inject/Inject
    at com.querydsl.codegen.AbstractModule.createInstance (AbstractModule.java:125)
    at com.querydsl.codegen.AbstractModule.get (AbstractModule.java:95)
    at com.querydsl.apt.DefaultConfiguration.getTypeMappings (DefaultConfiguration.java:480)
    at com.querydsl.apt.AbstractQuerydslProcessor.process (AbstractQuerydslProcessor.java:85)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor (JavacProcessingEnvironment.java:1023)
mikereiche commented 5 months ago

The error is pretty easy to replicate with a minimal project

Can you provide that please.

The dependency was removed because of https://github.com/spring-projects/spring-data-couchbase/issues/1917

mikereiche commented 5 months ago

Is the solution to add <classifier>jakarta</classifier> in the dependency for querydsl in spring-data-couchbase?

ajschutte commented 5 months ago

That should do it, provided the assumption is that all clients are on jakarta libs, which I think is what Spring Boot 3.x requires anyway,

On Thu, Apr 4, 2024 at 12:52 PM Michael Reiche @.***> wrote:

Is the solution to add jakarta in the dependency for querydsl in spring-data-couchbase?

— Reply to this email directly, view it on GitHub https://github.com/spring-projects/spring-data-couchbase/issues/1929#issuecomment-2037711790, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEUM7TTJQNQHSRM6DMAY4F3Y3WAMPAVCNFSM6AAAAABFVOQGTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZXG4YTCNZZGA . You are receiving this because you authored the thread.Message ID: @.***>

mikereiche commented 5 months ago

This is the fix to exclude javax.inject, but not have CouchbaseAnnotationProcessor fail when it is missing - instead just output a warning.