I am encountering a loader constraint violation error when trying to verify a JWS signature using a Java callout in an Apigee policy. The error message is as follows:
loader constraint violation: when resolving method “org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;” the class loader (instance of com/apigee/messaging/resource/JavaResourceClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for the method’s defining class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type org/slf4j/ILoggerFactory used in the signature
Environment:
Apigee
Causing code:
jsonWebSignature.verifySignature();
My build.gradle:
plugins {
id 'io.freefair.lombok' version '3.2.0'
}
dependencies {
compileOnly 'com.apigee.edge:message-flow:1.0.0'
compileOnly 'com.apigee.edge:expressions:1.0.0'
implementation 'org.bitbucket.b_c:jose4j:0.9.6'
testImplementation 'org.mockito:mockito-junit-jupiter:2.25.1'
testImplementation 'com.apigee.edge:message-flow:1.0.0'
testImplementation 'com.apigee.edge:expressions:1.0.0'
}
I believe the issue is related to SLF4J class loading conflicts between Apigee’s class loader and the Java application’s class loader. How can I resolve this loader constraint violation?
Additional Information:
The SLF4J library version I am not using explicitly but appears to be causing conflicts. May be library adding it internally.
I am using the jose4j library for JWS verification.
The build.gradle file provided shows my current dependencies and plugins.