aws-serverless-java-container | Java wrapper to run Spring | REST library

 by   awslabs Java Version: 2.0.0-M2 License: Apache-2.0

kandi X-RAY | aws-serverless-java-container Summary

kandi X-RAY | aws-serverless-java-container Summary

aws-serverless-java-container is a Java library typically used in Manufacturing, Utilities, Machinery, Process, Web Services, REST, Spring Boot, Spring applications. aws-serverless-java-container has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. However aws-serverless-java-container has 31 bugs. You can download it from GitHub, Maven.

A Java wrapper to run Spring, Jersey, Spark, and other apps inside AWS Lambda.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              aws-serverless-java-container has a medium active ecosystem.
              It has 1351 star(s) with 538 fork(s). There are 76 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 43 open issues and 300 have been closed. On average issues are closed in 61 days. There are 7 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of aws-serverless-java-container is 2.0.0-M2

            kandi-Quality Quality

              OutlinedDot
              aws-serverless-java-container has 31 bugs (1 blocker, 4 critical, 19 major, 7 minor) and 967 code smells.

            kandi-Security Security

              aws-serverless-java-container has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              aws-serverless-java-container code analysis shows 0 unresolved vulnerabilities.
              There are 70 security hotspots that need review.

            kandi-License License

              aws-serverless-java-container is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              aws-serverless-java-container releases are available to install and integrate.
              Deployable package is available in Maven.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              aws-serverless-java-container saves you 11059 person hours of effort in developing the same functionality from scratch.
              It has 22413 lines of code, 1856 functions and 311 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed aws-serverless-java-container and discovered the below as its top functions. This is intended to give you an instant insight into aws-serverless-java-container implemented functionality, and help decide if they suit your requirements.
            • Encodes the given String as a String .
            • Parse the header value .
            • Gets the filter chain .
            • Create resources .
            • Return output stream .
            • Performs the actual proxy request .
            • Returns the authenticated user principal .
            • Writes the response body to the LambdaProxyResponse object .
            • Performs a forward request .
            • Validates the configuration .
            Get all kandi verified functions for this library.

            aws-serverless-java-container Key Features

            No Key Features are available at this moment for aws-serverless-java-container.

            aws-serverless-java-container Examples and Code Snippets

            No Code Snippets are available at this moment for aws-serverless-java-container.

            Community Discussions

            QUESTION

            Deploying Spring boot with Spring data jpa in AWS lambda
            Asked 2021-Feb-18 at 12:23

            I have created a spring boot application with spring data JPA that should connect with a RDS instance,i have api's exposed which will deo CRUD basically I have provided the DB connection details as below in application.yml file,

            ...

            ANSWER

            Answered 2021-Feb-18 at 12:23

            Increasing Lambda timeout fixed this issue. Added the below lines too,

            LambdaContainerHandler.getContainerConfig().setInitializationTimeout(60_000); handler = SpringBootLambdaContainerHandler.getAwsProxyHandler(Application.class);

            Source https://stackoverflow.com/questions/65983490

            QUESTION

            Spring boot failes with 'void org.springframework.boot.builder.SpringApplicationBuilder.(java.lang.Object[])': java.lang.NoSuchMethodError
            Asked 2020-Dec-08 at 23:28

            I have a spring boot app that I am trying to boot as a Lambda with the aws-serverless-java-container-spring library, and upon startup I get the error:

            ...

            ANSWER

            Answered 2020-Dec-08 at 23:28

            The common answer to this question is that you have mixed up some libraries, although I could never find good instructions on how to resolve the issue.

            The key thing to understand here is that the org.springframework.cloud.bootstrap.BootstrapApplicationListener class comes from the spring-cloud-context library, while org.springframework.boot.builder.SpringApplicationBuilder comes from the spring-boot library.

            Using mvn dependency:tree I could see the following output:

            Source https://stackoverflow.com/questions/65208451

            QUESTION

            AWS Lambda cold start issue with spring boot
            Asked 2020-Mar-21 at 19:21

            I am new to aws lambda and I am moving my spring boot 2.x based project to lambda.But I am struggling with lambda cold-start and warm-up. I tried a few things mentioned in this link:https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Spring-Boot, but still the application takes around 45 secs to start.

            Things I tried:

            1. Async initialization from the above link. It did help a bit but not enough.

            2. Skip the Init phase of the lambda. It helped reduce almost 8 secs.

            3. Provisioned concurrency but as far as I could see, it is not helping either. When I saw the logs, the spring context is getting initialized every time, if any request comes after an interval of 15-20 mins.

            The response time of my lambda in different scenarios is:

            ...

            ANSWER

            Answered 2020-Mar-21 at 19:21

            A 5 minute Cloudwatch Event would come out to arount 8600 calls / month. If you ran even 100000 calls it's still free according to the calculator on https://aws.amazon.com/lambda/pricing/ with 3GB of memory.

            To configure Cloudwatch to ping your Lambda, start by creating rule (Cloudwatch -> Rules) and have it run every 5 minutes:

            Then, have it run your Lambda:

            My Lambda in this example is named SnapshotHandler and it takes a small JSON object. Note that this calls the Lambda directly, not through an API gateway. That may or may not be what your Lambda code is expecting so you may need to update.

            If you want to call this Lambda via a HTTP/S API, you'll need to setup an SNS topic to publish the Cloudwatch event to and have the SNS topic call your API via HTTP. This is a bit more complicated but not terrible.

            All in all, you can do this but the cost is dependent on how many "normal" calls your API gets. At 1000000 calls per month a 3GB / 800ms Lambda is at about USD $33. At 10000000 it's nearly USD $400. But if you're getting that many calls (an average of about 230/second) it seems unlikely you need a heartbeat too.

            Source https://stackoverflow.com/questions/60787022

            QUESTION

            Supply lambda context to Jersey resource
            Asked 2019-Sep-11 at 16:43

            I'm using aws-serverless-java-container to wrap a Jersey service in a AWS Lambda. I decided to use function alias to have a "test" and "prod" stage that eventually points to different versions of the lambda function.

            I need to select some properties in a .properties file based on that alias, basically because I need to talk to a "test" or "prod" DB or use a different endpoint to invoke an external web service.

            For such purpose I need to invoke the method getInvokedFunctionArn of the Context object. Unfortunately the Jersey resource is not aware of such context by default.

            Below a sample resource:

            ...

            ANSWER

            Answered 2019-Jun-23 at 07:19

            You can Inject context to jersey resources using Spring profile

            Define for test and prod profiles different methods/objects

            If you don't have Spring, you can check jersey integration

            jersey-spring4 module that will act as the integration bridge for Spring and Jersey.

            See full example in github aws-serverless-java-container library running a Spring application with profiles in AWS Lambda

            There are two ways to activate Spring Profiles (as defined with the @Profile annotation). We recommend using the static initializer that receives a list of profiles. The Serverless Java Container framework takes care of setting the profile and initializing the application at once.

            Source https://stackoverflow.com/questions/56671175

            QUESTION

            How to setup aws lambda on existing spring boot project?
            Asked 2019-Jul-31 at 23:35

            I want to configure aws lambda in my existing Spring boot project. In my project i am using lombok, kafka consumer, and microservice. I follow steps at:

            https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Spring-Boot

            I added dependency:

            ...

            ANSWER

            Answered 2019-Jul-31 at 23:35

            The lambda will still work with @ComponentScan but the cold-start will take longer because of the all classes scan, which is mentioned in the tutorial. You can read more about cold-start in java, for example here https://aws.amazon.com/blogs/opensource/java-apis-aws-lambda (see "Cold start notes"). In short, when AWS Lambda doesn't reuse a container with your function/application it starts the application and scans all the classes while executing @ComponentScan. With @Import you avoid this scan, and that makes cold-start faster.

            You can also check the code sample for this package https://github.com/awslabs/aws-serverless-java-container/tree/master/samples/springboot/pet-store

            Source https://stackoverflow.com/questions/57291149

            QUESTION

            Spring Boot application throws MultipartException when running in AWS Lambda
            Asked 2018-Nov-30 at 09:09

            I just tried to run a Spring Boot application on AWS Lambda using the following article: https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Spring-Boot

            Basic requests are just working fine, but sending files seems to cause problems. Running the application locally works fine:

            ...

            ANSWER

            Answered 2018-Oct-27 at 17:19

            This was a bug in Amazon's library and has been fixed some days ago. More information is available here. Just make sure to use version 1.2 or above:

            Source https://stackoverflow.com/questions/52936877

            QUESTION

            How do I make JAR and WAR on IntelliJ IDEA?
            Asked 2017-Dec-07 at 13:53

            I want to develop a new java webservice to be deployed on AWS Lambda, but I also want to be able to easily test it.

            My idea is to code my webservice using Jersey and be able to compile it into a war file, so I can test it localy and also be able to compile it into a jar for the Serverless Java container from AWS.

            My first thought was to create 2 modules on IntelliJ IDEA 2017.3 Ultimate, one for the warand one for the jar, all using Maven, with the 2 modules sharing the same code base for the Jersey REST Resources (the webservice classes). But unfortunately I am too new to IntelliJ IDEA and I can't put this to work.

            Is there a way to achieve this?

            ...

            ANSWER

            Answered 2017-Dec-07 at 13:53

            Solution you provided is workable but IMO overcomplicated a bit. I did something similar for my project: first I made a module with all the sources and tests, then I sliced it to different artifacts. It's not the cleanest solution though - you have a risk of placing dependent classes to different artifacts and cause classloading issues in runtime.

            In your case it is simpler - you only need to repackage same content to another artifact, if I get it right. In simplest case, one module would be enough. You can just add a plugin for assembling WAR archive, like that:

            Source https://stackoverflow.com/questions/47684582

            QUESTION

            AWS API Gateway return HTML
            Asked 2017-Jun-21 at 21:48

            I am using the AWS labs' serverless container (https://github.com/awslabs/aws-serverless-java-container) to handle the lambda entrypoint and response for a lambda that returns HTML. It appears that it calls the lambda and returns the HTML just fine from the lambda. However, API Gateway then throws a fit processing the response. I am using the API Gateway as a proxy, not configuring individual endpoints.

            Wed Jun 21 20:53:29 UTC 2017 : Endpoint response body before transformations: --- statusCode: 200 headers: Content-Type: "text/html" body: "\r\n\r\nhttp://www.w3.org/1999/xhtml\"\r\n \ \ lang=\"en\">\r\n \r\n \r\n \ \ Page Title\r\n \r\n \r\n \ \ \r\n \r\n\ \ \r\n \r\n ... [TRUNCATED] Wed Jun 21 20:53:29 UTC 2017 : Endpoint response headers: {x-amzn-Remapped-Content-Length=0, x-amzn-RequestId=adb2b101-56c3-11e7-afc6-8383d836980f, Connection=keep-alive, Content-Length=17551, Date=Wed, 21 Jun 2017 20:53:29 GMT, X-Amzn-Trace-Id=root=1-594adcc9-6987c6ed102696c505538b02;sampled=0, Content-Type=application/octet-stream} Wed Jun 21 20:53:29 UTC 2017 : Execution failed due to configuration error: Malformed Lambda proxy response Wed Jun 21 20:53:29 UTC 2017 : Method completed with status: 502

            As you can see from the logs, the AWS own Java object, AwsProxyResponse, properly wraps the HTML content how AWS coded it. You see it returning the proper body and text/html headers. It seems API Gateway then blows up handling a response from AWS's own response.

            How do I get AWS Gateway to properly handle the response when the response form the lambda is Content-Type: test/html?

            ...

            ANSWER

            Answered 2017-Jun-21 at 21:48

            The response from the Lambda function does not look correct. It appears a raw string without any format.

            It should be JSON in the format:

            Source https://stackoverflow.com/questions/44686303

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install aws-serverless-java-container

            You can download it from GitHub, Maven.
            You can use aws-serverless-java-container like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the aws-serverless-java-container component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
            Maven
            Gradle
            CLONE
          • HTTPS

            https://github.com/awslabs/aws-serverless-java-container.git

          • CLI

            gh repo clone awslabs/aws-serverless-java-container

          • sshUrl

            git@github.com:awslabs/aws-serverless-java-container.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link