Skip to content
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

java.lang.NoClassDefFoundError: javax/inject/Inject: javax.inject.Inject when upgrading to Spring Boot 3.2.4 #1926

Closed
cabbonizio opened this issue Mar 25, 2024 · 7 comments
Labels
status: feedback-provided Feedback has been provided

Comments

@cabbonizio
Copy link

cabbonizio commented Mar 25, 2024

Hi, we recently upgraded to Spring Boot 3.2.4 and are running into a compilation error with:

        java.lang.NoClassDefFoundError: javax/inject/Inject: javax.inject.Inject

It looks like it's stemming from Spring Data Couchbase so any of our projects using it is running into this error. I saw this issue:

#1917

And tried to follow what you did but still get the compilation error. Can someone please suggest what we can do until a permanent release is issued?

This is what we have in dependency management:

       <dependency>
		<groupId>com.querydsl</groupId>
		<artifactId>querydsl-apt</artifactId>
		<exclusions>
			<exclusion>
				<groupId>javax.inject</groupId>
				<artifactId>javax.inject</artifactId>
			</exclusion>
		</exclusions>
	</dependency>
	<dependency>
		<groupId>javax.inject</groupId>
		<artifactId>javax.inject</artifactId>
		<version>1</version>
		<scope>test</scope>
	</dependency>
            <dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-couchbase</artifactId>
	</dependency>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 25, 2024
@mikereiche
Copy link
Collaborator

Make sure you have the latest version of spring-data-couchbase which is 5.2.4.

You shouldn't need to have a dependency for com.querydls:querydsl-apt as the dependency is already in spring-data-couchbase (which you would get through spring-boot-starter-data-couchbase)

If your code references java.inject.Inject directly (and apparently it does, otherwise it wouldn't get a compilation error) - I think that should be coming from spring-boot-starter-data-couchbase (something in it other than spring-data-couchbase).

mvn dependency:tree can be used to see where the dependencies come from.

@mikereiche mikereiche added status: feedback-provided Feedback has been provided and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 27, 2024
@mikereiche
Copy link
Collaborator

Closing this issue - I haven't heard back. Please reopen if there is more information.

@hantsy
Copy link

hantsy commented Apr 8, 2024

I encountered the same issue when updating to Spring Boot 3.2.4,

The sample project is here.

https://github.com/hantsy/spring6-sandbox/blob/master/boot-data-couchbase

The dependency tree is here.

--- dependency:3.6.1:tree (default-cli) @ demo ---
[INFO] com.example:demo:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-data-couchbase:jar:3.2.4:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:3.2.4:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:3.2.4:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:3.2.4:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.4.14:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.4.14:compile
[INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.21.1:compile
[INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.21.1:compile
[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:2.0.12:compile
[INFO] |  |  +- jakarta.annotation:jakarta.annotation-api:jar:2.1.1:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:2.2:compile
[INFO] |  \- org.springframework.data:spring-data-couchbase:jar:5.2.4:compile
[INFO] |     +- com.querydsl:querydsl-apt:jar:5.0.0:compile
[INFO] |     |  \- com.querydsl:querydsl-codegen:jar:5.0.0:compile
[INFO] |     |     +- com.querydsl:querydsl-core:jar:5.0.0:compile
[INFO] |     |     |  \- com.mysema.commons:mysema-commons-lang:jar:0.2.4:compile
[INFO] |     |     +- com.querydsl:codegen-utils:jar:5.0.0:compile
[INFO] |     |     |  \- org.eclipse.jdt:ecj:jar:3.26.0:compile
[INFO] |     |     \- io.github.classgraph:classgraph:jar:4.8.108:compile
[INFO] |     +- org.springframework:spring-context-support:jar:6.1.5:compile
[INFO] |     +- org.springframework:spring-tx:jar:6.1.5:compile
[INFO] |     +- org.springframework.data:spring-data-commons:jar:3.2.4:compile
[INFO] |     +- com.couchbase.client:java-client:jar:3.4.11:compile
[INFO] |     |  \- com.couchbase.client:core-io:jar:2.4.11:compile
[INFO] |     +- com.fasterxml.jackson.core:jackson-databind:jar:2.15.4:compile
[INFO] |     |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.15.4:compile
[INFO] |     |  \- com.fasterxml.jackson.core:jackson-core:jar:2.15.4:compile
[INFO] |     \- org.slf4j:slf4j-api:jar:2.0.12:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:3.2.4:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:3.2.4:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.15.4:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.15.4:compile
[INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.15.4:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:3.2.4:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:10.1.19:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:10.1.19:compile
[INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:10.1.19:compile
[INFO] |  +- org.springframework:spring-web:jar:6.1.5:compile
[INFO] |  |  +- org.springframework:spring-beans:jar:6.1.5:compile
[INFO] |  |  \- io.micrometer:micrometer-observation:jar:1.12.4:compile
[INFO] |  |     \- io.micrometer:micrometer-commons:jar:1.12.4:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:6.1.5:compile
[INFO] |     +- org.springframework:spring-aop:jar:6.1.5:compile
[INFO] |     +- org.springframework:spring-context:jar:6.1.5:compile
[INFO] |     \- org.springframework:spring-expression:jar:6.1.5:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.32:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:3.2.4:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:3.2.4:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:3.2.4:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.9.0:test
[INFO] |  +- jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.2:test
[INFO] |  |  \- jakarta.activation:jakarta.activation-api:jar:2.1.3:test
[INFO] |  +- net.minidev:json-smart:jar:2.5.0:test
[INFO] |  |  \- net.minidev:accessors-smart:jar:2.5.0:test
[INFO] |  |     \- org.ow2.asm:asm:jar:9.3:test
[INFO] |  +- org.assertj:assertj-core:jar:3.24.2:test
[INFO] |  |  \- net.bytebuddy:byte-buddy:jar:1.14.12:test
[INFO] |  +- org.awaitility:awaitility:jar:4.2.0:test
[INFO] |  +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] |  +- org.junit.jupiter:junit-jupiter:jar:5.10.2:test
[INFO] |  |  +- org.junit.jupiter:junit-jupiter-api:jar:5.10.2:test
[INFO] |  |  |  +- org.opentest4j:opentest4j:jar:1.3.0:test
[INFO] |  |  |  +- org.junit.platform:junit-platform-commons:jar:1.10.2:test
[INFO] |  |  |  \- org.apiguardian:apiguardian-api:jar:1.1.2:test
[INFO] |  |  +- org.junit.jupiter:junit-jupiter-params:jar:5.10.2:test
[INFO] |  |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.10.2:test
[INFO] |  |     \- org.junit.platform:junit-platform-engine:jar:1.10.2:test
[INFO] |  +- org.mockito:mockito-core:jar:5.7.0:test
[INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.14.12:test
[INFO] |  |  \- org.objenesis:objenesis:jar:3.3:test
[INFO] |  +- org.mockito:mockito-junit-jupiter:jar:5.7.0:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.1:test
[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] |  +- org.springframework:spring-core:jar:6.1.5:compile
[INFO] |  |  \- org.springframework:spring-jcl:jar:6.1.5:compile
[INFO] |  +- org.springframework:spring-test:jar:6.1.5:test
[INFO] |  \- org.xmlunit:xmlunit-core:jar:2.9.1:test
[INFO] +- org.springframework.boot:spring-boot-testcontainers:jar:3.2.4:test
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:3.2.4:compile
[INFO] |  \- org.testcontainers:testcontainers:jar:1.19.7:test
[INFO] |     +- junit:junit:jar:4.13.2:test
[INFO] |     |  \- org.hamcrest:hamcrest-core:jar:2.2:test
[INFO] |     +- org.apache.commons:commons-compress:jar:1.24.0:test
[INFO] |     +- org.rnorth.duct-tape:duct-tape:jar:1.0.8:test
[INFO] |     |  \- org.jetbrains:annotations:jar:17.0.0:test
[INFO] |     +- com.github.docker-java:docker-java-api:jar:3.3.6:test
[INFO] |     \- com.github.docker-java:docker-java-transport-zerodep:jar:3.3.6:test
[INFO] |        +- com.github.docker-java:docker-java-transport:jar:3.3.6:test
[INFO] |        \- net.java.dev.jna:jna:jar:5.13.0:test
[INFO] +- io.projectreactor:reactor-test:jar:3.6.4:test
[INFO] |  \- io.projectreactor:reactor-core:jar:3.6.4:compile
[INFO] |     \- org.reactivestreams:reactive-streams:jar:1.0.4:compile
[INFO] +- org.testcontainers:junit-jupiter:jar:1.19.7:test
[INFO] \- org.testcontainers:couchbase:jar:1.19.7:test
[INFO] ------------------------------------------------------------------------

The problem is caused the querydsl that is a dependency of the latest spring data couchbase.

@hantsy
Copy link

hantsy commented Apr 8, 2024

Excluding com.querydsl:querydsl-apt from spring data couchbase starter can not resolve the issue.

New exception like this when exclude com.querydsl:querydsl-apt at compile time.

 Error:  COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
Error:  Bad service configuration file, or exception thrown while constructing Processor object: com/querydsl/apt/AbstractQuerydslProcessor

It seems spring data couchbase depends on the QueryDSL APT.

@hantsy
Copy link

hantsy commented Apr 8, 2024

@mikereiche Please reopen this issue, it cause the spring data couchbase not work at all.

@mikereiche
Copy link
Collaborator

mikereiche commented Apr 8, 2024

@hantsy - this is being addressed in #1929 .

btw - don't exclude querydsl.

@mikereiche
Copy link
Collaborator

This is now fixed. It will be available in the May release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided
Projects
None yet
Development

No branches or pull requests

4 participants