GoogleCloudPlatform / gradle-appengine-plugin

Gradle plugin that provides tasks for uploading, running and managing Google App Engine projects
Apache License 2.0
236 stars 60 forks source link

appengineDeploy works but appenginRun fails #294

Closed fixako closed 5 years ago

fixako commented 7 years ago

I tried to rewrite this https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/appengine-standard-java8/springboot-appengine-standard simple spring boot app to use gradle instead of maven.

The gradle bootRun and appengineDeploy works fine but appengineRun FAILS with:

java.lang.IllegalArgumentException: Unable to find the main class to restart
    at org.springframework.util.Assert.notNull(Assert.java:134)
    at org.springframework.boot.devtools.restart.Restarter.doStart(Restarter.java:285)
    at org.springframework.boot.devtools.restart.Restarter.start(Restarter.java:273)
    at org.springframework.boot.devtools.restart.Restarter$1.call(Restarter.java:174)
    at org.springframework.boot.devtools.restart.Restarter$1.call(Restarter.java:170)
    at org.springframework.boot.devtools.restart.Restarter$LeakSafeThread.run(Restarter.java:627)
error.

My gradle.build:

buildscript {
    repositories {
        jcenter()    // Bintray's repository - a fast Maven Central mirror & more
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:+")
        classpath 'com.google.cloud.tools:appengine-gradle-plugin:+'
    }
}

repositories {
    maven {
        url 'https://maven-central.storage.googleapis.com'            // Google's mirror of Maven Central
    }
    jcenter()
    mavenCentral()
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'org.springframework.boot'

bootRepackage {
    enabled = false
}

configurations {
    compile.exclude module: "spring-boot-starter-tomcat"
    compile.exclude module: "spring-boot-starter-jetty"
}

dependencies {

    providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
    compile 'com.google.appengine:appengine:+'

    // Use JUnit test framework
    testImplementation 'junit:junit:4.12'

    compile("org.springframework.boot:spring-boot-devtools")
    compile("org.springframework.boot:spring-boot-starter-web")
}

appengine {  // App Engine tasks configuration
  run {      // local (dev_appserver) configuration (standard environments only)
    port = 8080                 // default
  }

  deploy {   // deploy configuration
    stopPreviousVersion = true  // default - stop the current version
    promote = true              // default - & make this the current version
  }
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

The working pom.xml: https://github.com/GoogleCloudPlatform/getting-started-java/blob/master/appengine-standard-java8/springboot-appengine-standard/pom.xml

I found a solution: Removing the compile("org.springframework.boot:spring-boot-devtools") dependency solves the issue. I guess I would get the same error if I use that dependency with maven. Is this a bug in appengineRun or that dependency should not be used with appengine?

loosebazooka commented 6 years ago

It looks like you missed a step in the instructions of the getting started guide where it asks you to exclude the spring-boot-starter dependency : https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/appengine-standard-java8/springboot-appengine-standard#remove-tomcat-starter

What it appears you need to do here is mimic that behavior in gradle (I have not tested this) by editing your build.gradle dependencies with something like this

dependencies {
  ...
  compile("org.springframework.boot:spring-boot-starter-web") {
    exclude group: "org.springframework.boot", module: "spring-boot-starter-tomcat"
  }
zevt commented 6 years ago

I have the same issue with Maven spring-boot-devtools dependency. App Engine dev server doesn't run on local machine and throw the same error. java.lang.IllegalArgumentException: Unable to find the main class to restart at org.springframework.util.Assert.notNull(Assert.java:193) at org.springframework.boot.devtools.restart.Restarter.doStart(Restarter.java:275) at org.springframework.boot.devtools.restart.Restarter.start(Restarter.java:263) at org.springframework.boot.devtools.restart.Restarter.lambda$immediateRestart$0(Restarter.java:171) at org.springframework.boot.devtools.restart.Restarter$LeakSafeThread.run(Restarter.java:632)

Removing devtools dependency it will work but we will miss the hotswap feature of devtools.

amrfaissal commented 5 years ago

Any updates on this issue?

loosebazooka commented 5 years ago

This plugin is not being updated anymore and we recommend using the current CloudSDK based plugin. But AFAIK devtools is not compatible with the appengine dev server.