Micronaut-core: Blank Micronaut 1.0 RC1 does not run in IntelliJ

Created on 4 Oct 2018  路  11Comments  路  Source: micronaut-projects/micronaut-core

I have created a blank app using Micronaut 1.0.RC1 and CLI command

mn create-app sillynaut --profile service \
   --features java,spock,jdbc-hikari,hibernate-jpa,jib

After importing the project into IntelliJ 2018.2.4 I tried to start the Application by running the main method of the Application class.

/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/bin/java "-javaagent:/Users/saw303/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/182.4505.22/IntelliJ IDEA 2018.2 EAP.app/Contents/lib/idea_rt.jar=58014:/Users/saw303/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/182.4505.22/IntelliJ IDEA 2018.2 EAP.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/tools.jar:/Users/saw303/dev/private/sillynaut/out/production/classes:/Users/saw303/dev/private/sillynaut/out/production/resources:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut/http-client/1.0.0.RC1/e0fc1145ac279e2cb37ba83588de3c0deb7f5562/http-client-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut.configuration/hibernate-jpa/1.0.0.RC1/5f7482f9c8dfde45d9c0e5ddfb743af22e9ccc64/hibernate-jpa-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut.configuration/hibernate-validator/1.0.0.RC1/505c233c19409a644fd519308741a020610c8755/hibernate-validator-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut/validation/1.0.0.RC1/9f489bc12364c0a5b647e7538f8be830f7849bdb/validation-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut/http-server-netty/1.0.0.RC1/20bfb981de34fc9b32aae83b7141ac8b139c673b/http-server-netty-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut/http-server/1.0.0.RC1/8c1d1b42691a41e81a006049a363ff29014ce8cb/http-server-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut/runtime/1.0.0.RC1/f9fa101c607f9fcb77c4b4d761873002d28edff3/runtime-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut.configuration/jdbc-hikari/1.0.0.RC1/1ce15a9884df1887301adf12e484722cf332c5c1/jdbc-hikari-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut/http-netty/1.0.0.RC1/ca6338005bda1be53f0b502ae43ce7be708beab0/http-netty-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut/websocket/1.0.0.RC1/e36ee91ebd54fca37b04abd12b724aaa54e0e82d/websocket-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut/router/1.0.0.RC1/b6d9b9788c8c7aa6d6574765b4025478ada0a21f/router-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut/http/1.0.0.RC1/594776dec6ea851bf0991586f68a642dfe327cfe/http-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut/spring/1.0.0.RC1/a690ca8cdc8171c0951ae361329a105b2297e0cf/spring-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut/aop/1.0.0.RC1/de6aacbc752eb66d16cb55f67e82136802c397a6/aop-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut/jdbc/1.0.0.RC1/38ba150513d5e2cc8b480d6f21cc46b339acbdc2/jdbc-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/javax.annotation/javax.annotation-api/1.3.2/934c04d3cfef185a8008e7bf34331b79730a9d43/javax.annotation-api-1.3.2.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.micronaut/buffer-netty/1.0.0.RC1/52d8abe4b92041ec14028e1523c02cb917943b48/buffer-netty-1.0.0.RC1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.mariadb.jdbc/mariadb-java-client/2.2.5/3d1406a8ed02ca69cc389ae715cee8913871a81e/mariadb-java-client-2.2.5.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/com.zaxxer/HikariCP/2.7.9/a83113d2c091d0d0f853dad3217bd7df3beb6ae3/HikariCP-2.7.9.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.25/da76ca59f6a57ee3102f8f9bd9cee742973efa8a/slf4j-api-1.7.25.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.reactivex.rxjava2/rxjava/2.2.2/db2277cb0641bd8bd2f491fab555d37345351d6/rxjava-2.2.2.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.netty/netty-handler-proxy/4.1.29.Final/67e9473ac043b4d173ac9d620d43eb428ecc408a/netty-handler-proxy-4.1.29.Final.jar:/Users/saw303/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.yaml/snakeyaml/1.23/ec62d74fe50689c28c0ff5b35d3aebcaa8b5be68/snakeyaml-1.23.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.hibernate.validator/hibernate-validator/6.0.13.Final/af4232bf90ecd33c71147d67185dbb1cfe8f33df/hibernate-validator-6.0.13.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/javax.validation/validation-api/2.0.1.Final/cb855558e6271b1b32e716d24cb85c7f583ce09e/validation-api-2.0.1.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.9.7/98d8f190db07f97c64c0ea3af5792f718a6c2cc1/jackson-datatype-jdk8-2.9.7.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.9.7/cbd919f1ce67533e07b98dd493247e8dbabc26b2/jackson-datatype-jsr310-2.9.7.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.9.7/e6faad47abd3179666e89068485a1b88a195ceb7/jackson-databind-2.9.7.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.hibernate/hibernate-core/5.3.6.Final/42c7130757c3f67dda008d8edb28b381a09a7ce6/hibernate-core-5.3.6.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.springframework/spring-orm/5.0.8.RELEASE/4da63072d1ed6a2eb4bc0a4c8da5e09f39b5021e/spring-orm-5.0.8.RELEASE.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.reactivestreams/reactive-streams/1.0.1/1b1c911686eb40179219466e6a59b634b9d7a748/reactive-streams-1.0.1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.netty/netty-codec-http/4.1.29.Final/454688b88cea27a4d407202d1fc79a6522345b5e/netty-codec-http-4.1.29.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.netty/netty-handler/4.1.29.Final/1acf1d94799296a2517533ec75ce7e155e9c4ea7/netty-handler-4.1.29.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.netty/netty-codec-socks/4.1.29.Final/f687150259de44f0ff7b37a449f1a1bf6f20e992/netty-codec-socks-4.1.29.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-core/1.2.3/864344400c3d4d92dfeb0a305dc87d953677c03c/logback-core-1.2.3.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.netty/netty-codec/4.1.29.Final/1651bc2e279216773c234cafe402d68d2a5adc90/netty-codec-4.1.29.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.netty/netty-transport/4.1.29.Final/c190b90f70e2ae8a48c068afad709e8728fcaa39/netty-transport-4.1.29.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/3.0.2/25ea2e8b0c338a877313bd4672d3fe056ea78f0d/jsr305-3.0.2.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.9.0/7c10d545325e3a6e72e06381afe469fd40eb701/jackson-annotations-2.9.0.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.9.7/4b7f0e0dc527fab032e9800ed231080fdc3ac015/jackson-core-2.9.7.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.hibernate.common/hibernate-commons-annotations/5.0.4.Final/965a18fdf939ee75e41f7918532d37b3a8350535/hibernate-commons-annotations-5.0.4.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.jboss.logging/jboss-logging/3.3.2.Final/3789d00e859632e6c6206adc0c71625559e6e3b0/jboss-logging-3.3.2.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/javax.persistence/javax.persistence-api/2.2/25665ac8c0b62f50e6488173233239120fc52c96/javax.persistence-api-2.2.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.javassist/javassist/3.23.1-GA/c072c13dcb7f705471c40bafb1536171df850ab2/javassist-3.23.1-GA.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/net.bytebuddy/byte-buddy/1.8.17/9a36bc0f6eb9f941da0526ad89c4fb4b8ab580f0/byte-buddy-1.8.17.jar:/Users/saw303/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.jboss.spec.javax.transaction/jboss-transaction-api_1.2_spec/1.1.1.Final/a8485cab9484dda36e9a8c319e76b5cc18797b58/jboss-transaction-api_1.2_spec-1.1.1.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.jboss/jandex/2.0.5.Final/7060f67764565b9ee9d467e3ed0cb8a9c601b23a/jandex-2.0.5.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/com.fasterxml/classmate/1.3.4/3d5f48f10bbe4eb7bd862f10c0583be2e0053c6/classmate-1.3.4.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/javax.activation/javax.activation-api/1.2.0/85262acf3ca9816f9537ca47d5adeabaead7cb16/javax.activation-api-1.2.0.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/dom4j/dom4j/1.6.1/5d3ccc056b6f056dbf0dddfdf43894b9065a8f94/dom4j-1.6.1.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.springframework/spring-jdbc/5.0.8.RELEASE/efcf5f0ccaaa9deec2d9133c9d6bfbb7e55370ff/spring-jdbc-5.0.8.RELEASE.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.springframework/spring-tx/5.0.8.RELEASE/b6488db6192f71bd682a13b9d42127307631c616/spring-tx-5.0.8.RELEASE.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/5.0.8.RELEASE/3a067d8990761111c9b6d1d895640be26cc1fb38/spring-context-5.0.8.RELEASE.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.springframework/spring-aop/5.0.8.RELEASE/f5086c1a3185c481104511837427b39a07a57aa2/spring-aop-5.0.8.RELEASE.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/5.0.8.RELEASE/5fc965d3e7f5515099244857a8ae9e2a208c169b/spring-beans-5.0.8.RELEASE.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.springframework/spring-expression/5.0.8.RELEASE/f23158f22c917df2cddf2ecebc398a9e95f95fae/spring-expression-5.0.8.RELEASE.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.0.8.RELEASE/dc39c49e3246cdf73d3786ac41119140aed3fa08/spring-core-5.0.8.RELEASE.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.glassfish/javax.el/3.0.1-b08/8fa39d3901fc6ec8c0fff4ad4e48c26c4911c422/javax.el-3.0.1-b08.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.netty/netty-buffer/4.1.29.Final/c3809f72e4b535b343b7dfa3c0c8210dad2fa5ea/netty-buffer-4.1.29.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.netty/netty-resolver/4.1.29.Final/bbec1dc913732e4773893c14d795b15d6c1e878e/netty-resolver-4.1.29.Final.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/org.springframework/spring-jcl/5.0.8.RELEASE/a1fa8fb560fb252321776e16bc9ac8201af4ef5e/spring-jcl-5.0.8.RELEASE.jar:/Users/saw303/.gradle/caches/modules-2/files-2.1/io.netty/netty-common/4.1.29.Final/a5d6a735ed07d8f197daa48db7f097cfc971ee5e/netty-common-4.1.29.Final.jar sillynaut.Application
Exception in thread "main" java.lang.NoClassDefFoundError: io/micronaut/context/ApplicationContextBuilder
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at sillynaut.Application.main(Application.java:8)
Caused by: java.lang.ClassNotFoundException: io.micronaut.context.ApplicationContextBuilder
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 13 more

Running it with from the console using ./gradlew run works fine.

This is the content of build.gradle:

plugins {
    id "io.spring.dependency-management" version "1.0.6.RELEASE"
    id "com.github.johnrengelman.shadow" version "4.0.0"
    id "net.ltgt.apt-eclipse" version "0.18"
    id "net.ltgt.apt-idea" version "0.18"
    id "com.google.cloud.tools.jib" version "0.9.9" 
}

apply plugin:"application"
apply plugin:"java"
apply plugin:"groovy"

version "0.1"
group "sillynaut"

repositories {
    mavenLocal()
    mavenCentral()
    maven { url "https://jcenter.bintray.com" }
}

dependencyManagement {
    imports {
        mavenBom 'io.micronaut:bom:1.0.0.RC1'
    }
}

dependencies {
    annotationProcessor "io.micronaut:inject-java"
    annotationProcessor "io.micronaut:validation"
    annotationProcessor "javax.persistence:javax.persistence-api:2.2"
    implementation "io.micronaut:http-client"
    implementation "io.micronaut:inject"
    implementation "io.micronaut:validation"
    implementation "io.micronaut:runtime"
    implementation "io.micronaut.configuration:jdbc-hikari"
    implementation "io.micronaut.configuration:hibernate-jpa"
    implementation "io.micronaut:http-server-netty"
    implementation "javax.annotation:javax.annotation-api:1.3.2"
    compileOnly "io.micronaut:inject-java"
    runtimeOnly "ch.qos.logback:logback-classic:1.2.3"

    testImplementation("org.spockframework:spock-core:1.2-groovy-2.4") {
        exclude group: "org.codehaus.groovy", module: "groovy-all"
    }
    testImplementation "io.micronaut:inject-groovy"
    testImplementation "junit:junit:4.12"
    testImplementation "io.micronaut:inject-java"
    testImplementation "org.hamcrest:hamcrest-all:1.3"

    runtime 'org.mariadb.jdbc:mariadb-java-client:2.2.5'
}

shadowJar {
    mergeServiceFiles()
}

run.jvmArgs('-noverify', '-XX:TieredStopAtLevel=1')

mainClassName = "sillynaut.Application"
compileJava.options.compilerArgs += '-parameters'
compileTestJava.options.compilerArgs += '-parameters'
jib.to.image = 'gcr.io/sillynaut/jib-image'

I managed to workaround the issue by changing the dependency scope of io.micronaut:inject from implementation to compile. But I was wondering why the CLI generates dependencies using scope of Gradles java-library plugin but only applies the Gradle java plugin.

Since IntelliJ is usually very good in setting the dependency scopes I was wondering if this is a bug. Can anyone confirm or explain this?

Task List

  • [x] Steps to reproduce provided
  • [x] Stacktrace (if present) provided
  • [x] Example that reproduces the problem uploaded to Github
  • [x] Full description of the issue provided (see below)

Steps to Reproduce

See description above

Expected Behaviour

IntelliJ can run Application without modifying the build.gradle

Actual Behaviour

Need to modiy build.gradle

Environment Information

  • Operating System: macOS 10.14
  • Micronaut Version: 1.0.0 RC1
  • JDK Version: JDK 8

Example Application

https://github.com/saw303/sillynaut

Find my modification at https://github.com/saw303/sillynaut/blob/master/build.gradle#L31

Most helpful comment

I encountered this exact issue and how I resolved it was by the following:

Click "Edit Configuration" in the run toolbar where you normally run the Application.

In the popup window for "Run/Debug Configurations" look for "Use classpath of module:". Right below that, you'll see a check box that reads Include dependencies with "Provided scope. If you check that box, it should run normally.

I discovered this by inspecting the the command Intellij runs and noticed that the class in question, ApplicationContextBuilder, was located in io.micronaut:micronaut-inject which is not included in the classpath of the command executed.

If you can confirm this, we could look at updating the documentation to include this so others don't encountered this problem.

All 11 comments

I ran into the same issue when creating a groovy project
mn create-app hello-groovy -l groovy
which creates the following dependencies

dependencies {
    implementation "io.micronaut:runtime-groovy"
    implementation "io.micronaut:validation"
    implementation "io.micronaut:http-client"
    implementation "io.micronaut:http-server-netty"
    compileOnly "io.micronaut:inject-groovy"
    runtimeOnly "ch.qos.logback:logback-classic:1.2.3"
    testImplementation "io.micronaut:inject-groovy"
    testImplementation("org.spockframework:spock-core:1.2-groovy-2.4") {
        exclude group: "org.codehaus.groovy", module: "groovy-all"
    }
}

If I change the "io.micronaut:inject-groovy" from compileOnly to compile it works just fine.

with a simple java application
mn create-app hello-java
I do not get the issue.

dependencies {
    annotationProcessor "io.micronaut:inject-java"
    annotationProcessor "io.micronaut:validation"
    implementation "io.micronaut:inject"
    implementation "io.micronaut:validation"
    implementation "io.micronaut:runtime"
    implementation "io.micronaut:http-client"
    implementation "io.micronaut:http-server-netty"
    compileOnly "io.micronaut:inject-java"
    runtimeOnly "ch.qos.logback:logback-classic:1.2.3"
    testImplementation "junit:junit:4.12"
    testImplementation "io.micronaut:inject-java"
    testImplementation "org.hamcrest:hamcrest-all:1.3"
}

Environment Info
OS Windows 10
Micronaut Version Rc1
JDK Version 8
Intellij 2018.2.4

Seems Gradle updated the scopes without the IDE support catching up, we will go back to compile, testCompile and runtime until these issues are resolved

I see the correct JARs listed under "External Libraries". I don't think this is an issue with resolving the dependencies per se with the "new" Gradle configurations.

You can work around the issue by enabling "Delegate IDE build/run actions to gradle" under Preferences... > Build, Execution, Deployment > Gradle > Runner.

@bmuschko That is not a great solution, running tests via Gradle is slower and less productive than running them via the IDE.

I do wish Gradle considered IDE support more closely when making changes, this combined with https://github.com/gradle/gradle/issues/6227 are very painful

@graemerocher I do agree that the solution is not great and would require explicit documentation (which is easily missed by users). Thanks for your feedback!

ran into that issue in 1.0.1, 1.0.3

I encountered this exact issue and how I resolved it was by the following:

Click "Edit Configuration" in the run toolbar where you normally run the Application.

In the popup window for "Run/Debug Configurations" look for "Use classpath of module:". Right below that, you'll see a check box that reads Include dependencies with "Provided scope. If you check that box, it should run normally.

I discovered this by inspecting the the command Intellij runs and noticed that the class in question, ApplicationContextBuilder, was located in io.micronaut:micronaut-inject which is not included in the classpath of the command executed.

If you can confirm this, we could look at updating the documentation to include this so others don't encountered this problem.

Had the same issue. I can confirm rburton's solution works.

I encountered this exact issue and how I resolved it was by the following:

Click "Edit Configuration" in the run toolbar where you normally run the Application.

In the popup window for "Run/Debug Configurations" look for "Use classpath of module:". Right below that, you'll see a check box that reads Include dependencies with "Provided scope. If you check that box, it should run normally.

I discovered this by inspecting the the command Intellij runs and noticed that the class in question, ApplicationContextBuilder, was located in io.micronaut:micronaut-inject which is not included in the classpath of the command executed.

If you can confirm this, we could look at updating the documentation to include this so others don't encountered this problem.

Gracias estimado amigo.

For me, this did not solve the problem, unfortunately.

I ran into the same issue when creating a groovy project
mn create-app hello-groovy -l groovy
which creates the following dependencies

dependencies {
    implementation "io.micronaut:runtime-groovy"
    implementation "io.micronaut:validation"
    implementation "io.micronaut:http-client"
    implementation "io.micronaut:http-server-netty"
    compileOnly "io.micronaut:inject-groovy"
    runtimeOnly "ch.qos.logback:logback-classic:1.2.3"
    testImplementation "io.micronaut:inject-groovy"
    testImplementation("org.spockframework:spock-core:1.2-groovy-2.4") {
        exclude group: "org.codehaus.groovy", module: "groovy-all"
    }
}

If I change the "io.micronaut:inject-groovy" from compileOnly to compile it works just fine.

with a simple java application
mn create-app hello-java
I do not get the issue.

dependencies {
    annotationProcessor "io.micronaut:inject-java"
    annotationProcessor "io.micronaut:validation"
    implementation "io.micronaut:inject"
    implementation "io.micronaut:validation"
    implementation "io.micronaut:runtime"
    implementation "io.micronaut:http-client"
    implementation "io.micronaut:http-server-netty"
    compileOnly "io.micronaut:inject-java"
    runtimeOnly "ch.qos.logback:logback-classic:1.2.3"
    testImplementation "junit:junit:4.12"
    testImplementation "io.micronaut:inject-java"
    testImplementation "org.hamcrest:hamcrest-all:1.3"
}

Environment Info
OS Windows 10
Micronaut Version Rc1
JDK Version 8
Intellij 2018.2.4

Worked for me

Was this page helpful?
0 / 5 - 0 ratings