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!

贡献指南

打开贡献指南

调研方向

Start with StreamLambdaHandler and its ResourceConfig registration, then inspect build.gradle for the Jersey, Spring Boot, and AWS serverless container dependencies. Reproduce the warning and trace the runtime provider configuration; done means PingResource is recognized and the reported request is handled without the SERVER-runtime warning.

由索引模型根据 Issue 内容生成。

评估

技术栈
aws, java, spring-boot
领域
api, backend, cloud
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。