#mihaild_unexpected
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1219562313791701022
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Can you share the backtrace log?
I don't see any Stripe classes in the backtrace, so I don't see a direct connection between this error and Stripe Java SDK.
Yes you are right but this exception is happening because Invoice.list() is returning null, only when executed from an builded native image
This is code for getInvoices() nothing special that may cause this issue
final String startingAfter,
final String endingBefore,
final Long limit) {
log.infof("Request invoices from stripe for customer = {} with limit = {}, startingBefore = {}, endingBefore = {}",
customer, limit, startingAfter, endingBefore);
final InvoiceListParams params = InvoiceListParams.builder()
.setLimit(limit)
.setCustomer(customer)
.setStartingAfter(startingAfter)
.setEndingBefore(endingBefore)
.build();
try {
return Invoice.list(params);
} catch (StripeException e) {
throw new WebApplicationException("Error when requesting data from Stripe for customer = %s".formatted(customer), e);
}
}```
Which line is line 63?
Is failing on controller layer on line 63 that is operating on aboves getInvoice(...) results
basicaly on invoices.getData()
Is this stripeInvoiceService of type com.stripe.service.InvoiceService ?
stripeInvoiceService on line 61 is basically a wrapper around one that you mentioned
hi! hmm I have no idea what Quarkus or native images are. I'd suggest just opening an issue on the stripe-java Github if you have an account and are comfortable with that! Otherwise we'll file a ticket internally.
Yes sure will do it , will past it here when done
Describe the bug I am using stripe-java v24.10.0 in an quarkus based project , I created an controller that is expected to return a list of Invoice related information for a specific customer, loca...
@cerulean sphinx Stripe Java SDK don't provide support for Quarkus/Gralvm yet, they need to make native image build config files by yourself following this guide: https://www.graalvm.org/latest/reference-manual/native-image/overview/BuildConfiguration/
You can find couple of samples in the community; For example:
https://github.com/romixch/stripe-java-graalvm
I already did this changes
before I faced
java.lang.RuntimeException: Unable to invoke no-args constructor for class com.stripe.model.Event. Registering an InstanceCreator with Gson for this type may fix this problem.
After creating serialization-config.json as is stated in stripe-java-graalvm NPE starts to happen
Did you try to use the configu files from the repository I shared with you ?
You are facing the same issue...
no
Did you try to run this sample ?
https://github.com/romixch/stripe-java-graalvm
I followed steps described there
"Copy the whole directory native-image in META-INF to your own META-INF directory."
This solved
java.lang.RuntimeException: Unable to invoke no-args constructor for class com.stripe.model.Event. Registering an InstanceCreator with Gson for this type may fix this problem.
But instead Stripe Invoice.list() is returning alwys null
?
yes
And what is the issue you were facing ?
NPE for stripe calls results for example Invoice.lis()
please
I replaced company name with x for obvious reasons, is an multi module project so I am sharing base pom and one for rest taht is containing controller that are failling
And what do you have in your META-INF ?
thanks, checking...
I'm still doing some tests sorry for my late reply @cerulean sphinx
as you may know, building the native image takes some time...
yes sure, np I totaly understand
So far, I'm getting missing registred attribute but no NPE.... e.g.
java.lang.IllegalArgumentException: Type com.stripe.model.Price$Recurring is instantiated reflectively but was never registered. Register the type by adding "unsafeAllocated" for the type in reflect-config.json.
Ok for this one I thin you should use reflect-conf.json from here https://github.com/romixch/stripe-java-graalvm/pull/2/files
can you check please ?
Yes I'm updating the attributes one by one...
Your file is missing too
I'll share the final one by the end...
For example you don't have InvoiceLineItem$ProrationDetails
But no NPE so far, every think working perfectly
I'm testing this Jakarta API for example with customer:
@GetMapping("/stripe")
public ResponseEntity<Map<String, String>> hello() {
CustomerCreateParams params =
CustomerCreateParams
.builder()
.setDescription("Example description")
.setEmail("test@example.com")
.setPaymentMethod("pm_card_visa") // obtained via Stripe.js
.build();
try {
Customer customer = client.customers().create(params);
System.out.println(customer);
Map<String, String> response = new HashMap<>();
response.put("customerId", customer.getId());
return ResponseEntity.ofNullable(response);
} catch (StripeException e) {
e.printStackTrace();
}
return null;
}
and it creates a customer
I'm doing my tests using this official quick start:
https://github.com/quarkusio/quarkus-quickstarts/tree/main/getting-started
I simply added the reflect-config.json and the native-image.properties under src/main/resources/META-INF/native-image/{package}/
I can sharre with you the updated project if you want at the end...
yes would be greate
Between I'm using Java 21 and latest version of GraalVM
Here is the sample I'm using...
After untarring it, you can build the native image using this command:
./mvnw package -Dnative
And then run the image:
`./target/getting-started-1.0.0-SNAPSHOT-runner
`
You can test the customer endpoint at localhost:8080/hello/stripe/customer
And don't forget to update your stripe API key
at GreetingResource line 20
thank you let me try
For the invoice part, there is still other attribute to update in the reflect-config.json, continue to add them one by one...
Hey @river rune any luck with Invoice ?
I just checked customer creation , I already had an similar endpoint in the service I am developing , and strangely enougth is working fine , but any enpoint that is fetching something is failing with NPE
for example trying to fetch all products defined in stripe is failing with
Have you completed the reflect-config.json with all the required fields ?
if so can you share it back with me ?
thanks checking...
You still have unregistred attributes in that file...
for example,
Caused by: java.lang.IllegalArgumentException: Type com.stripe.model.StripeCollection is instantiated reflectively but was never registered. Register the type by adding "unsafeAllocated" for the type in reflect-config.json.
Are you getting NPE on the sample I shared with you ?
No on my main project
I can't tell much about your main project
but what I'm sure of is that stripe-java works with quarkus and graalvm
you can always refer to the quickstart I shared with you and double check..
But you still was not able to execute an succesfull GET request, how can you be sure that is working ?
Ah maybe I wasn't enough clear then earlier
first you need to complete the reflect-config.json with all the required fields using the quickstart I shared with
are you able to complete this step ?
Why ?
You simply need to package the native image and run the invoice endpoint and see what field is missing.
But wait let's do it a bit simpler, lets pick an resource that have all the properties already present and try to fetch it
The main issue that for me with config that I shared with you I am stil getting NPE and not
I'll test the Customer endpoint...
You can use this file with the project I shared with you, the listing of a customer and invoices is working fine...
I strongly invite you to run the quarkus I shared with you and make your tests on it first, then try to see what is the different with your main project and what is causing issue...
There must be something else causing the NPE while packaging your app