简体   繁体   English

绑定到Google App Engine上Cloud SQL中的@Text字段时,Play Framework的Siena模块出错

[英]Play Framework's Siena module is erroring out while binding to a @Text field in Cloud SQL on Google App Engine

I am attempting to rewrite Play! 我正在尝试重写Play! framework's YABE tutorial so that it can run on Google App Engine using the Siena module. 框架的YABE教程,以便可以使用Siena模块在Google App Engine上运行。 I am using the following versions of play and modules: 我正在使用以下版本的游戏和模块:

  • Play 1.2.5 播放1.2.5
  • crudsiena 2.0.3 Crudsiena 2.0.3
  • siena 2.0.7 锡耶纳2.0.7
  • gae 1.6.0 盖伊1.6.0

I have successfully setup the application, connected to the database and capable of storing/retrieving data to the database. 我已经成功设置了应用程序,已连接到数据库并能够将数据存储/检索到数据库。 However, I am running into an issue with the @Text annotation provided by the Siena module. 但是,我遇到了Siena模块提供的@Text批注的问题。 It is creating the database correctly using the MediumText datatype for the Post.content and Comment.content data fields. 它使用Post.content和Comment.content数据字段的MediumText数据类型正确创建数据库。 Below is the generated DDL from the GAE logs: 以下是从GAE日志生成的DDL:

# ----------------------------------------------------------------------- 
# Comment 
# ----------------------------------------------------------------------- 

CREATE TABLE Comment
(
    id VARCHAR(255) NOT NULL,
    author VARCHAR(255) NULL,
    postedAt DATETIME,
    content MEDIUMTEXT NULL,
    post VARCHAR(255) NULL,
    PRIMARY KEY (id)
);

# ----------------------------------------------------------------------- 
# User 
# ----------------------------------------------------------------------- 

CREATE TABLE User
(
    id VARCHAR(255) NOT NULL,
    email VARCHAR(255) NULL,
    password VARCHAR(255) NULL,
    fullname VARCHAR(255) NULL,
    isAdmin TINYINT(1) DEFAULT false NOT NULL,
    PRIMARY KEY (id)
);

# ----------------------------------------------------------------------- 
# Tag 
# ----------------------------------------------------------------------- 

CREATE TABLE Tag
(
    id VARCHAR(255) NOT NULL,
    name VARCHAR(255) NULL,
    PRIMARY KEY (id)
);

# ----------------------------------------------------------------------- 
# Post 
# ----------------------------------------------------------------------- 

CREATE TABLE Post
(
    id VARCHAR(255) NOT NULL,
    title VARCHAR(255) NULL,
    postedAt DATETIME,
    content MEDIUMTEXT NULL,
    author VARCHAR(255) NULL,
    PRIMARY KEY (id)
);

I have annotated my Post.content field with the @Text annotation as I have seen Pascal comment on a few boards to use . 我已经用@Text注释对Post.content字段进行了注释,因为我看到Pascal在一些要使用的板上发表了评论 I have posted my Post class below for reference: 我在下面发布了我的Post类供参考:

package models;

import ...

public class Post extends Model {
    ...

    @Text
    @Required
    @MaxSize(10000)
    public String content;

    ...
}

As I mentioned, everything deploys fine, but when I attempt to save a post to the database, I receive the follow stack trace: 如前所述,一切部署都很好,但是当我尝试将帖子保存到数据库时,我收到了以下堆栈跟踪:

play.Logger niceThrowable: 

@6cm6cpabp
Internal Server Error (500)

Execution exception (In /app/controllers/Application.java around line 28)
RuntimeException occured : Cannot load fixture initial-data.yml: Unexpected Error

play.exceptions.JavaExecutionException: Cannot load fixture initial-data.yml: Unexpected Error
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:237)
    at play.server.ServletWrapper$ServletInvocation.execute(ServletWrapper.java:561)
    at play.Invoker$Invocation.run(Invoker.java:278)
    at play.server.ServletWrapper$ServletInvocation.run(ServletWrapper.java:552)
    at play.Invoker.invokeInThread(Invoker.java:68)
    at play.server.ServletWrapper.service(ServletWrapper.java:143)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:102)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:266)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:447)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:454)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:461)
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:703)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:338)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:330)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:458)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.RuntimeException: Cannot load fixture initial-data.yml: Unexpected Error
    at play.modules.siena.SienaFixtures.loadModels(SienaFixtures.java:273)
    at controllers.Application.index(Application.java:28)
    at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:557)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:508)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:484)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:479)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
    at play.server.ServletWrapper$ServletInvocation.execute(ServletWrapper.java:561)
    at play.Invoker$Invocation.run(Invoker.java:278)
    at play.server.ServletWrapper$ServletInvocation.run(ServletWrapper.java:552)
    at play.Invoker.invokeInThread(Invoker.java:68)
    at play.server.ServletWrapper.service(ServletWrapper.java:143)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:454)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:461)
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:703)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:338)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:330)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:458)
    ... 1 more
Caused by: play.exceptions.UnexpectedException: Unexpected Error
    at play.modules.siena.SienaModelUtils.edit(SienaModelUtils.java:301)
    at play.modules.siena.SienaModelUtils.create(SienaModelUtils.java:58)
    at play.modules.siena.SienaPlugin.bind(SienaPlugin.java:331)
    at play.PlayPlugin.bind(PlayPlugin.java:68)
    at play.plugins.PluginCollection.bind(PluginCollection.java:579)
    at play.data.binding.Binder.bind(Binder.java:112)
    at play.data.binding.Binder.bind(Binder.java:92)
    at play.data.binding.Binder.bind(Binder.java:88)
    at play.modules.siena.SienaFixtures.loadModels(SienaFixtures.java:207)
    ... 34 more
Caused by: siena.SienaException: java.lang.IllegalArgumentException: Can not set java.lang.String field models.Post.content to com.google.cloud.sql.jdbc.internal.ClientSideClob
    at siena.Util.setField(Util.java:286)
    at siena.jdbc.JdbcMappingUtils.setFromObject(JdbcMappingUtils.java:205)
    at siena.jdbc.JdbcMappingUtils.mapField(JdbcMappingUtils.java:186)
    at siena.jdbc.JdbcMappingUtils.mapObject(JdbcMappingUtils.java:79)
    at siena.jdbc.JdbcMappingUtils.mapObject(JdbcMappingUtils.java:67)
    at siena.jdbc.JdbcMappingUtils.mapList(JdbcMappingUtils.java:92)
    at siena.jdbc.JdbcPersistenceManager.doFetch(JdbcPersistenceManager.java:636)
    at siena.jdbc.JdbcPersistenceManager.fetch(JdbcPersistenceManager.java:728)
    at siena.AbstractPersistenceManager.get(AbstractPersistenceManager.java:71)
    at siena.BaseQuery.get(BaseQuery.java:111)
    at play.modules.siena.SienaModelUtils.edit(SienaModelUtils.java:227)
    ... 42 more
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field models.Post.content to com.google.cloud.sql.jdbc.internal.ClientSideClob
    at siena.Util.setField(Util.java:284)
    ... 52 more

Essentially it is choking trying to map the content field from a String to a Google ClientSideClob class. 本质上,尝试将内容字段从String映射到Google ClientSideClob类是令人窒息的。 Anybody got any ideas? 有人有想法吗?

It turns out this issue was not occuring during the insert of the data, but on the reading of the data from the database. 事实证明,此问题不是在数据插入期间发生的,而是在从数据库读取数据时发生的。 It has been fixed in the current siena master branch on github . 它已在github上当前的siena master分支中修复。 I cloned that repo, built the siena jar from that codebase, copied it from the target directory to the siena module lib directory. 我克隆了该仓库,从该代码库构建了siena jar,并将其从目标目录复制到siena模块lib目录。

cp ~/projects/siena/source/target/siena-1.0.0-b6.jar modules/siena-2.0.7/lib/

Redeployed and it fixed the mapping error between String and the mediumtext field in Google's Cloud SQL. 重新部署并修复了String和Google Cloud SQL中的mediumtext字段之间的映射错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM