aws / aws/serverless-java-container

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

Open
#614 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.6k
Forks
574
PR merge metrics
No merged PRs in 30d

Description

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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.