micronaut-guides / creating-your-first-micronaut-app-kotlin

8 stars 20 forks source link

./gradlew run fails with java.lang.NoSuchMethodError: com.sun.tools.javac.processing.JavacProcessingEnvironment.validImportStringToPattern(Ljava/lang/String;)Ljava/util/regex/Pattern; #12

Closed Applequist closed 4 years ago

Applequist commented 4 years ago

I've been following the Micronaut tutorial on https://guides.micronaut.io/creating-your-first-micronaut-app-kotlin/guide/index.html and when running the app I get the following error:

Task :kaptKotlin FAILED e: java.lang.NoSuchMethodError: com.sun.tools.javac.processing.JavacProcessingEnvironment.validImportStringToPattern(Ljava/lang/String;)Ljava/util/regex/Pattern; at org.jetbrains.kotlin.kapt3.base.incremental.JavaClassCache.invalidateEntriesAnnotatedWith(classStructureCache.kt:133) at org.jetbrains.kotlin.kapt3.base.incremental.JavaClassCacheManager.invalidateAndGetDirtyFiles(cache.kt:58) at org.jetbrains.kotlin.kapt3.base.KaptContext.(KaptContext.kt:64) at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:175) at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:99) at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:96) at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:106) at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:81) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:555) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:82) at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:107) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:546) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:177) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:164) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:54) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42) at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104) at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1558) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359) at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200) at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)

FAILURE: Build failed with an exception.

I'm using kotlin 1.3.50 with JRE 11.0.3+7-LTS

Thanks for your help

ilopmar commented 4 years ago

I've tried using this java version from SDKMan: sdk use java 11.0.5.hs-adpt and I can run both ./gradlew test and ./gradlew run and it works as expected. Can you please clone the guide and try it again?

bram209 commented 4 years ago

I had the same issue with 11.0.4, can confirm that it works after installing the 11.0.5 sdk

dkowis commented 4 years ago

I'm seeing this happen with 11.0.5, but it's sporatic.

If I do a clean build, it goes away, if I do a build again later, it shows up. Just have to change something, and it then immediately it dies.

openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-post-Ubuntu-0ubuntu1.118.04)
OpenJDK 64-Bit Server VM (build 11.0.5+10-post-Ubuntu-0ubuntu1.118.04, mixed mode, sharing)
dkowis commented 4 years ago

https://kotlinlang.org/docs/reference/kapt.html#gradle-build-cache-support-since-1220

I can remove the problem by disabling the kapt build cache. I think that's the problem.

bram209 commented 4 years ago

I indeed still had the problem on 11.0.5

sdelamo commented 4 years ago

Hi, I have updated the guide to Micronaut 2.0.

I can run with JDK 11. Please reopen if you are still able to reproduce the issue.

% java --version
openjdk 11.0.7 2020-04-14 LTS
OpenJDK Runtime Environment Corretto-11.0.7.10.1 (build 11.0.7+10-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.7.10.1 (build 11.0.7+10-LTS, mixed mode)
sdelamo@Sergios-iMac-Pro complete % ./gradlew run

> Task :complete:run
07:23:20.189 [main] INFO  io.micronaut.runtime.Micronaut - Startup completed in 794ms. Server Running: http://localhost:8080