Closed Abhi-Codes closed 1 year ago
I resolved this by adding the hints for Serialization.
@SpringBootApplication
@ImportRuntimeHints(LdapServiceApplication.MyRuntimeHints.class)
public class LdapServiceApplication {
static class MyRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
// Register serialization
hints.serialization().registerType(HashMap.class).registerType(LinkedList.class);
}
}
}
Hi guys, could you please help me.
I have a method
@Cacheable(value = USER_IDENTITIES_PROTO_CACHE) public UserIdentitiesResponseOuterClass.UserIdentitiesResponse findUserIdentitiesProto(UUID userId) { where UserIdentitiesResponseOuterClass.UserIdentitiesResponse is a class generated by protobuff.
When using JVM everything works well but in the native image I am getting the exception
"Failure putting into cache: user_identities_proto. Cannot serialize"
I have tried to add
hints.serialization() .registerType(TypeReference.of(UserIdentitiesResponseOuterClass.class)) .registerType(UserIdentitiesResponseOuterClass.UserIdentity.class) .registerType(UserIdentitiesResponseOuterClass.UserIdentitiesResponse.class); but it did not help.
I am using Redis as a cache and using JdkSerializationRedisSerializer to serialize.
Content of proto file below:
syntax = "proto3";
package identity;
message UserIdentity { string provider = 1; string sub = 2; }
message UserIdentitiesResponse { UserIdentity primary = 1; repeated UserIdentity identities = 2; } if an application is run in JVM mode (not native) protobuff object is successfully serialized/deserialized. But in native image the mentioned problem happens.
I am assuming the solution would be to add the runtime hints.serialization(), but as I mentioned I did it and it did not help, so something is still missing, but it's not clear what exactly
How to fix it?
Up any news here ? I've still got the issues in SB 3.30 without LinkedHashMap hint it does not work !
Describe the bug
This only happens in the native version. In uber jar way, no issue. Spring Boot 3.0.1 openjdk version "17.0.5" 2022-10-18 OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08) OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08, mixed mode, sharing)
Stack trace:
Service class where @cacheable annotation is used :
RedisConfig