【问题标题】:Unable to launch in GAE无法在 GAE 中启动
【发布时间】:2016-12-11 14:28:15
【问题描述】:

我正在尝试使用codebase 来测试将 Google Cloud SQL 实例与 GAE 应用程序连接起来。我能够在本地成功运行它,但它似乎也在 AppEngine 中成功部署,但是当我尝试访问 myproject.appspot.com 时,我得到了 404。

以下是我遵循的步骤(跳过成功的本地相关步骤)。

  1. 创建了一个项目myproject
  2. 创建了一个 Google Cloud SQL 第二代实例,myproject-db
  3. 使用密码创建了root 用户。
  4. 使用了 Google Cloud Console "jdbc:google:mysql://myproject:us-central1:myproject-db/demo?user=root&password=PASSWORD;" 中指示的连接字符串
  5. appengine-web.xml 如下所示

    <?xml version="1.0" encoding="utf-8"?>
    <appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
    <application>myproject</application>
    <version>1</version>
    <threadsafe>true</threadsafe>
    <use-google-connector-j>true</use-google-connector-j>
    
    <system-properties>
    <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
    <property name="cloudsql.url" value="jdbc:google:mysql://myproject:us-central1:myproject-db/demo?user=root&amp;password=PASSWORD;"/>
    <property name="cloudsql.url.dev" value="jdbc:mysql://localhost/demo?user=root&amp;useSSL=false"/>
    </system-properties>
    </appengine-web-app>
    
  6. HibernateJPAServlet 中嵌入了以下代码 sn-p

    if (System.getProperty("com.google.appengine.runtime.version")
                .startsWith("Google App Engine/")) {
            Class.forName("com.mysql.jdbc.GoogleDriver");
            properties.put("javax.persistence.jdbc.driver",
              "com.mysql.jdbc.GoogleDriver");
            properties.put("javax.persistence.jdbc.url",
              System.getProperty("cloudsql.url"));
        }
    
  7. 我已将代码从本地上传到默认 myproject 存储库

    https://source.developers.google.com/p/myproject/r/default

  8. 我从“开发”视图启动了 Google Cloud Platform Console。

  9. 成功运行mvn clean packagemvn appengine:update。由于防火墙/代理限制,我无法从本地执行appengine:update
  10. 所以,在这一点上,我的理解是,我正在为 same 项目运行一个 GAE 应用程序和 GAE Cloud SQL 实例。所以http://myproject.appspot.com/ 应该托管我上传的第 8 步应用程序。但是当我访问它时会显示"404" - "The requested URL / was not found on this server."

万一问题是我们无法从 Cloud Console 部署它,那么我还有什么其他选择?我绝对不能更改网络/代理规则。

编辑

我尝试使用 mvn gcloud:runmvn gcloud:deploy 从外部代理/防火墙限制运行和部署应用程序。最后它清楚地说明了"Deployed URL: [https://myproject.appspot.com]"。但是当我通过浏览器访问同一个 URL 时,同样的问题仍然存在。

编辑 2

我可以从 App Engine 信息中心看到错误跟踪。这是说

" org.hibernate.exception.JDBCConnectionException: Could not open connection
Caused by: org.hibernate.exception.JDBCConnectionException: Could not open connection
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost."

我的连接字符串是“jdbc:google:mysql://myproject:us-central1:myproject-db/demo?user=root&password=PASSWD123&”

【问题讨论】:

  • 您在哪里看到这个 404 错误?在日志中?在您的浏览器中?此外,在第 8 步中,您说您成功运行了mvn appengine:update,但是您说您无法执行appengine:update。它是哪一个?该命令是成功还是失败?
  • 嗨 Eric,我无法从本地执行 mvn appengine:update... 但是我可以从 Google Cloud Console 执行相同操作,但部署结束后,当我尝试访问 myproject 时.appspot.com 通过浏览器,我看到 404 错误。

标签: java hibernate maven google-app-engine google-cloud-sql


【解决方案1】:

这是我的错误(也部分是文档空白,我也提供了反馈)。每次我们通过appenginegcloud 部署应用程序时,新部署的版本应该通过"App Engine &gt; Versions" 选项卡可见。我们应该"Split Traffic""100%"(用于测试)给新部署的版本,然后启动“https://myproject.appspot.com”来查看我们想要看到的结果。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-08
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 2020-02-16
    • 2013-04-21
    • 1970-01-01
    • 2018-03-26
    相关资源
    最近更新 更多