java.lang.IllegalStateException:未找到 InjectionManagerFactory

时间:2021-05-04 11:11:20

标签: java aws-lambda jersey illegalstateexception datadog

我被困在这个问题上,我使用特定的 Datadog HTTP API ( "com.datadoghq" % "datadog-api-client" % "1.0.0-beta10" % "compile" ) 从我的内部向 Datadog 代理发送一些自定义统计信息应用。此客户端依赖于 jersey 依赖项。

我有几个端到端的测试用例,其中整个功能/流程都在工作,我能够成功发送统计数据。

当我开始使用(胖)jar 创建一个 Lambda 函数时,就会出现问题,该函数会随着任何传入的 SNS 事件触发。我收到以下错误,并且我尝试了多种依赖项组合阅读一些早期线程,但似乎没有任何效果。

你能给点建议吗?这可能是由于调用 Lambda 的方式吗?当我在本地运行时,一切都很好。虽然我认为这并不重要,但应用程序是用 Scala 2.12 编写的。

我尝试了以下线程:

  1. Jersey stopped working with InjectionManagerFactory not found
  2. HTTP Status 500 - Servlet.init()
  3. https://github.com/igniterealtime/REST-API-Client/issues/29
2021-05-03T23:58:12.412-04:00   java.lang.IllegalStateException: InjectionManagerFactory not found.
2021-05-03T23:58:12.412-04:00   at org.glassfish.jersey.internal.inject.Injections.lambda$lookupInjectionManagerFactory$0(Injections.java:98)
2021-05-03T23:58:12.412-04:00   at java.util.Optional.orElseThrow(Optional.java:290)
2021-05-03T23:58:12.412-04:00   at org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:98)
2021-05-03T23:58:12.412-04:00   at org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:68)
2021-05-03T23:58:12.412-04:00   at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:432)
2021-05-03T23:58:12.412-04:00   at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:341)
2021-05-03T23:58:12.412-04:00   at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:826)
2021-05-03T23:58:12.412-04:00   at org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:285)
2021-05-03T23:58:12.412-04:00   at org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:143)
2021-05-03T23:58:12.412-04:00   at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:112)
2021-05-03T23:58:12.412-04:00   at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:108)
2021-05-03T23:58:12.412-04:00   at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:99)
2021-05-03T23:58:12.412-04:00   at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:445)
2021-05-03T23:58:12.412-04:00   at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:351)
2021-05-03T23:58:12.412-04:00   at com.datadog.api.v1.client.ApiClient.sendRequest(ApiClient.java:1476)
2021-05-03T23:58:12.412-04:00   at com.datadog.api.v1.client.ApiClient.invokeAPI(ApiClient.java:1435)
2021-05-03T23:58:12.412-04:00   at com.datadog.api.v1.client.api.MetricsApi.submitMetricsWithHttpInfo(MetricsApi.java:533)
2021-05-03T23:58:12.412-04:00   at com.datadog.api.v1.client.api.MetricsApi.submitMetrics(MetricsApi.java:476)
2021-05-03T23:58:12.412-04:00   at com.organization.raw.beacon.metric.statsD.DataDogHttpMetricsApi.$anonfun$send$1(DataDogHttpMetricsApi.scala:115)
2021-05-03T23:58:12.412-04:00   at scala.util.Try$.apply(Try.scala:213)
2021-05-03T23:58:12.412-04:00   at com.organization.raw.beacon.metric.statsD.DataDogHttpMetricsApi.send(DataDogHttpMetricsApi.scala:115)
2021-05-03T23:58:12.412-04:00   at com.organization.raw.beacon.metric.application.EventHandler.pushStats(EventHandler.scala:102)
2021-05-03T23:58:12.412-04:00   at com.organization.raw.beacon.metric.application.SnsEventHandler.handle(SnsEventHandler.scala:67)
2021-05-03T23:58:12.412-04:00   at com.organization.raw.beacon.metric.SnsLambdaHandler.handleRequest(SnsLambdaHandler.scala:27)
2021-05-03T23:58:12.412-04:00   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2021-05-03T23:58:12.412-04:00   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2021-05-03T23:58:12.412-04:00   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2021-05-03T23:58:12.412-04:00   at java.lang.reflect.Method.invoke(Method.java:498)
2021-05-03T23:58:12.412-04:00   at lambdainternal.EventHandlerLoader$PojoMethodRequestHandler.handleRequest(EventHandlerLoader.java:263)
2021-05-03T23:58:12.412-04:00   at lambdainternal.EventHandlerLoader$PojoHandlerAsStreamHandler.handleRequest(EventHandlerLoader.java:180)
2021-05-03T23:58:12.412-04:00   at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:902)
2021-05-03T23:58:12.412-04:00   at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:340)
2021-05-03T23:58:12.412-04:00   at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:63)
2021-05-03T23:58:12.412-04:00   at java.lang.Class.forName0(Native Method)
2021-05-03T23:58:12.412-04:00   at java.lang.Class.forName(Class.java:348)
2021-05-03T23:58:12.412-04:00   at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:150)

调用Handler如下:

class SnsLambdaHandler extends RequestHandler[SNSEvent, Unit] with LazyLogging {

  // base configuration
  lazy val baseConfig: Config = getRootConfig.getConfig(this.getClass.getPackage.getName)

  /**
   * Handles SNS notification triggered by CreateObject Request in S3
   *
   * @param snsEvent
   * @param context
   */
  override def handleRequest(snsEvent: SNSEvent, context: Context): Unit = {

    logger.info("Request handler invoking for {} messages from the Sns Topic.", snsEvent.getRecords.size())
    val sqsMessageHandler = SnsEventHandler.apply(baseConfig, snsEvent)

    // handle the event
    sqsMessageHandler.handle()
  }
}

0 个答案:

没有答案