Open omarkad2 opened 3 years ago
@omarkad2 I was able to make it work for an inner class using the following format
{
"name": "com.stripe.model.Class$InvoiceSettings",
"allDeclaredFields": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredConstructors": true,
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
}
So use a $
between the top level class and the inner class instead of a .
and things will work.
How do you fix
java.lang.RuntimeException: Unable to create instance of class com.stripe.model.Customer. Registering an InstanceCreator or a TypeAdapter for this type, or adding a no-args constructor may fix this problem.
Given there are no - no-args constructor defined in stripe models.
How do you fix
java.lang.RuntimeException: Unable to create instance of class com.stripe.model.Customer. Registering an InstanceCreator or a TypeAdapter for this type, or adding a no-args constructor may fix this problem.
Given there are no - no-args constructor defined in stripe models.
@prashant-gupta-kune I fixed a similar issue in Spring Boot by creating a @Configuration
class with @RegisterReflectionForBinding
annotation.
import com.stripe.model.StripeError;
import org.springframework.aot.hint.annotation.RegisterReflectionForBinding;
import org.springframework.context.annotation.Configuration;
@Configuration
/*
* RegisterReflectionForBinding fixes error "Unable to create instance of class
* com.stripe.model.StripeError." and something about unsafeCall
*/
@RegisterReflectionForBinding(StripeError.class)
public class PaymentConfig {}
So if you check what @RegisterReflectionForBinding
does, you might be able to fix it outside of Spring Boot app.
I'm using quarkus on an application that uses Stripe library. So in order to declare all reflective classes used by Stripe I tried this solution. Yet when testing I get errors in my native image for each Stripe's inner class I try to deserialize.