Spring Boot web application running on Google App

2019-04-30 18:32发布

问题:

When I execute gradlew appengineRun, I consistently get:

Starting a Gradle Daemon (subsequent builds will be faster)
Mar 26, 2018 5:47:48 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
2018-03-26 17:47:51.665:INFO::main: Logging initialized @3872ms
2018-03-26 17:47:53.727:INFO:oejs.Server:main: jetty-9.3.18.v20170406
2018-03-26 17:48:01.040:WARN:oeja.ClassInheritanceHandler:qtp99347477-18:
java.lang.NullPointerException
    at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
    at org.eclipse.jetty.annotations.ClassInheritanceHandler.addToInheritanceMap(ClassInheritanceHandler.java:72)
    at org.eclipse.jetty.annotations.ClassInheritanceHandler.handle(ClassInheritanceHandler.java:58)
    at org.eclipse.jetty.annotations.AnnotationParser$MyClassVisitor.visit(AnnotationParser.java:476)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:650)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:525)
    at org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:978)
    at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.java:958)
    at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:902)
    at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:851)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:163)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:546)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
    at java.lang.Thread.run(Thread.java:745)
2018-03-26 17:48:01.087:WARN:oeja.ClassInheritanceHandler:qtp99347477-19:
java.lang.NullPointerException
    at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
    at org.eclipse.jetty.annotations.ClassInheritanceHandler.addToInheritanceMap(ClassInheritanceHandler.java:72)
    at org.eclipse.jetty.annotations.ClassInheritanceHandler.handle(ClassInheritanceHandler.java:58)
    at org.eclipse.jetty.annotations.AnnotationParser$MyClassVisitor.visit(AnnotationParser.java:476)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:650)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:525)
    at org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:978)
    at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.java:958)
    at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:902)
    at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:851)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:163)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:546)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
    at java.lang.Thread.run(Thread.java:745)
2018-03-26 17:48:01.103:WARN:oeja.ClassInheritanceHandler:qtp99347477-12:
java.lang.NullPointerException

I have a Windows 7 host. The same program runs fine with gradlew bootRun. I am not using a web.xml. But my build.gradle is along the lines of https://cloud.google.com/appengine/docs/standard/java/tools/gradle. I am not running through eclipse (similar problem is reported here: mvn appengine:run - error 403 (spring boot web with jsp)). springBootVersion = '2.0.0.BUILD-SNAPSHOT'

build.gradle:

buildscript {
    ext {
        springBootVersion = '2.0.0.BUILD-SNAPSHOT'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath 'com.google.cloud.tools:appengine-gradle-plugin:+'    // latest App Engine Gradle tasks
    }
}

apply plugin: 'java'                              // standard Java tasks
apply plugin: 'war'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.google.cloud.tools.appengine'  // App Engine tasks

ext['thymeleaf.version'] = '3.0.9.RELEASE'

compileJava {
    options.warnings = true
    options.debug = true
    options.compilerArgs += ["-Xlint:deprecation"]
}

sourceSets {
    main {
        java {
            exclude '**/RedirectHttpToHttpsOnTomcatConfig.java'
            exclude '**/RedirectHttpToHttpsOnJettyConfig.java'
            exclude '**/RedirectHttpToHttpsOnJetty2Config.java'
            exclude '**/RedirectHttpToHttpsOnJetty3Config.java'
            exclude '**/RedirectHttpToHttpsOnJetty4Config.java'
       }
   }
}

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}

dependencies {
    compile 'com.google.appengine:appengine-api-1.0-sdk:+'  // Latest App Engine Api's
    providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
    compile 'jstl:jstl:1.2'

    compile('org.springframework.boot:spring-boot-starter-thymeleaf')
    compile("org.springframework.boot:spring-boot-starter-web") {
        exclude module: "spring-boot-starter-tomcat"
    }
    compile("org.springframework.boot:spring-boot-starter-jetty")
    compile('org.springframework.boot:spring-boot-starter-actuator')
    compile('org.springframework.boot:spring-boot-starter-security')
    compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity4')
    compile("org.springframework.boot:spring-boot-starter-jdbc") {
        exclude module: "org.apache.tomcat:tomcat-juli"
    }
    compile("org.springframework.boot:spring-boot-starter-data-jpa") {
        exclude module: "org.apache.tomcat:tomcat-juli"
    }
    compile("com.h2database:h2")
    providedRuntime 'org.slf4j:jul-to-slf4j'
}

configurations {
    compile.exclude module: 'spring-boot-starter-tomcat'
    runtime.exclude module: 'spring-boot-starter-tomcat'
}

appengine {  // App Engine tasks configuration
  deploy {   // deploy configuration

  }
}

sourceCompatibility = 1.8     // App Engine Flexible uses Java 8
targetCompatibility = 1.8     // App Engine Flexible uses Java 8

回答1:

The issue is being tracked upstream by https://issuetracker.google.com/issues/65200034. Please star that issue to receive updates.

Details

We believe your issue is https://github.com/eclipse/jetty.project/issues/1892. https://issuetracker.google.com/issues/65200034 was originally about https://github.com/eclipse/jetty.project/issues/1692, but it has expanded to cover your issue too.