Skip to content

Cannot Kotlin bootRun on Windows due to long paths / No auto configuration classes found in META-INF/spring.factories #14262

@psyanite

Description

@psyanite

When I run bootRun on Microsoft Windows [Version 10.0.17134.228], it throws the error 'CreateProcess error=206' when classpath too long on the cp, but I am able to start the application with no issues, if I run java -jar meow.jar on the jar produced by bootJar.

I have tried to enable long paths via the Enable NTFS long paths option and also in REGEDIT, and then restart my machine, but no luck.

This is a common issue with typical Java projects with bootRun for a long time as seen in this github issue

So I decided to write my custom bootRun like in this github issue but have encountered another issue.

My build.gradle:

Gradle version: gradle-4.5.1-all.zip

buildscript {
    ext {
        kotlinVersion = '1.2.51'
        springBootVersion = '2.0.3.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
        classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
        classpath("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
        classpath('gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.13.0')
    }
}

plugins {
    id "org.jlleitschuh.gradle.ktlint" version "4.1.0"
}

apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'kotlin-kapt'


group = 'com.meow'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
compileKotlin {
    kotlinOptions {
        freeCompilerArgs = ["-Xjsr305=strict"]
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        freeCompilerArgs = ["-Xjsr305=strict"]
        jvmTarget = "1.8"
    }
}

repositories {
    mavenCentral()
    jcenter()
}


dependencies {
    compile 'org.springframework.boot:spring-boot-starter-web'
    compile 'org.springframework.security:spring-security-web'
    compile 'org.springframework.security:spring-security-config'
    compile 'org.springframework.security:spring-security-core'
    compile 'org.springframework.security:spring-security-test'
    compile 'org.springframework.data:spring-data-redis'
    compile 'com.fasterxml.jackson.module:jackson-module-kotlin'
    compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
    compile 'org.jetbrains.kotlin:kotlin-reflect'
    compile 'com.github.kittinunf.fuel:fuel:1.13.0'
    compile 'io.github.microutils:kotlin-logging:1.5.4'
    compile 'redis.clients:jedis'
    compile 'org.apache.poi:poi-ooxml:3.16'
    compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.+"
    compile "javax.xml.bind:jaxb-api"
    compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.390'


    runtime 'org.springframework.boot:spring-boot-devtools'

    testCompile 'org.springframework.boot:spring-boot-starter-test'
}

ktlint {
    verbose = true
    // For now have to be uppercase, see https://github.com/gradle/gradle/issues/4030
    reporters = ["CHECKSTYLE", "PLAIN"]
}

apply plugin: 'com.palantir.docker'

group = 'meow'

springBoot {
    mainClassName = 'com.meow.ApplicationKt'
}

docker {
    dependsOn build
    name "${project.group}/${bootJar.baseName}"
    files bootJar.archivePath
    buildArgs(['JAR_FILE': "${bootJar.archiveName}"])
}

task pathingJar(type: Jar) {
    dependsOn configurations.runtime
    appendix = 'pathing'
    zip64 true
    doFirst {
        manifest {
            attributes "Class-Path": configurations.runtime.files.collect {
                it.toURL().toString().replaceFirst('/file:/+/', '/')
            }.join(' ')
        }
    }
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin/'
    test.java.srcDirs += 'src/test/kotlin/'
}

bootRun {
    dependsOn pathingJar
    main = 'com.meow.ApplicationKt'
    sourceResources sourceSets.main
    doFirst {
        classpath = files(sourceSets.main.output.files, pathingJar.archivePath)
    }
}

Error thrown:

Aug. 31, 2018 1:13:03 PM com.meow.ApplicationKt logStarting
INFO: Starting ApplicationKt on CREAMPUFF with PID 13120 (C:\Neila\Projects\meow\fan\build\classes\kotlin\main started by Sam Xia in C:\Neila\Projects\meow\fan)
Aug. 31, 2018 1:13:03 PM com.meow.ApplicationKt logStartupProfileInfo
INFO: No active profile set, falling back to default profiles: default
Aug. 31, 2018 1:13:03 PM org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext prepareRefresh
INFO: Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7c6908d7: startup date [Fri Aug 31 13:13:03 AEST 2018]; root of context hierarchy
Aug. 31, 2018 1:13:04 PM org.springframework.boot.SpringApplication reportFailure
SEVERE: Application run failed
java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
        at org.springframework.util.Assert.notEmpty(Assert.java:450)
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:160)
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.selectImports(AutoConfigurationImportSelector.java:96)
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:386)
        at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:830)
        at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:563)
        at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:188)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
        at com.meow.ApplicationKt.main(Application.kt:13)

Aug. 31, 2018 1:13:04 PM org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext doClose
INFO: Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7c6908d7: startup date [Fri Aug 31 13:13:03 AEST 2018]; root of context hierarchy
:bootRun FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command 'C:\Program Files\Java\jdk-10.0.1\bin\java.exe'' finished with non-zero exit value 1

My friend who runs bootRun do not have spring.factories in his jar, I assume this is supposed to be supplied by the plugin?

I have tried ./gradlew clean before I run every ./gradlew bootRun

Thank you for taking the time to read my issue and any help will be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions