appengineDeploy 后 com.google.api.Service.hasQuota 的 NoSuchMethodError
NoSuchMethodError for com.google.api.Service.hasQuota after appengineDeploy
在部署我的 Google 端点 API 之后,即使我只点击服务器 url / 或 /_ah/warmup
我也会收到以下错误
Uncaught exception from servlet
java.lang.NoSuchMethodError: com.google.api.Service.hasQuota()Z
at com.google.api.control.model.MethodRegistry.extractQuota(MethodRegistry.java:290)
at com.google.api.control.model.MethodRegistry.<init>(MethodRegistry.java:72)
at com.google.api.control.ConfigFilter.init(ConfigFilter.java:89)
疯狂的是这种情况会间歇性发生。有时部署只是工作,但大多数时候它会失败。
这在 3 月 1 日之前一直运行良好,所以我也回滚了 gcloud 组件版本,但仍然遇到相同的错误。
如果应用引擎和端点库已尝试升级到最新版本,但仍然出现以下错误。
编辑-1
这里是build.gradle供参考
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
// App Engine Gradle plugin
classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.1'
// Endpoints Frameworks Gradle plugin
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:2.1.0'
}
}
// Dev
def projectIdValue = 'dev-sample-api'
repositories {
mavenCentral()
jcenter()
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceSets {
main {
java {
srcDirs 'src/main/java'
}
}
}
dependencies {
// App Engine API
implementation group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: '1.9.86'
// Endpoints Frameworks v2.0
implementation ('com.google.endpoints:endpoints-framework:2.2.2') {
exclude group: 'org.slf4j', module: 'slf4j-nop'
}
implementation group: 'com.google.endpoints', name: 'endpoints-management-control-appengine', version: '1.0.14'
implementation group: 'com.google.endpoints', name: 'endpoints-framework-auth', version: '1.0.14'
implementation group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.15.6'
implementation group: 'io.grpc', name: 'grpc-stub', version: '1.36.0'
implementation group: 'io.grpc', name: 'grpc-protobuf', version: '1.36.0'
// App Engine and Endpoint dependencies
compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
implementation 'jstl:jstl:1.2'
implementation group: 'javax.inject', name: 'javax.inject', version: '1'
// Logging
implementation 'org.slf4j:slf4j-api:1.7.30'
implementation 'org.slf4j:slf4j-jdk14:1.7.30'
// Objectify for data storage and access
implementation 'com.googlecode.objectify:objectify:5.1.9'
// Common Utils and Libraries
implementation 'com.google.guava:guava:20.0'
implementation 'commons-validator:commons-validator:1.6'
implementation 'joda-time:joda-time:2.10.8'
implementation group: 'com.darwinsys', name: 'hirondelle-date4j', version: '1.5.1'
}
endpointsServer {
// Endpoints Framework Plugin server-side configuration
hostname = "${projectIdValue}.appspot.com"
}
// this replaces the ${endpoints.project.id} in appengine-web.xml and web.xml
task replaceProjectId(type: Copy) {
from 'src/main/webapp/WEB-INF/'
include '*.xml'
into "build/exploded-${archivesBaseName}/WEB-INF"
expand(endpoints:[project:[id:projectIdValue]])
filteringCharset = 'UTF-8'
}
assemble.dependsOn replaceProjectId
appengine {
deploy { // deploy configuration
version = "GCLOUD_CONFIG"
projectId = "GCLOUD_CONFIG"
def promoteProp = findProperty("appengine.deploy.promote")
if (promoteProp != null) {
promote = new Boolean(promoteProp)
}
}
run {
host = "0.0.0.0"
port = 8080
}
}
根据@RafaelLemos 的建议关闭它。
“这可能是某些组件的旧版本问题”
不可重现。可能的修复
gcloud components update
仅作记录 - 正确的命令行应该是:
gcloud components update
在部署我的 Google 端点 API 之后,即使我只点击服务器 url / 或 /_ah/warmup
我也会收到以下错误Uncaught exception from servlet
java.lang.NoSuchMethodError: com.google.api.Service.hasQuota()Z
at com.google.api.control.model.MethodRegistry.extractQuota(MethodRegistry.java:290)
at com.google.api.control.model.MethodRegistry.<init>(MethodRegistry.java:72)
at com.google.api.control.ConfigFilter.init(ConfigFilter.java:89)
疯狂的是这种情况会间歇性发生。有时部署只是工作,但大多数时候它会失败。
这在 3 月 1 日之前一直运行良好,所以我也回滚了 gcloud 组件版本,但仍然遇到相同的错误。
如果应用引擎和端点库已尝试升级到最新版本,但仍然出现以下错误。
编辑-1
这里是build.gradle供参考
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
// App Engine Gradle plugin
classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.1'
// Endpoints Frameworks Gradle plugin
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:2.1.0'
}
}
// Dev
def projectIdValue = 'dev-sample-api'
repositories {
mavenCentral()
jcenter()
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceSets {
main {
java {
srcDirs 'src/main/java'
}
}
}
dependencies {
// App Engine API
implementation group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: '1.9.86'
// Endpoints Frameworks v2.0
implementation ('com.google.endpoints:endpoints-framework:2.2.2') {
exclude group: 'org.slf4j', module: 'slf4j-nop'
}
implementation group: 'com.google.endpoints', name: 'endpoints-management-control-appengine', version: '1.0.14'
implementation group: 'com.google.endpoints', name: 'endpoints-framework-auth', version: '1.0.14'
implementation group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.15.6'
implementation group: 'io.grpc', name: 'grpc-stub', version: '1.36.0'
implementation group: 'io.grpc', name: 'grpc-protobuf', version: '1.36.0'
// App Engine and Endpoint dependencies
compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
implementation 'jstl:jstl:1.2'
implementation group: 'javax.inject', name: 'javax.inject', version: '1'
// Logging
implementation 'org.slf4j:slf4j-api:1.7.30'
implementation 'org.slf4j:slf4j-jdk14:1.7.30'
// Objectify for data storage and access
implementation 'com.googlecode.objectify:objectify:5.1.9'
// Common Utils and Libraries
implementation 'com.google.guava:guava:20.0'
implementation 'commons-validator:commons-validator:1.6'
implementation 'joda-time:joda-time:2.10.8'
implementation group: 'com.darwinsys', name: 'hirondelle-date4j', version: '1.5.1'
}
endpointsServer {
// Endpoints Framework Plugin server-side configuration
hostname = "${projectIdValue}.appspot.com"
}
// this replaces the ${endpoints.project.id} in appengine-web.xml and web.xml
task replaceProjectId(type: Copy) {
from 'src/main/webapp/WEB-INF/'
include '*.xml'
into "build/exploded-${archivesBaseName}/WEB-INF"
expand(endpoints:[project:[id:projectIdValue]])
filteringCharset = 'UTF-8'
}
assemble.dependsOn replaceProjectId
appengine {
deploy { // deploy configuration
version = "GCLOUD_CONFIG"
projectId = "GCLOUD_CONFIG"
def promoteProp = findProperty("appengine.deploy.promote")
if (promoteProp != null) {
promote = new Boolean(promoteProp)
}
}
run {
host = "0.0.0.0"
port = 8080
}
}
根据@RafaelLemos 的建议关闭它。
“这可能是某些组件的旧版本问题”
不可重现。可能的修复
gcloud components update
仅作记录 - 正确的命令行应该是:
gcloud components update