1

Every time I create a new AWS Lambda Java Project in Eclipse using this guide, I get the following compilation error.

compilation-error-screenshot

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;

public class MyHandler implements RequestHandler<Object, Object> {

    @Override
    public Object handleRequest(Object input, Context context) {
        context.getLogger().log("Input: " + input);

        // TODO: implement your handler
        return null;
     }
}

pom.xml looks as follows:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.myproject</groupId>
  <artifactId>myfirstlambda</artifactId>
  <version>4.0.0</version>
  <dependencies>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-lambda-java-core</artifactId>
      <version>1.0.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-lambda-java-events</artifactId>
      <version>1.1.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk</artifactId>
      <version>1.11.127</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

I have other projects that were previously created by my colleague and they seem to have the exact same structure and they work absolutely fine on my Eclipse. They also work when I have tried matching the dependencies between the two projects and everything is the exact same.

More than that, I would like to believe that if something that comes out of a template should not have compilation errors.

What am I doing wrong?

Venkatesh Wadawadagi
  • 2,793
  • 21
  • 34
LeoNeo
  • 739
  • 1
  • 9
  • 28

0 Answers0