2

我正在尝试重写 Play!框架的YABE 教程,以便它可以使用 Siena 模块在 Google App Engine 上运行。我正在使用以下版本的播放和模块:

  • 玩 1.2.5
  • 克鲁兹耶纳 2.0.3
  • 锡耶纳 2.0.7
  • gae 1.6.0

我已成功设置应用程序,连接到数据库并能够将数据存储/检索到数据库。但是,我遇到了 Siena 模块提供的 @Text 注释的问题。它使用 Post.content 和 Comment.content 数据字段的 MediumText 数据类型正确创建数据库。下面是从 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)
);

我已经用 @Text 注释对我的 Post.content 字段进行了注释,因为我在一些要使用的板上看到了 Pascal 评论。我在下面发布了我的 Post 类以供参考:

package models;

import ...

public class Post extends Model {
    ...

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

    ...
}

正如我所提到的,一切都部署得很好,但是当我尝试将帖子保存到数据库时,我收到了以下堆栈跟踪:

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

本质上,尝试将内容字段从 String 映射到 Google ClientSideClob 类是令人窒息的。有人有什么想法吗?

4

1 回答 1

0

事实证明,这个问题不是在插入数据期间发生的,而是在从数据库中读取数据时发生的。它已在 github 上的当前 siena master 分支中修复。我克隆了那个 repo,从那个代码库构建了 siena jar,将它从目标目录复制到了 siena 模块 lib 目录。

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

重新部署并修复了 Google Cloud SQL 中 String 和 mediumtext 字段之间的映射错误。

于 2012-12-23T16:08:24.263 回答