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: ProtoSchema - v5.0.1.Final #267

Open
markosalazar opened this issue Apr 18, 2024 · 23 comments
Open

java.lang.NoClassDefFoundError: ProtoSchema - v5.0.1.Final #267

markosalazar opened this issue Apr 18, 2024 · 23 comments

Comments

@markosalazar
Copy link

markosalazar commented Apr 18, 2024

Using the new 5.0.1.Final dependency creates the following error:
Execution failed for task ':compileJava'.

java.lang.NoClassDefFoundError: org/infinispan/protostream/annotations/ProtoSchema

This happens as soon as the annotation processor is added to the project. This also happens with all the other v5 versions. Any feedback on this ? Thank you

@tristantarrant
Copy link
Member

can you paste the output of mvn dependency:tree here ?

@markosalazar
Copy link
Author

I am using gradle. It works fine with version 4, but in version 5 I cannot get past this error.

@tristantarrant
Copy link
Member

can you get the actual javac command being executed ?

@markosalazar
Copy link
Author

My gradle dependencies:
+--- org.infinispan.protostream:protostream-processor:5.0.3.Final
| +--- org.jboss.logging:jboss-logging:3.5.3.Final
| --- org.infinispan.protostream:protostream:5.0.3.Final
| +--- org.jboss.logging:jboss-logging:3.5.3.Final
| --- com.fasterxml.jackson.core:jackson-core:2.16.2 -> 2.15.4
| --- com.fasterxml.jackson:jackson-bom:2.15.4
| +--- com.fasterxml.jackson.core:jackson-annotations:2.15.4 (c)
| +--- com.fasterxml.jackson.core:jackson-core:2.15.4 (c)
| +--- com.fasterxml.jackson.core:jackson-databind:2.15.4 (c)
| +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.15.4 (c)
| +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.4 (c)
| --- com.fasterxml.jackson.module:jackson-module-parameter-names:2.15.4 (c)
+--- org.projectlombok:lombok -> 1.18.30
+--- org.springframework.boot:spring-boot-starter-web -> 3.2.4
| +--- org.springframework.boot:spring-boot-starter:3.2.4
| | +--- org.springframework.boot:spring-boot:3.2.4
| | | +--- org.springframework:spring-core:6.1.5
| | | | --- org.springframework:spring-jcl:6.1.5
| | | --- org.springframework:spring-context:6.1.5
| | | +--- org.springframework:spring-aop:6.1.5
| | | | +--- org.springframework:spring-beans:6.1.5
| | | | | --- org.springframework:spring-core:6.1.5 ()
| | | | --- org.springframework:spring-core:6.1.5 (
)
| | | +--- org.springframework:spring-beans:6.1.5 ()
| | | +--- org.springframework:spring-core:6.1.5 (
)
| | | +--- org.springframework:spring-expression:6.1.5
| | | | --- org.springframework:spring-core:6.1.5 ()
| | | --- io.micrometer:micrometer-observation:1.12.4
| | | --- io.micrometer:micrometer-commons:1.12.4
| | +--- org.springframework.boot:spring-boot-autoconfigure:3.2.4
| | | --- org.springframework.boot:spring-boot:3.2.4 (
)
| | +--- jakarta.annotation:jakarta.annotation-api:2.1.1
| | +--- org.springframework:spring-core:6.1.5 ()
| | --- org.yaml:snakeyaml:2.2
| +--- org.springframework.boot:spring-boot-starter-json:3.2.4
| | +--- org.springframework.boot:spring-boot-starter:3.2.4 (
)
| | +--- org.springframework:spring-web:6.1.5
| | | +--- org.springframework:spring-beans:6.1.5 ()
| | | +--- org.springframework:spring-core:6.1.5 (
)
| | | --- io.micrometer:micrometer-observation:1.12.4 ()
| | +--- com.fasterxml.jackson.core:jackson-databind:2.15.4
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.15.4
| | | | --- com.fasterxml.jackson:jackson-bom:2.15.4 (
)
| | | +--- com.fasterxml.jackson.core:jackson-core:2.15.4 ()
| | | --- com.fasterxml.jackson:jackson-bom:2.15.4 (
)
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.15.4
| | | +--- com.fasterxml.jackson.core:jackson-core:2.15.4 ()
| | | +--- com.fasterxml.jackson.core:jackson-databind:2.15.4 (
)
| | | --- com.fasterxml.jackson:jackson-bom:2.15.4 ()
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.4
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.15.4 (
)
| | | +--- com.fasterxml.jackson.core:jackson-core:2.15.4 ()
| | | +--- com.fasterxml.jackson.core:jackson-databind:2.15.4 (
)
| | | --- com.fasterxml.jackson:jackson-bom:2.15.4 ()
| | --- com.fasterxml.jackson.module:jackson-module-parameter-names:2.15.4
| | +--- com.fasterxml.jackson.core:jackson-core:2.15.4 (
)
| | +--- com.fasterxml.jackson.core:jackson-databind:2.15.4 ()
| | --- com.fasterxml.jackson:jackson-bom:2.15.4 (
)
| +--- org.springframework.boot:spring-boot-starter-tomcat:3.2.4
| | +--- jakarta.annotation:jakarta.annotation-api:2.1.1
| | +--- org.apache.tomcat.embed:tomcat-embed-core:10.1.19
| | +--- org.apache.tomcat.embed:tomcat-embed-el:10.1.19
| | --- org.apache.tomcat.embed:tomcat-embed-websocket:10.1.19
| | --- org.apache.tomcat.embed:tomcat-embed-core:10.1.19
| +--- org.springframework:spring-web:6.1.5 ()
| --- org.springframework:spring-webmvc:6.1.5
| +--- org.springframework:spring-aop:6.1.5 (
)
| +--- org.springframework:spring-beans:6.1.5 ()
| +--- org.springframework:spring-context:6.1.5 (
)
| +--- org.springframework:spring-core:6.1.5 ()
| +--- org.springframework:spring-expression:6.1.5 (
)
| --- org.springframework:spring-web:6.1.5 ()
+--- org.springframework.boot:spring-boot-starter-log4j2 -> 3.2.4
| +--- org.apache.logging.log4j:log4j-slf4j2-impl:2.21.1
| | +--- org.apache.logging.log4j:log4j-api:2.21.1
| | --- org.slf4j:slf4j-api:2.0.6 -> 2.0.12
| +--- org.apache.logging.log4j:log4j-core:2.21.1
| | --- org.apache.logging.log4j:log4j-api:2.21.1
| --- org.apache.logging.log4j:log4j-jul:2.21.1
| --- org.apache.logging.log4j:log4j-api:2.21.1
--- org.infinispan.protostream:protostream:5.0.3.Final (
)

@markosalazar
Copy link
Author

Sorry Tristin, I am using gradle build not sure which specific javac command is being executed. Trying to check

@markosalazar
Copy link
Author

Have also added this compiler arg from your doc:
tasks.withType(JavaCompile) {
configure(options) {
options.compilerArgs << '-Aprotostream-debug=true'
}
}
and this fails with key in annotation processor option '-Aprotostream-debug=true' is not a dot-separated sequence of identifiers

@tristantarrant
Copy link
Member

org/infinispan/protostream/annotations/ProtoSchema is in org.infinispan.protostream:protostream
org.infinispan.protostream:protostream-processor depends on that library.
I'm asking about the command-line, because it depends on whether it is using --processor-path or the classpath and which -proc options are being set. Also, which JDK are you using ?

@markosalazar
Copy link
Author

I am using JDK 17

@markosalazar
Copy link
Author

Thanks for the feedback, the documentation only mentions one dependency which is the annotation processor dependency. I have tried adding the other protostream dependencies before and it didn't resolve the issue. Which other library is required for this ProtoSchema class?

@tristantarrant
Copy link
Member

Well, I'm surprised it worked for you with 4 and not 5, because the layout of the jars has not changed

@tristantarrant
Copy link
Member

as for the failure related to the annotation processor option, that's a bug. I'll fix it

@markosalazar
Copy link
Author

Yes I am not understanding what the issue is either, with 4 its working great. Was hoping to switch to 5 for the proto3 support. Thanks for all the help. Will keep track to see if that bug is fixed.

@tristantarrant
Copy link
Member

I'll try to set up a simple gradle build to see what's happening

@markosalazar
Copy link
Author

Sure that sounds good, let me know if you require any info from my end

@tristantarrant
Copy link
Member

Btw, the debug option is -Aprotostream.debug=true (dot instead of dash)

@markosalazar
Copy link
Author

markosalazar commented Apr 18, 2024

Thanks, that worked. Error is the same however:

java.lang.NoClassDefFoundError: org/infinispan/protostream/annotations/ProtoSchema

Iv included the following dependency as well but no luck yet:
implementation 'org.infinispan.protostream:protostream:5.0.1.Final'

@markosalazar
Copy link
Author

Not sure if this is helpful but version 5.0.0.Dev01 works, although it generates a schema using proto2 syntax

@tristantarrant
Copy link
Member

This worked for me: https://github.com/tristantarrant/protostream-gradle

@markosalazar
Copy link
Author

So, I downloaded your project and was able to run it, however the spring boot application I have is still throwing the same error. I have cross referenced both projects and see no real differences. Let me verify further and share what I find.

Also is the syntax supposed to still be proto2?

@tristantarrant
Copy link
Member

For backwards compatibility. Use the following:

@ProtoSchema(schemaFileName = "simple.proto", includeClasses = Simple.class, syntax = ProtoSyntax.PROTO3)

@markosalazar
Copy link
Author

Thanks a lot for all the feedback and the example project. It is very helpful. However, with the spring boot application, it is still throwing the same error. I have uploaded the project here. Can take a look if you ever get a chance and recreate the issue:
https://github.com/markosalazar/protostream-api-test-app

@markosalazar
Copy link
Author

Hey Tristan, believe this issue is related to some type of conflict with Spring Boot/ maybe due to conflicting Jackson versions? Tried it on another application and its working as expected. Thanks again for all your prompt feedback

@tristantarrant
Copy link
Member

I modified my project to add implementation 'org.springframework.boot:spring-boot-starter-web:3.2.4' but everything works. The only weird thing I see in your dependency tree is the downgrading of jackson: com.fasterxml.jackson.core:jackson-core:2.16.2 -> 2.15.4

Is there any more information from that exception java.lang.NoClassDefFoundError: org/infinispan/protostream/annotations/ProtoSchema, such as the full stack trace with any additional causes ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants