【问题标题】:Unable to use Flyway migrations with Google Cloud SQL and Maven无法通过 Google Cloud SQL 和 Maven 使用 Flyway 迁移
【发布时间】:2017-11-24 18:21:22
【问题描述】:

我只是尝试使用 maven、flyway 和 Google Cloud SQL 设置一个简单的 Hello World 概念验证。有关我正在使用的完整代码,请参阅 https://github.com/creyes17/mvn-flyway-cloudsql-test。 (问题发布在提交3b7bfa8e)。

每当我运行mvn flyway:migrate 时,无论我从哪个机器运行它,我都会收到以下错误:

[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:4.0.2:migrate (default-cli) on project mvn-flyway-cloudsql-test: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call rdbms.OpenConnection in a thread that is neither the original request thread nor a thread created by ThreadManager -> [Help 1]

这是我的 pom.xml:

<!--
    mvn-flyway-cloudsql-test is an example of how to set up a Maven/Flyway/Google CloudSQL integration.
    Copyright (C) 2017  Christopher R. Reyes

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>reyes.r.christopher</groupId>
  <artifactId>mvn-flyway-cloudsql-test</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>mvn-flyway-cloudsql-test</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>6.0.6</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-1.0-sdk</artifactId>
        <version>1.9.54</version>
    </dependency>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
        <version>4.0</version>
    </dependency>
  </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <version>4.0.2</version>
                <configuration>
                    <!-- 
                         Normally, I would specify these in a flyway.properties file. 
                         Since I don't want to check in my actual instance address, username, and password to a public git repository, I'll do this instead.
                    -->
                    <url>jdbc:google:rdbms://${instance}:3306/hello_world?serverTimezone=UTC&amp;useSSL=true&amp;verifyServerCertificate=true&amp;requireSSL=true</url>
                    <user>${user}</user>
                    <password>${password}</password>
                    <driver>com.google.appengine.api.rdbms.AppEngineDriver</driver>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

下面是运行mvn -X flyway:migrate -Dinstance=$instance -Duser=$user -Dpassword=$password的完整输出

Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T12:39:06-07:00)
Maven home: /usr/local/Cellar/maven/3.5.0/libexec
Java version: 1.8.0_77, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.5", arch: "x86_64", family: "mac"
[DEBUG] Created new class realm maven.api
[DEBUG] Importing foreign packages into class realm maven.api
[DEBUG]   Imported: javax.enterprise.inject.* < plexus.core
[DEBUG]   Imported: javax.enterprise.util.* < plexus.core
[DEBUG]   Imported: javax.inject.* < plexus.core
[DEBUG]   Imported: org.apache.maven.* < plexus.core
[DEBUG]   Imported: org.apache.maven.artifact < plexus.core
[DEBUG]   Imported: org.apache.maven.classrealm < plexus.core
[DEBUG]   Imported: org.apache.maven.cli < plexus.core
[DEBUG]   Imported: org.apache.maven.configuration < plexus.core
[DEBUG]   Imported: org.apache.maven.exception < plexus.core
[DEBUG]   Imported: org.apache.maven.execution < plexus.core
[DEBUG]   Imported: org.apache.maven.execution.scope < plexus.core
[DEBUG]   Imported: org.apache.maven.lifecycle < plexus.core
[DEBUG]   Imported: org.apache.maven.model < plexus.core
[DEBUG]   Imported: org.apache.maven.monitor < plexus.core
[DEBUG]   Imported: org.apache.maven.plugin < plexus.core
[DEBUG]   Imported: org.apache.maven.profiles < plexus.core
[DEBUG]   Imported: org.apache.maven.project < plexus.core
[DEBUG]   Imported: org.apache.maven.reporting < plexus.core
[DEBUG]   Imported: org.apache.maven.repository < plexus.core
[DEBUG]   Imported: org.apache.maven.rtinfo < plexus.core
[DEBUG]   Imported: org.apache.maven.settings < plexus.core
[DEBUG]   Imported: org.apache.maven.toolchain < plexus.core
[DEBUG]   Imported: org.apache.maven.usability < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.* < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.authentication < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.authorization < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.events < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.observers < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.proxy < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.repository < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.resource < plexus.core
[DEBUG]   Imported: org.codehaus.classworlds < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.* < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.classworlds < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.component < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.configuration < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.container < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.context < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.lifecycle < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.logging < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.personality < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.Xpp3Dom < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlPullParser < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlPullParserException < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlSerializer < plexus.core
[DEBUG]   Imported: org.eclipse.aether.* < plexus.core
[DEBUG]   Imported: org.eclipse.aether.artifact < plexus.core
[DEBUG]   Imported: org.eclipse.aether.collection < plexus.core
[DEBUG]   Imported: org.eclipse.aether.deployment < plexus.core
[DEBUG]   Imported: org.eclipse.aether.graph < plexus.core
[DEBUG]   Imported: org.eclipse.aether.impl < plexus.core
[DEBUG]   Imported: org.eclipse.aether.installation < plexus.core
[DEBUG]   Imported: org.eclipse.aether.internal.impl < plexus.core
[DEBUG]   Imported: org.eclipse.aether.metadata < plexus.core
[DEBUG]   Imported: org.eclipse.aether.repository < plexus.core
[DEBUG]   Imported: org.eclipse.aether.resolution < plexus.core
[DEBUG]   Imported: org.eclipse.aether.spi < plexus.core
[DEBUG]   Imported: org.eclipse.aether.transfer < plexus.core
[DEBUG]   Imported: org.eclipse.aether.version < plexus.core
[DEBUG]   Imported: org.fusesource.jansi.* < plexus.core
[DEBUG]   Imported: org.slf4j.* < plexus.core
[DEBUG]   Imported: org.slf4j.helpers.* < plexus.core
[DEBUG]   Imported: org.slf4j.spi.* < plexus.core
[DEBUG] Populating class realm maven.api
[INFO] Error stacktraces are turned on.
[DEBUG] Message scheme: color
[DEBUG] Message styles: debug info warning error success failure strong mojo project
[DEBUG] Reading global settings from /usr/local/Cellar/maven/3.5.0/libexec/conf/settings.xml
[DEBUG] Reading user settings from /Users/chris.reyes/.m2/settings.xml
[DEBUG] Reading global toolchains from /usr/local/Cellar/maven/3.5.0/libexec/conf/toolchains.xml
[DEBUG] Reading user toolchains from /Users/chris.reyes/.m2/toolchains.xml
[DEBUG] Using local repository at /Users/chris.reyes/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /Users/chris.reyes/.m2/repository
[INFO] Scanning for projects...
[DEBUG] Extension realms for project reyes.r.christopher:mvn-flyway-cloudsql-test:jar:1.0-SNAPSHOT: (none)
[DEBUG] Looking up lifecycle mappings for packaging jar from ClassRealm[plexus.core, parent: null]
[DEBUG] Resolving plugin prefix flyway from [org.apache.maven.plugins, org.codehaus.mojo]
[DEBUG] Resolved plugin prefix flyway to org.flywaydb:flyway-maven-plugin from POM reyes.r.christopher:mvn-flyway-cloudsql-test:jar:1.0-SNAPSHOT
[DEBUG] === REACTOR BUILD PLAN ================================================
[DEBUG] Project: reyes.r.christopher:mvn-flyway-cloudsql-test:jar:1.0-SNAPSHOT
[DEBUG] Tasks:   [flyway:migrate]
[DEBUG] Style:   Regular
[DEBUG] =======================================================================
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building mvn-flyway-cloudsql-test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[DEBUG] Resolving plugin prefix flyway from [org.apache.maven.plugins, org.codehaus.mojo]
[DEBUG] Resolved plugin prefix flyway to org.flywaydb:flyway-maven-plugin from POM reyes.r.christopher:mvn-flyway-cloudsql-test:jar:1.0-SNAPSHOT
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] === PROJECT BUILD PLAN ================================================
[DEBUG] Project:       reyes.r.christopher:mvn-flyway-cloudsql-test:1.0-SNAPSHOT
[DEBUG] Dependencies (collect): []
[DEBUG] Dependencies (resolve): [test]
[DEBUG] Repositories (dependencies): [central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] Repositories (plugins)     : [central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal:          org.flywaydb:flyway-maven-plugin:4.0.2:migrate (default-cli)
[DEBUG] Style:         Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <baselineDescription>${flyway.baselineDescription}</baselineDescription>
  <baselineOnMigrate>${flyway.baselineOnMigrate}</baselineOnMigrate>
  <baselineVersion>${flyway.baselineVersion}</baselineVersion>
  <cleanDisabled>${flyway.cleanDisabled}</cleanDisabled>
  <cleanOnValidationError>${flyway.cleanOnValidationError}</cleanOnValidationError>
  <configFile>${flyway.configFile}</configFile>
  <driver>com.google.appengine.api.rdbms.AppEngineDriver</driver>
  <encoding>${flyway.encoding}</encoding>
  <ignoreFailedFutureMigration>${flyway.ignoreFailedFutureMigration}</ignoreFailedFutureMigration>
  <ignoreFutureMigrations>${flyway.ignoreFutureMigrations}</ignoreFutureMigrations>
  <mavenProject>${project}</mavenProject>
  <outOfOrder>${flyway.outOfOrder}</outOfOrder>
  <password>REDACTED</password>
  <placeholderPrefix>${flyway.placeholderPrefix}</placeholderPrefix>
  <placeholderReplacement>${flyway.placeholderReplacement}</placeholderReplacement>
  <placeholderSuffix>${flyway.placeholderSuffix}</placeholderSuffix>
  <repeatableSqlMigrationPrefix>${flyway.repeatableSqlMigrationPrefix}</repeatableSqlMigrationPrefix>
  <schemas>${flyway.schemas}</schemas>
  <serverId>${flyway.serverId}</serverId>
  <settings>${settings}</settings>
  <skip>${flyway.skip}</skip>
  <skipDefaultCallbacks>${flyway.skipDefaultCallbacks}</skipDefaultCallbacks>
  <skipDefaultResolvers>${flyway.skipDefaultResolvers}</skipDefaultResolvers>
  <sqlMigrationPrefix>${flyway.sqlMigrationPrefix}</sqlMigrationPrefix>
  <sqlMigrationSeparator>${flyway.sqlMigrationSeparator}</sqlMigrationSeparator>
  <sqlMigrationSuffix>${flyway.sqlMigrationSuffix}</sqlMigrationSuffix>
  <table>${flyway.table}</table>
  <target>${flyway.target}</target>
  <url>jdbc:google:rdbms://REDACTED:3306/hello_world?serverTimezone=UTC&amp;useSSL=true&amp;verifyServerCertificate=true&amp;requireSSL=true</url>
  <user>REDACTED</user>
  <validateOnMigrate>${flyway.validateOnMigrate}</validateOnMigrate>
</configuration>
[DEBUG] =======================================================================
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=0, ConflictMarker.markTime=1, ConflictMarker.nodeCount=4, ConflictIdSorter.graphTime=0, ConflictIdSorter.topsortTime=1, ConflictIdSorter.conflictIdCount=3, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=3, ConflictResolver.conflictItemCount=3, DefaultDependencyCollector.collectTime=49, DefaultDependencyCollector.transformTime=9}
[DEBUG] reyes.r.christopher:mvn-flyway-cloudsql-test:jar:1.0-SNAPSHOT
[DEBUG]    mysql:mysql-connector-java:jar:6.0.6:compile
[DEBUG]    com.google.appengine:appengine-api-1.0-sdk:jar:1.9.54:compile
[DEBUG]    org.flywaydb:flyway-core:jar:4.0:compile
[INFO] 
[INFO] --- flyway-maven-plugin:4.0.2:migrate (default-cli) @ mvn-flyway-cloudsql-test ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=0, ConflictMarker.markTime=0, ConflictMarker.nodeCount=83, ConflictIdSorter.graphTime=1, ConflictIdSorter.topsortTime=0, ConflictIdSorter.conflictIdCount=34, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=3, ConflictResolver.conflictItemCount=76, DefaultDependencyCollector.collectTime=220, DefaultDependencyCollector.transformTime=4}
[DEBUG] org.flywaydb:flyway-maven-plugin:jar:4.0.2:
[DEBUG]    org.apache.maven:maven-plugin-api:jar:2.2.1:compile
[DEBUG]    org.apache.maven:maven-artifact:jar:2.2.1:compile
[DEBUG]    org.apache.maven:maven-project:jar:2.2.1:compile
[DEBUG]       org.apache.maven:maven-settings:jar:2.2.1:compile
[DEBUG]       org.apache.maven:maven-profile:jar:2.2.1:compile
[DEBUG]       org.apache.maven:maven-artifact-manager:jar:2.2.1:compile
[DEBUG]          backport-util-concurrent:backport-util-concurrent:jar:3.1:compile
[DEBUG]       org.apache.maven:maven-plugin-registry:jar:2.2.1:compile
[DEBUG]       org.codehaus.plexus:plexus-interpolation:jar:1.11:compile
[DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[DEBUG]          junit:junit:jar:4.11:test
[DEBUG]             org.hamcrest:hamcrest-core:jar:1.3:test
[DEBUG]    org.apache.maven:maven-model:jar:2.2.1:compile
[DEBUG]    org.apache.maven:maven-core:jar:2.2.1:compile
[DEBUG]       org.apache.maven:maven-plugin-parameter-documenter:jar:2.2.1:compile
[DEBUG]       org.slf4j:slf4j-jdk14:jar:1.7.16:runtime
[DEBUG]          org.slf4j:slf4j-api:jar:1.7.16:runtime
[DEBUG]       org.slf4j:jcl-over-slf4j:jar:1.7.16:runtime
[DEBUG]       org.apache.maven.reporting:maven-reporting-api:jar:2.2.1:compile
[DEBUG]          org.apache.maven.doxia:doxia-sink-api:jar:1.1:compile
[DEBUG]          org.apache.maven.doxia:doxia-logging-api:jar:1.1:compile
[DEBUG]       org.apache.maven:maven-repository-metadata:jar:2.2.1:compile
[DEBUG]       org.apache.maven:maven-error-diagnostics:jar:2.2.1:compile
[DEBUG]       commons-cli:commons-cli:jar:1.2:compile
[DEBUG]       org.apache.maven:maven-plugin-descriptor:jar:2.2.1:compile
[DEBUG]       org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-4:compile
[DEBUG]       org.apache.maven:maven-monitor:jar:2.2.1:compile
[DEBUG]       classworlds:classworlds:jar:1.1:compile
[DEBUG]    org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4:compile
[DEBUG]       org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[DEBUG]    org.codehaus.plexus:plexus-utils:jar:1.5.15:compile
[DEBUG]    org.flywaydb:flyway-core:jar:4.0.2:compile
[DEBUG] Created new class realm plugin>org.flywaydb:flyway-maven-plugin:4.0.2
[DEBUG] Importing foreign packages into class realm plugin>org.flywaydb:flyway-maven-plugin:4.0.2
[DEBUG]   Imported:  < maven.api
[DEBUG] Populating class realm plugin>org.flywaydb:flyway-maven-plugin:4.0.2
[DEBUG]   Included: org.flywaydb:flyway-maven-plugin:jar:4.0.2
[DEBUG]   Included: backport-util-concurrent:backport-util-concurrent:jar:3.1
[DEBUG]   Included: org.codehaus.plexus:plexus-interpolation:jar:1.11
[DEBUG]   Included: org.slf4j:slf4j-jdk14:jar:1.7.16
[DEBUG]   Included: org.slf4j:jcl-over-slf4j:jar:1.7.16
[DEBUG]   Included: org.apache.maven.reporting:maven-reporting-api:jar:2.2.1
[DEBUG]   Included: org.apache.maven.doxia:doxia-sink-api:jar:1.1
[DEBUG]   Included: org.apache.maven.doxia:doxia-logging-api:jar:1.1
[DEBUG]   Included: commons-cli:commons-cli:jar:1.2
[DEBUG]   Included: org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-4
[DEBUG]   Included: org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4
[DEBUG]   Included: org.sonatype.plexus:plexus-cipher:jar:1.4
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:1.5.15
[DEBUG]   Included: org.flywaydb:flyway-core:jar:4.0.2
[DEBUG] Configuring mojo org.flywaydb:flyway-maven-plugin:4.0.2:migrate from plugin realm ClassRealm[plugin>org.flywaydb:flyway-maven-plugin:4.0.2, parent: sun.misc.Launcher$AppClassLoader@55f96302]
[DEBUG] Configuring mojo 'org.flywaydb:flyway-maven-plugin:4.0.2:migrate' with include-project-dependencies configurator -->
[DEBUG]   (f) driver = com.google.appengine.api.rdbms.AppEngineDriver
[DEBUG]   (f) mavenProject = MavenProject: reyes.r.christopher:mvn-flyway-cloudsql-test:1.0-SNAPSHOT @ /Users/chris.reyes/github/creyes17/mvn-flyway-cloudsql-test/pom.xml
[DEBUG]   (f) password = REDACTED
[DEBUG]   (f) schemas = []
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@44a2b17b
[DEBUG]   (f) url = jdbc:google:rdbms://REDACTED:3306/hello_world?serverTimezone=UTC&useSSL=true&verifyServerCertificate=true&requireSSL=true
[DEBUG]   (f) user = REDACTED
[DEBUG] -- end configuration --
[DEBUG] flyway.properties not found. Skipping.
[INFO] Flyway 4.0.2 by Boxfuse
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.834 s
[INFO] Finished at: 2017-06-21T10:22:07-07:00
[INFO] Final Memory: 11M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:4.0.2:migrate (default-cli) on project mvn-flyway-cloudsql-test: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call rdbms.OpenConnection in a thread that is neither the original request thread nor a thread created by ThreadManager -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.flywaydb:flyway-maven-plugin:4.0.2:migrate (default-cli) on project mvn-flyway-cloudsql-test: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call rdbms.OpenConnection in a thread that is neither the original request thread nor a thread created by ThreadManager
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call rdbms.OpenConnection in a thread that is neither the original request thread nor a thread created by ThreadManager
    at org.flywaydb.maven.AbstractFlywayMojo.execute(AbstractFlywayMojo.java:541)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 20 more
Caused by: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call rdbms.OpenConnection in a thread that is neither the original request thread nor a thread created by ThreadManager
    at com.google.apphosting.api.ApiProxy$CallNotFoundException.foreignThread(ApiProxy.java:800)
    at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:112)
    at com.google.appengine.api.rdbms.RdbmsApiProxyClient$ApiProxyBlockingInterface.makeSyncCall(RdbmsApiProxyClient.java:94)
    at com.google.appengine.api.rdbms.RdbmsApiProxyClient$ApiProxyBlockingInterface.openConnection(RdbmsApiProxyClient.java:71)
    at com.google.cloud.sql.jdbc.internal.SqlProtoClient.openConnection(SqlProtoClient.java:58)
    at com.google.cloud.sql.jdbc.Driver.connect(Driver.java:65)
    at com.google.cloud.sql.jdbc.Driver.connect(Driver.java:25)
    at com.google.appengine.api.rdbms.AppEngineDriver.connect(AppEngineDriver.java:83)
    at org.flywaydb.core.internal.util.jdbc.DriverDataSource.getConnectionFromDriver(DriverDataSource.java:409)
    at org.flywaydb.core.internal.util.jdbc.DriverDataSource.getConnection(DriverDataSource.java:370)
    at org.flywaydb.core.internal.util.jdbc.JdbcUtils.openConnection(JdbcUtils.java:50)
    at org.flywaydb.core.Flyway.execute(Flyway.java:1326)
    at org.flywaydb.core.Flyway.migrate(Flyway.java:917)
    at org.flywaydb.maven.MigrateMojo.doExecute(MigrateMojo.java:30)
    at org.flywaydb.maven.AbstractFlywayMojo.execute(AbstractFlywayMojo.java:539)
    ... 22 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

我已确认我可以使用 gcloud 工具使用相同的凭据直接登录到云 sql:gcloud sql connect REDACTED --user=$user。当我在打开的 mysql 工具中输入\s 时,我可以确认用户是相同的,并且连接与我一直使用的$instance 相同。我在尝试mvn flyway:migrate 之前和之后都尝试过使用gcloud 工具,但它不会改变错误消息。

我查看了Migrating to Google Cloud SQL using flyway, what jar files should be copied?,但我的错误信息不同。我还是尝试了修复(放入 mysql jdbc jar),但它根本没有改变错误消息。

感谢您的帮助!

【问题讨论】:

    标签: maven google-cloud-sql flyway


    【解决方案1】:

    我在 Google 与 Jinjun 进行了交谈,他能够向我指出一些 different Google documentation。我需要使用他们的MySQL SocketFactory 并重新格式化 jdbc url 字符串。

    具体来说,我在 pom.xml 中添加了以下依赖:

    <!-- https://mvnrepository.com/artifact/com.google.cloud.sql/mysql-socket-factory-connector-j-6 -->
    <dependency>
        <groupId>com.google.cloud.sql</groupId>
        <artifactId>mysql-socket-factory-connector-j-6</artifactId>
        <version>1.0.2</version>
    </dependency>
    

    然后,我将 JDBC URL 连接器字符串更改为

    jdbc:mysql://google/hello_world?cloudSqlInstance=${instance}&socketFactory=com.google.cloud.sql.mysql.SocketFactory
    

    我更新了我的example github repo 并在几台不同的机器上对其进行了测试以测试其可移植性。

    【讨论】:

    • 另外,如果 jdbc 连接器字符串在配置文件中,则不需要 HTML 转义 & 符号 (&amp;amp;)
    猜你喜欢
    • 2015-01-02
    • 2020-10-25
    • 2013-12-23
    • 2012-05-01
    • 2012-08-06
    • 2012-02-07
    • 2021-09-01
    • 2020-07-03
    • 2017-05-31
    相关资源
    最近更新 更多