vert.x
vert.x copied to clipboard
Starter Gradle project fails to start with java.lang.ClassNotFoundException
Version
4.1.5
Context
I downloaded starter Gradle project from https://vertx.io/get-started/
Unpacked it and ran ./gradlew clean run
It failed to start:
./gradlew clean run
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :run
Oct 28, 2021 12:38:26 AM io.vertx.core.impl.launcher.commands.Watcher
INFO: Watched paths: [/Users/relgames/myprojects/eatellia/vertx/./src]
Oct 28, 2021 12:38:26 AM io.vertx.core.impl.launcher.commands.Watcher
INFO: Starting the vert.x application in redeploy mode
Starting vert.x application...
fab6aa3a-19eb-474a-a628-561af9e8a349-redeploy
Error: Could not find or load main class
Caused by: java.lang.ClassNotFoundException:
<==========---> 80% EXECUTING [1m 49s]
> :run
Steps to reproduce
- Download starter Gradle project from https://vertx.io/get-started/
- unzip it to some folder
- run
./gradlew clean run
Extra
- MacOS Big Sur 11.6
- OpenJDK 64-Bit Server VM Corretto-17.0.1.12.1
- Also tried with Java 11 (Corretto-11.0.13.8.1), same result.
- Maven project works fine on Java 11 and 17:
./mvnw clean compile exec:java
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.example:starter >-------------------------
[INFO] Building starter 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ starter ---
[INFO] Deleting /Users/relgames/myprojects/eatellia/vertx-maven/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ starter ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/relgames/myprojects/eatellia/vertx-maven/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ starter ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/relgames/myprojects/eatellia/vertx-maven/target/classes
[INFO]
[INFO] --- exec-maven-plugin:3.0.0:java (default-cli) @ starter ---
HTTP server started on port 8888
Oct 28, 2021 12:48:19 AM io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer
INFO: Succeeded in deploying verticle
It could be specific to MacOS as I just tried with amazoncorretto:11-alpine
docker and it worked.
But, didn't with with openjdk 17 (so not corretto specific).
When I disabled redeploy, it started.
Instead of
tasks.withType<JavaExec> {
args = listOf("run", mainVerticleName, "--redeploy=$watchForChange", "--launcher-class=$launcherClassName", "--on-redeploy=$doOnChange")
}
I used
tasks.withType<JavaExec> {
args = listOf("run", mainVerticleName, "--launcher-class=$launcherClassName")
}
Then it started:
./gradlew run
> Task :run
HTTP server started on port 8888
Oct 30, 2021 12:57:56 PM io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer
INFO: Succeeded in deploying verticle
So the bug is in redeploy code.
Trying to debug, first it failed on slf4j class. Added slf4j-api and logback-classic, now it fails to load javax/smartcardio/CardPermission
class:
forName0:-1, Class (java.lang) [2]
forName:467, Class (java.lang)
getInstance:844, PolicyFile (sun.security.provider)
addGrantEntry:744, PolicyFile (sun.security.provider)
initDefaultPolicy:501, PolicyFile (sun.security.provider)
run:348, PolicyFile$2 (sun.security.provider)
run:345, PolicyFile$2 (sun.security.provider)
executePrivileged:776, AccessController (java.security)
doPrivileged:318, AccessController (java.security)
initPolicyFile:345, PolicyFile (sun.security.provider)
init:338, PolicyFile (sun.security.provider)
<init>:292, PolicyFile (sun.security.provider)
loadPolicyProvider:221, Policy (java.security)
getPolicyNoCheck:191, Policy (java.security)
implies:325, ProtectionDomain (java.security)
impliesWithAltFilePerm:357, ProtectionDomain (java.security)
checkPermission:463, AccessControlContext (java.security)
checkPermission:1068, AccessController (java.security)
run:48, Loader$1 (ch.qos.logback.core.util)
run:45, Loader$1 (ch.qos.logback.core.util)
executePrivileged:776, AccessController (java.security)
doPrivileged:318, AccessController (java.security)
<clinit>:45, Loader (ch.qos.logback.core.util)
findURLOfDefaultConfigurationFile:119, ContextInitializer (ch.qos.logback.classic.util)
autoConfig:148, ContextInitializer (ch.qos.logback.classic.util)
init:84, StaticLoggerBinder (org.slf4j.impl)
<clinit>:55, StaticLoggerBinder (org.slf4j.impl)
bind:150, LoggerFactory (org.slf4j)
performInitialization:124, LoggerFactory (org.slf4j)
getILoggerFactory:417, LoggerFactory (org.slf4j)
<clinit>:35, SLF4JLogDelegateFactory (io.vertx.core.logging)
forName0:-1, Class (java.lang) [1]
forName:467, Class (java.lang)
configureWith:61, LoggerFactory (io.vertx.core.logging)
initialise:49, LoggerFactory (io.vertx.core.logging)
<clinit>:34, LoggerFactory (io.vertx.core.logging)
getLogger:26, LoggerFactory (io.vertx.core.impl.logging)
<init>:46, ClasspathHandler (io.vertx.core.impl.launcher.commands)
<init>:48, BareCommand (io.vertx.core.impl.launcher.commands)
<init>:39, RunCommand (io.vertx.core.impl.launcher.commands)
get:-1, RunCommandFactory$$Lambda$2/0x0000000800c055b8 (io.vertx.core.impl.launcher.commands)
create:60, DefaultCommandFactory (io.vertx.core.spi.launcher)
getNewCommandInstance:179, VertxCommandLauncher (io.vertx.core.impl.launcher)
execute:234, VertxCommandLauncher (io.vertx.core.impl.launcher)
dispatch:383, VertxCommandLauncher (io.vertx.core.impl.launcher)
dispatch:346, VertxCommandLauncher (io.vertx.core.impl.launcher)
main:45, Launcher (io.vertx.core)
Downloaded a sample with:
curl -G https://start.vertx.io/starter.zip -d "groupId=com.example" -d "artifactId=starter" -d "vertxVersion=4.3.5" -d "language=java" -d "jdkVersion=17" -d "buildTool=gradle" --output starter.zip
Works for me with AdoptOpenJDK 17 on Mac OS. Perhaps an install issue. Closing.