I’m working on a aws lambda using Quarkus.
I’m trying to load a custom class to configure my database connection in a custom way.
I wrote the following class, that works perfectly when I run locally (not native):
@PersistenceUnitExtension
@ApplicationScoped
@RegisterForReflection
public class OracleDatasourceConfig implements TenantConnectionResolver {
@ConfigProperty(name = "quarkus.datasource.jdbc.url")
String connectionStringProperty;
private final KeyVaultConfig keyVaultConfig;
public OracleDatasourceConfig(KeyVaultConfig keyVaultConfig) {
this.keyVaultConfig = keyVaultConfig;
}
@Override
public ConnectionProvider resolve(String tenantId) {
try {
// configurations and code...
return new QuarkusConnectionProvider(AgroalDataSource.from(new AgroalPropertiesReader()
.readProperties(properties)
.get()));
} catch (SQLException e) {
throw new IllegalStateException(e);
}
}
}
This class loads just fine locally, but when I deploy my code on aws lambda it builds as native and my class seems to not load at all.
I’m new to graalvm and native java code, so I’m struggling to understand how to make this work.
I imagine that the problem is some reflection that native have its own way to deal with but I can’t find any sources to help me out with this.
How to make sure this class will run on native?