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

IllegalAccessError with springwolf-core 0.10.0 and kafka batch listener #132

Closed
timonback opened this issue Jan 19, 2023 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@timonback
Copy link
Member

Describe the bug
Unable to start springwolf-core 0.10.0 with Kafka BatchListener

Dependencies and versions used
springwolf-core 0.10.0

Code example

    public fun consumeFuturePriceTags(
        @Payload nullableCloudEvents: List<CloudEvent?>
    ) {

Stack trace and error logs

Caused by: java.lang.IllegalAccessError: class io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.SpringPayloadAnnotationTypeExtractor (in unnamed module @0x54bff557) cannot access class sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl (in module java.base) because module java.base does not export sun.reflect.generics.reflectiveObjects to unnamed module @0x54bff557
	at io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.SpringPayloadAnnotationTypeExtractor.getPayloadParameterClass(SpringPayloadAnnotationTypeExtractor.java:34)

Possible solution in SpringPayloadAnnotationTypeExtractor:

        try {
            // Resolve generic type for batch listeners
            if (parameterClass == List.class) {
                Type type = ((ParameterizedTypeImpl) method.getGenericParameterTypes()[parameterPayloadIndex]).getActualTypeArguments()[0];
                return Class.forName(type.getTypeName());
            }
        } catch (Exception ex) { // Throwable here?
            log.info("Found payload type List<?>, but was unable to extract generic data type", ex);
        }

IllegalAccessError is not part of the caught Exception. Change catch block to Throwable?

Root cause:
((ParameterizedTypeImpl) method.getGenericParameterTypes()[parameterPayloadIndex]).getActualTypeArguments()[0].getTypeName() -> ? extends io.cloudevents.CloudEvent, which is not an actual class

@timonback timonback added the bug Something isn't working label Jan 19, 2023
@timonback
Copy link
Member Author

@sam0r040 and I investigated and came to the conclusion that different java version are used. java8 in springwolf and java17 in the bug description.

The IllegalAccessError indicated an issue with the introduced java modules.
Add this to your java17 JVM args: --add-opens=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED"

Related info: graphql-java-kickstart/graphql-java-tools#265

timonback referenced this issue in timonback/springwolf-core Jan 20, 2023
Add log message to indicate mismatch java versions

Co-Authored-By: 93372330+sam0r040@users.noreply.github.com
sam0r040 referenced this issue in timonback/springwolf-core Jan 20, 2023
Add log message to indicate mismatch java versions

Co-Authored-By: 93372330+sam0r040@users.noreply.github.com
stavshamir pushed a commit that referenced this issue Jan 20, 2023
Add log message to indicate mismatch java versions

Co-Authored-By: 93372330+sam0r040@users.noreply.github.com
stavshamir pushed a commit that referenced this issue Jan 22, 2023
Add log message to indicate mismatch java versions

Co-Authored-By: 93372330+sam0r040@users.noreply.github.com

(cherry picked from commit ee8da96)
@timonback
Copy link
Member Author

Resolved with springwolf-kafka:0.10.3

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

No branches or pull requests

1 participant