Fixing “Invalid signature” and missing main class issues with GraalVM’s nativeCompile Gradle task

Originally posted on 2022-09-29

I was working on building some native executables today with GraalVM’s native image and I started running into a problem with a misleading error message. The message I got was:

Error: Main entry point class 'com.timmattison.AmazingMainClass' neither found on the classpath nor on the modulepath.

Naturally I popped open the nativecompile-classpath.jar and saw the class was there. After some research I found out the following:

  • Paho 1.2.5 includes META-INF/ECLIPSE_.RSA and META-INF/ECLIPSE_.SF files
  • Stripping down the project to a Hello World project that just includes Paho 1.2.5 yields an invalid signature error

The top level fatal error I got from the Hello World project was:

Fatal error: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

To fix this with the Gradle Kotlin DSL I had to add the following code:

tasks.nativeCompileClasspathJar {

Now it builds and runs perfectly. Hopefully this’ll save you some debugging time.