aws-greengrass/aws-greengrass-nucleus

Unable to compile Greengrass nucleus

Closed this issue · 3 comments

Describe the bug
I'm trying to compile Nucleus on Windows 11.
I first tried with Maven 3.9.6 + Java JDK 21, then tried with Maven 3.9.6 + Java JDK 8 as it seems JDK 21 is incompatible with Greengrass Nucleus. However, even with JDK 8, I get errors when trying to compile. It seems some API that are called are newer than Java JDK 8:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/temp/nucleus/aws-greengrass-nucleus/src/main/java/software/amazon/awssdk/http/apache/internal/conn/SdkTlsSocketFactory.java:[50,19] cannot find symbol
  symbol:   method setApplicationProtocols(java.lang.String[])
  location: variable params of type javax.net.ssl.SSLParameters
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:57 min
[INFO] Finished at: 2024-02-27T18:34:11+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project nucleus: Compilation failure
[ERROR] /C:/temp/nucleus/aws-greengrass-nucleus/src/main/java/software/amazon/awssdk/http/apache/internal/conn/SdkTlsSocketFactory.java:[50,19] cannot find symbol
[ERROR]   symbol:   method setApplicationProtocols(java.lang.String[])
[ERROR]   location: variable params of type javax.net.ssl.SSLParameters

To Reproduce
I'm using Java 8 to compile on Windows 11:

java -version
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
javac -version
javac 1.8.0_202

When trying to compile I get an error:

mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.aws.greengrass:nucleus >---------------------
[INFO] Building greengrass-nucleus 2.13.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- license:4.0.rc2:check (default) @ nucleus ---
[INFO] Checking licenses...
[WARNING] Unknown file extension: C:/temp/nucleus/aws-greengrass-nucleus/scripts/greengrass.service.procd.template
[WARNING] Unknown file extension: C:/temp/nucleus/aws-greengrass-nucleus/scripts/loader
[WARNING] Unknown file extension: C:/temp/nucleus/aws-greengrass-nucleus/scripts/greengrass.service.template
[WARNING] Unknown file extension: C:/temp/nucleus/aws-greengrass-nucleus/scripts/greengrass.xml.template
[WARNING] Unknown file extension: C:/temp/nucleus/aws-greengrass-nucleus/uat/src/main/resources/greengrass/features/component.feature
[WARNING] Unable to find a comment style definition for some files. You may want to add a custom mapping for the relevant file extensions.
[INFO]
[INFO] --- checkstyle:3.1.0:check (validate) @ nucleus ---
[INFO]
[INFO] --- jacoco:0.8.5:prepare-agent (pre-unit-test) @ nucleus ---
[INFO] surefire.argLine set to -javaagent:C:\Users\lconvert\.m2\repository\org\jacoco\org.jacoco.agent\0.8.5\org.jacoco.agent-0.8.5-runtime.jar=destfile=C:\temp\nucleus\aws-greengrass-nucleus\target\jacoco.exec,excludes=/Exception:/awssdk/:/vendored/**
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ nucleus ---
[INFO] Copying 3 resources from to target\classes
[INFO] skip non existing resourceDirectory C:\temp\nucleus\aws-greengrass-nucleus\src\main\resources
[INFO]
[INFO] --- compiler:3.8.1:compile (default-compile) @ nucleus ---
[INFO] Compiling 113 source files to C:\temp\nucleus\aws-greengrass-nucleus\target\classes
[INFO] /C:/temp/nucleus/aws-greengrass-nucleus/src/main/java/com/aws/greengrass/deployment/IotJobsClientWrapper.java: Some input files use or override a deprecated API.
[INFO] /C:/temp/nucleus/aws-greengrass-nucleus/src/main/java/com/aws/greengrass/deployment/IotJobsClientWrapper.java: Recompile with -Xlint:deprecation for details.
[INFO] /C:/temp/nucleus/aws-greengrass-nucleus/src/main/java/com/aws/greengrass/util/BaseRetryableAccessor.java: Some input files use unchecked or unsafe operations.
[INFO] /C:/temp/nucleus/aws-greengrass-nucleus/src/main/java/com/aws/greengrass/util/BaseRetryableAccessor.java: Recompile with -Xlint:unchecked for details.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/temp/nucleus/aws-greengrass-nucleus/src/main/java/software/amazon/awssdk/http/apache/internal/conn/SdkTlsSocketFactory.java:[50,19] cannot find symbol
symbol: method setApplicationProtocols(java.lang.String[])
location: variable params of type javax.net.ssl.SSLParameters
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.522 s
[INFO] Finished at: 2024-02-27T18:46:37+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project nucleus: Compilation failure
[ERROR] /C:/temp/nucleus/aws-greengrass-nucleus/src/main/java/software/amazon/awssdk/http/apache/internal/conn/SdkTlsSocketFactory.java:[50,19] cannot find symbol
[ERROR] symbol: method setApplicationProtocols(java.lang.String[])
[ERROR] location: variable params of type javax.net.ssl.SSLParameters
[ERROR]
[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

Expected behavior
I'm expecting Greengrass nucleus to be compiled without errors

Actual behavior
Errors occur during compilation

Environment

  • OS: Windows 11
  • JDK version: 8
  • Nucleus version: greengrass-nucleus 2.13.0-SNAPSHOT

Additional context
Add any other context about the problem here.

E.g. what is the impact of the bug?
I need to compile Greengrass to be able to debug it in an LXC container on an embedded device to find what is missing on my device.

Hello there,

Looks like you're using an old version of Java 8. Please use the latest version of Java 8 available. At least u252 is required.

// Java 8 did not launch with ALPN support, but it was backported in April 2020 with JDK8u252.

Why do you need to build Greengrass yourself for debugging? That should not be required, however you certainly can do that. I'd recommend you use standard Java debugging tools including remote java agent to attach a debugger to a running JVM.
We do not recommend running Greengrass inside of containers as it limits the capabilities of Greengrass and the components that you deploy through Greengrass.

I'm able to build with Java 21 without issue using mvn package -DskipTests. What is the command you are using? What was the problem with Java 21?

Thanks both of you!
I was able to compile using JDK-8u401 and with the -DskipTests option.
Now I have to debug it on my device to check what's missing on my device to run it correctly.