aws / aws/serverless-java-container

registered in SERVER runtime does not implement any provider interfaces applicable in the SERVER runtime

未關閉
#614 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Java
星號
1.6k
分支
574
PR 合併指標
30 天內沒有已合併 PR

描述

Implementation: Jersey

Hello,

I'm encountering an issue where my JAX-RS resource is not being recognized despite having correct JAX-RS annotations.

As I am getting error:

```
WARNING: A provider bingadsapi.resource.PingResource registered in SERVER runtime does not implement any provider interfaces applicable in the SERVER runtime. Due to constraint configuration problems the provider bingadsapi.resource.PingResource will be ignored.
```

Here is the code for my JAX-RS resource:

```
package bingadsapi.resource;

import java.util.Map;
import java.util.HashMap;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path("/ping")
public class PingResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.WILDCARD)
public Response ping() {
Map pong = new HashMap<>();
pong.put("pong", "Hello, World!");
return Response.status(200).entity(pong).build();
}
}
```

my `build.gradle`

```
apply plugin: 'java'

repositories {
mavenLocal()
mavenCentral()
}

group = 'bingadsapi'
version = '1.0-SNAPSHOT'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

repositories {
mavenLocal()
mavenCentral()
}

dependencies {

implementation ('org.springframework.boot:spring-boot-starter-web:2.6.2') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
implementation 'com.amazonaws.serverless:aws-serverless-java-container-springboot2:[1.4,)'
implementation 'com.amazonaws.serverless:aws-serverless-java-container-springboot2:1.9.3'
implementation 'io.symphonia:lambda-logging:1.0.1'

testImplementation 'org.glassfish.main.extras:glassfish-embedded-all:3.1.2.2'

implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.1000')
implementation 'com.amazonaws:aws-java-sdk-s3'
implementation 'com.amazonaws:aws-java-sdk-secretsmanager'

compile 'com.googlecode.json-simple:json-simple:1.1.1'

implementation 'com.microsoft.bingads:microsoft.bingads:13.0.1'
implementation 'org.apache.commons:commons-text:1.4'
implementation 'com.amazonaws:aws-lambda-java-core:1.2.1'
// implementation 'com.amazonaws.serverless:aws-serverless-java-container-jersey:[1.0,)'
implementation 'com.amazonaws.serverless:aws-serverless-java-container-jersey:1.9'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.4'
implementation 'io.symphonia:lambda-logging:1.0.3'

implementation ('org.glassfish.jersey.media:jersey-media-json-jackson:2.36') {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
}

implementation ('org.glassfish.jersey.inject:jersey-hk2:2.36') {
exclude group: 'javax.inject', module: 'javax.inject'
}

testImplementation 'junit:junit:4.13.2'
}

task assembleZip(type: Zip) {
from compileJava
from processResources
into('lib') {
from configurations.runtimeClasspath
}
}

assemble.dependsOn assembleZip

```

Handler:

```
package bingadsapi;

import com.amazonaws.serverless.proxy.jersey.JerseyLambdaContainerHandler;
import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;

import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.ServerProperties;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import bingadsapi.resource.*;

public class StreamLambdaHandler implements RequestStreamHandler {
private static final ResourceConfig jerseyApplication = new ResourceConfig()
// properties to speed up Jersey start time
.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE,true)
.property(ServerProperties.WADL_FEATURE_DISABLE,true)
.property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE,true)
.property(ServerProperties.BV_FEATURE_DISABLE,true)
.property(ServerProperties.JSON_PROCESSING_FEATURE_DISABLE,true)
.property(ServerProperties.MOXY_JSON_FEATURE_DISABLE,true)
.register(PingResource.class)
.register(BingAdsResource.class)
.register(JacksonFeature.class);

private static final JerseyLambdaContainerHandler handler
= JerseyLambdaContainerHandler.getAwsProxyHandler(jerseyApplication);

@Override
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context)
throws IOException {
handler.getContainerConfig().setInitializationTimeout(30_000);
handler.proxyStream(inputStream, outputStream, context);
}
}
```

Any hints, advice, or guidance would be greatly appreciated. Thanks in advance for your help!

貢獻指南

開啟貢獻指南

研究方向

先從 StreamLambdaHandler 及其 ResourceConfig 註冊開始,然後檢查 build.gradle 中 Jersey、Spring Boot 和 AWS serverless container 的相依性。重現該警告並追蹤執行階段 provider 設定;當 PingResource 被辨識且所回報的請求在沒有 SERVER-runtime 警告的情況下得到處理時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
aws, java, spring-boot
領域
api, backend, cloud
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。