stripe java webhook.constructevent()无法调用com.stripe.model.event类的no args构造函数

oewdyzsn  于 2021-07-09  发布在  Java
关注(0)|答案(0)|浏览(178)

正在尝试构建可处理条带事件的quarkus应用程序
stripe java 20.47.0 gson 2.8.5版
我的资源层接收带有….的事件。。。。

@Path("/stripe-events/{realm}")
@POST
public Response stripeEvents(@PathParam("realm") String realm, @HeaderParam("Stripe-Signature") String sig, @RequestBody String event) {
        stripe.processEvent(realm,sig,event);
        return Response.ok().build();
}

我的服务层处理事件

@Transactional
public void
processEvent(String realm, String sig, String payload) {
    StripeAccount account = stripeRepo.getAccount(realm);
    if (account == null) {
        throw new ApiException(realm + " not found", 404);
    }

    Event event = null;
    try {
        event = Webhook.constructEvent(payload, sig, account.getSecret());
    } catch (SignatureVerificationException e) {
        log.error("invalid event signature");
        throw new ApiException("invalid request",400);
    } catch (JsonSyntaxException e) {
        log.error("invalid event object");
        throw new ApiException("invalid request",400);
    }

对于那些不熟悉stripe的人,webhook.constructevent()和com.stripe.model.event是stripe java中提供的库类…..如果这是建议的修复,我不能添加默认构造函数。。。。。
正在从条带发送测试webhook。。。。
{“created”:1326853478,“livemode”:false,“id”:“evt\u00000000000000”,“type”:“plan.created”,“object”:“event”,“request”:null,“pending\u webhooks”:1,“api\u version”:“2020-08-27”,“data”:{“object”:{“id”:“price\u000000000000000”,“object”:“plan”,“active”:true,“aggregate\u usage”:null,“amount”:2000,“amount\u decimal”:“2000”,“计费\u方案”:“每\u单位”,“创建时间”:1618961865,“货币”:“美元”,“间隔时间”:“月”,“间隔\u计数”:1,“生活模式”:false,“元数据”:{},“昵称”:null,“产品”:“prod \u00000000000000”,“分层\u模式”:null,“转换\u用法”:null,“试用期\u天数”:null,“用法类型”:“许可”}}
堆栈跟踪如下所示。。。。
23:08:19错误[io.qu.ve.ht.ru.quarkuserrorhandler](executor-thread-1)http请求/pay/stripe events/micro失败,错误id:7278eee5-4677-4505-6-8586db3b018f-3:org.jboss.resteasy.spi.unhandledexception:java.lang.runtimeexception:无法调用com.stripe.model.event类的无参数构造函数。为此类型向gson注册instancecreator可以解决此问题。位于org.jboss.resteasy.core.exceptionhandler.handlapplicationexception(exceptionhandler)。java:106)在org.jboss.resteasy.core.exceptionhandler.handleexception(exceptionhandler。java:372)在org.jboss.resteasy.core.synchronousdispatcher.writeexception(synchronousdispatcher。java:218)在org.jboss.resteasy.core.synchronousdispatcher.invoke(synchronousdispatcher。java:519)在org.jboss.resteasy.core.synchronousdispatcher.lambda$invoke$4(synchronousdispatcher。java:261)在org.jboss.resteasy.core.synchronousdispatcher.lambda$preprocess$0(synchronousdispatcher。java:161)在org.jboss.resteasy.core.interception.jaxrs.prematchcontainerrequestcontext.filter(prematchcontainerrequestcontext)。java:364)在org.jboss.resteasy.core.synchronousdispatcher.preprocess(synchronousdispatcher。java:164)在org.jboss.resteasy.core.synchronousdispatcher.invoke(synchronousdispatcher。java:247)在io.quarkus.resteasy.runtime.standalone.requestdispatcher.service(requestdispatcher。java:73)在io.quarkus.resteasy.runtime.standalone.vertxrequesthandler.dispatch(vertxrequesthandler。java:138)在io.quarkus.resteasy.runtime.standalone.vertxrequesthandler.access$000(vertxrequesthandler。java:41)在io.quarkus.resteasy.runtime.standalone.vertxrequesthandler$1.run(vertxrequesthandler)。java:93)在org.jboss.threads.enhancedqueueexecutor$task.run(enhancedqueueexecutor。java:2415)在org.jboss.threads.enhancedqueueexecutor$threadbody.run(enhancedqueueexecutor。java:1452)在org.jboss.threads.delegatingrunnable.run(delegatingrunnable。java:29)在org.jboss.threads.threadlocalresettingrunnable.run(threadlocalresettingrunnable。java:29)在java.lang.thread.run(线程。java:834)在org.jboss.threads.jbossthread.run(jbossthread。java:501)在com.oracle.svm.core.thread.javathreads.threadstartrotine(javathreads。java:519)在com.oracle.svm.core.posix.thread.posixjavathreads.pthreadstartrotine(posixjavathreads)。java:192)原因:java.lang.runtimeexception:无法为类com.stripe.model.event调用无参数构造函数。为此类型向gson注册instancecreator可以解决此问题。在com.google.gson.internal.constructorconstructor$14.construct(constructorconstructor。java:228)在com.google.gson.internal.bind.reflectTypeAdapterFactory$adapter.read(reflectTypeAdapterFactory。java:212)在com.google.gson.gson.fromjson(gson。java:927)在com.google.gson.gson.fromjson(gson。java:892)在com.google.gson.gson.fromjson(gson。java:841)在com.google.gson.gson.fromjson(gson。java:813)在com.stripe.net.webhook.constructevent(webhook。java:49)在com.stripe.net.webhook.constructevent(webhook。java:30)在com.sophware.pay.stripeservice.processevent(stripeservice。java:38)在com.sophware.pay.stripeservice\u subclass.processevent$$superaccessor1(stripeservice\u子类)。zig:235)在com.sophware.pay.stripeservice\u subclass$$function$$1.apply(stripeservice\u subclass$$function$$1。zig:47)在io.quarkus.arc.impl.aroundinvokeinvocationcontext.procedue(aroundinvokeinvocationcontext。java:54)在io.quarkus.narayana.jta.runtime.interceptor.transactionalinterceptorbase.InvokeInurtx(transactionalinterceptorbase。java:127)在io.quarkus.narayana.jta.runtime.interceptor.transactionalinterceptorbase.InvokeInurtx(transactionalinterceptorbase。java:100)在io.quarkus.narayana.jta.runtime.interceptor.transactionalinterceptorrequired.dointercept(transactionalinterceptorrequired。java:32)在io.quarkus.narayana.jta.runtime.interceptor.transactionalinterceptorbase.intercept(transactionalinterceptorbase。java:53)在io.quarkus.narayana.jta.runtime.interceptor.transactionalinterceptorrequired.intercept(transactionalinterceptorrequired。java:26)在io.quarkus.narayana.jta.runtime.interceptor.transactionalinterceptorrequired\u bean.intercept(transactionalinterceptorrequired\u bean。zig:340)在io.quarkus.arc.impl.interceptorinvocation.invoke(interceptorinvocation。java:41)在io.quarkus.arc.impl.aroundinvokeinvocationcontext.perform(aroundinvokeinvocationcontext。java:41)在io.quarkus.arc.impl.invocationcontexts.PerformRoundInvoke(invocationcontexts。java:32)在com.sophware.pay.stripeservice\u子类.processevent(stripeservice\u子类)。zig:188)在com.sophware.pay.stripeservice\u clientproxy.processevent(stripeservice\u clientproxy。zig:163)在com.sophware.pay.payrource.stripeevents(payrource。java:23)在java.lang.reflect.method.invoke(方法。java:566)在org.jboss.resteasy.core.methodinjectorimpl.invoke(methodinjectorimpl。java:170)在org.jboss.resteasy.core.methodinjectorimpl.invoke(methodinjectorimpl。java:130)位于org.jboss.resteasy.core.resourcemethodinvoker.internalinvokeontarget(resourcemethodinvoker。java:643)在org.jboss.resteasy.core.resourcemethodinvoker.invokeontargetafterfilter(resourcemethodinvoker。java:507)在org.jboss.resteasy.core.resourcemethodinvoker.lambda$invokeontarget$2(resourcemethodinvoker。java:457)位于org.jboss.resteasy.core.interception.jaxrs.prematchcontainerrequestcontext.filter(prematchcontainerrequestcontext)。java:364)在org.jboss.resteasy.core.resourcemethodinvoker.invokeontarget(resourcemethodinvoker。java:459)位于org.jboss.resteasy.core.resourcemethodinvoker.invoke(resourcemethodinvoker)。java:419)位于org.jboss.resteasy.core.resourcemethodinvoker.invoke(resourcemethodinvoker)。java:393)在org.jboss.resteasy.core.resourcemethodinvoker.invoke(resourcemethodinvoker。java:68)在org.jboss.resteasy.core.synchronousdispatcher.invoke(synchronousdispatcher。java:492) ... 17更多原因:java.lang.reflect.invocationtargetexception at java.lang.reflect.method.invoke(method。java:566)在com.google.gson.internal.unsafeallocator$1.newinstance(unsafeallocator。java:50)在com.google.gson.internal.constructorconstructor$14.construct(constructorconstructor。java:225) ... 52其他原因:java.lang.illegalargumentexception:class com.stripe.model.event反射性地示例化,但从未注册。使用org.graalvm.nativeimage.hosted.runtimereflection在com.oracle.svm.core.graal.snippets.substrateallocationsnippets.huberrstub(substrateallocationsnippets)注册该类。java:247)在sun.misc.unsafe.allocateinstance(unsafe。java:840) ... 55个以上

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题