2

I am attempting to rewrite Play! framework's YABE tutorial so that it can run on Google App Engine using the Siena module. I am using the following versions of play and modules:

  • Play 1.2.5
  • crudsiena 2.0.3
  • siena 2.0.7
  • gae 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. It is creating the database correctly using the MediumText datatype for the Post.content and Comment.content data fields. Below is the generated DDL from the GAE logs:

# ----------------------------------------------------------------------- 
# 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. I have posted my Post class below for reference:

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. Anybody got any ideas?

1 Answers1

0

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. I cloned that repo, built the siena jar from that codebase, copied it from the target directory to the siena module lib directory.

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.

  • I have added this project to github for those that are interested. [https://github.com/mikalveli/yabegae](https://github.com/mikalveli/yabegae) – Michael Vaughan Dec 23 '12 at 22:30
  • Is there a reason why you used Play 1.x instead of Play 2? I am asking because you are doing active development right now while Play 2 has been released while ago! – user1076371 Jan 01 '13 at 18:04
  • 1
    @user1076371 play 2.x uses servlets v3 which are not supported in GAE, so if deploying in GAE you are forced to use play 1.x (which hopefully they keep developing) – momo Dec 05 '13 at 17:18