Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven Archetype quarkus-amazon-lambda-archetype:2.3.0.Final creates project with uncompilable source code on Test folder. #20674

Closed
ernestomar opened this issue Oct 11, 2021 · 1 comment · Fixed by #20747
Labels
Milestone

Comments

@ernestomar
Copy link

Describe the bug

Trying to follow the documentation at: https://quarkus.io/guides/amazon-lambda

After the execution of :

mvn archetype:generate
-DarchetypeGroupId=io.quarkus
-DarchetypeArtifactId=quarkus-amazon-lambda-archetype
-DarchetypeVersion=2.3.0.Final

Is not possible build the project, mvn clean package thrwes:

$ mvn clean package
[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------< net.cirrus.it.test:test-lambda >-------------------
[INFO] Building test-lambda 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test-lambda ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ test-lambda ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ test-lambda ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to /home/parallels/test-lambda/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ test-lambda ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ test-lambda ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/parallels/test-lambda/target/test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/parallels/test-lambda/src/test/java/net/cirrus/it/test/LambdaHandlerTest.java:[18,9] cannot find symbol
  symbol:   class Person
  location: class net.cirrus.it.test.LambdaHandlerTest
[ERROR] /home/parallels/test-lambda/src/test/java/net/cirrus/it/test/LambdaHandlerTest.java:[18,25] cannot find symbol
  symbol:   class Person
  location: class net.cirrus.it.test.LambdaHandlerTest
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.412 s
[INFO] Finished at: 2021-10-11T12:55:17-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile) on project test-lambda: Compilation failure: Compilation failure: 
[ERROR] /home/parallels/test-lambda/src/test/java/net/cirrus/it/test/LambdaHandlerTest.java:[18,9] cannot find symbol
[ERROR]   symbol:   class Person
[ERROR]   location: class net.cirrus.it.test.LambdaHandlerTest
[ERROR] /home/parallels/test-lambda/src/test/java/net/cirrus/it/test/LambdaHandlerTest.java:[18,25] cannot find symbol
[ERROR]   symbol:   class Person
[ERROR]   location: class net.cirrus.it.test.LambdaHandlerTest
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

The source code has the class InputObject but not Person.

parallels@parallels-Parallels-Virtual-Platform:~/test-lambda$ tree src
src
├── main
│   ├── java
│   │   └── net
│   │       └── cirrus
│   │           └── it
│   │               └── test
│   │                   ├── InputObject.java
│   │                   ├── OutputObject.java
│   │                   ├── ProcessingService.java
│   │                   ├── StreamLambda.java
│   │                   ├── TestLambda.java
│   │                   └── UnusedLambda.java
│   └── resources
│       └── application.properties
└── test
    ├── java
    │   └── net
    │       └── cirrus
    │           └── it
    │               └── test
    │                   └── LambdaHandlerTest.java
    └── resources
        └── application.properties

14 directories, 9 files

The generated test class has a reference to Person:

package net.cirrus.it.test;

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.containsString;

@QuarkusTest
public class LambdaHandlerTest {

    @Test
    public void testSimpleLambdaSuccess() throws Exception {
        // you test your lambas by invoking on http://localhost:8081
        // this works in dev mode too

        Person in = new Person();
        in.setName("Stu");
        given()
                .contentType("application/json")
                .accept("application/json")
                .body(in)
                .when()
                .post()
                .then()
                .statusCode(200)
                .body(containsString("Hello Stu"));
    }

}

Some minor changes on LambdaHandlerTest are required:

package net.cirrus.it.test;

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.containsString;

@QuarkusTest
public class LambdaHandlerTest {

    @Test
    public void testSimpleLambdaSuccess() throws Exception {
        // you test your lambas by invoking on http://localhost:8081
        // this works in dev mode too

        InputObject in = new InputObject();
        in.setName("Stu");
        in.setGreeting("Hello");
        given()
                .contentType("application/json")
                .accept("application/json")
                .body(in)
                .when()
                .post()
                .then()
                .statusCode(200)
                .body(containsString("Hello Stu"));
    }

}

Expected behavior

Succesful compilation.

Actual behavior

ERROR] /home/parallels/test-lambda/src/test/java/net/cirrus/it/test/LambdaHandlerTest.java:[18,9] cannot find symbol
[ERROR] symbol: class Person
[ERROR] location: class net.cirrus.it.test.LambdaHandlerTest
[ERROR] /home/parallels/test-lambda/src/test/java/net/cirrus/it/test/LambdaHandlerTest.java:[18,25] cannot find symbol
[ERROR] symbol: class Person
[ERROR] location: class net.cirrus.it.test.LambdaHandlerTest

How to Reproduce?

Create fresh project with:

mvn archetype:generate \
       -DarchetypeGroupId=io.quarkus \
       -DarchetypeArtifactId=quarkus-amazon-lambda-archetype \
       -DarchetypeVersion=2.3.0.Final

And run

mvn clean package

Output of uname -a or ver

Linux parallels-Parallels-Virtual-Platform 5.11.0-37-generic #41~20.04.2-Ubuntu SMP Fri Sep 24 09:06:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux para

Output of java -version

openjdk version "11.0.12" 2021-07-20

GraalVM version (if different from Java)

No response

Quarkus version or git rev

Quarkus 2.3.0.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.3

Additional information

No response

@ernestomar ernestomar added the kind/bug Something isn't working label Oct 11, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 11, 2021

/cc @matejvasek, @patriot1burke, @quarkusio/devtools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants