Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle Task :bootRun fails: Error: Could not find or load main class #115

Closed
eeriksp opened this issue May 4, 2019 · 5 comments
Closed

Comments

@eeriksp
Copy link

eeriksp commented May 4, 2019

When running ./gradlew on Windows 10 using JHipster 6.0.0-beta.0 for a newly created project, the script fails:

> Task :bootRun FAILED
Error: Could not find or load main class ...

FAILURE: Build failed with an exception.

When looking at the bootRun task:

    bootRun {
        dependsOn classpathJar
        doFirst {
            classpath = files("$buildDir/classes/java/main", "$buildDir/resources/main", classpathJar.archivePath)
        }
    }

it seems that the Kotlin directory is not included. I tried to add "$buildDir/classes/kotlin/main" at the beginning of the classpath, but although the needed class is clearly there, it made no difference.

Note that ./gradlew bootJar produces a functional .jar file and running it with java -jar build/libs/appname-0.0.1-SNAPSHOT.jar works.

[ x ] Checking this box is mandatory (this is just to show you read everything)

@sendilkumarn
Copy link
Member

sendilkumarn commented May 4, 2019

and are you using Java 8 or any other version?

Is it because of Windows path issue?

@eeriksp
Copy link
Author

eeriksp commented May 4, 2019

Yes, I am using Java 8 in Windows. I am not sure what you mean by Windows path issue.

Note that ./gradlew bootJar produces a functional JAR file and running it with java -jar build/libs/appname-0.0.1-SNAPSHOT.jar works.

@pvliss
Copy link
Contributor

pvliss commented May 6, 2019

@eeriksp I think you have hit the same issue as jhipster/generator-jhipster#9572. This has been fixed in JHipster 6.0.0 final release. Can you please try and remove the whole block stating with if (OperatingSystem.current().isWindows()) { and let us know if that works. See also here ) for reference.

NOTE: We should also remove the respective block from kotlin.gradle.ejs as well:

if (OperatingSystem.current().isWindows()) {
bootRun {
doFirst {
classpath += files("$buildDir/classes/kotlin/main")
}
}

@eeriksp
Copy link
Author

eeriksp commented May 6, 2019

Thank you!
This solved the problem :)

@eeriksp eeriksp closed this as completed May 6, 2019
@pvliss
Copy link
Contributor

pvliss commented May 6, 2019

@eeriksp Glad it did and thanks for reporting back!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants