Zeph Harben
unread,Jan 27, 2011, 3:54:30 PM1/27/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to play-framework, th...@volunteermatch.org
I've been developing my Play application as a standalone app, but for
our production environment it will need to be deployed within a Jetty
container.
Here's my problem - say I have a Model mapped as follows :
@Entity
@Table(name = "cms_view")
public class CMS extends GenericModel {
@Column(name="id")
@Id
public String id;
@Column(name="element_type")
public String elementType;
...
}
and a Controller that does this :
public static void index() {
/* Load required cms elements for various parts of the homepage */
CMS element = CMS.find("elementType = ? order by
elementIndex","homepage_element").first();
...
}
In my standalone Play application, this works perfectly - the JPQL
appears to generate the appropriate SQL :
DEBUG ~ select cms0_.id as id43_, cms0_.element_index as element2_43_,
cms0_.element_type as element3_43_ {...} from cms_view cms0_ where
cms0_.element_type=? order by cms0_.element_index limit ?
However, when I use "play war", and deploy the application into a
Jetty Servlet context, the following error occurs when access the
controller (full stacktrace at the end of this message) :
12:30:21,935 DEBUG ~ select cms0_.id as id3_, cms0_.element_index as
element2_3_, cms0_.element_type as element3_3_ {...} from cms_view
cms0_ where (elementType=? ) order by elementIndex limit ?
12:30:21,989 WARN ~ SQL Error: 1054, SQLState: 42S22
12:30:21,989 ERROR ~ Unknown column 'elementType' in 'where clause'
12:30:22,088 ERROR ~
As far as I can tell, when running within the servlet container,
Hibernate/JPA does not properly map the JPQL query's "where" and
"order by" clauses to the Model's underlying entity (our cms_view
table).
When I change my controller to use native SQL, it works fine in both
the standalone and deployed versions :
public static void index() {
/* Load required cms elements for various parts of the homepage */
CMS element = CMS.find("element_type = ? order by
element_index","homepage_element").first();
...
}
We are just beginning to use the Play framework (great job, BTW!), and
we'd strongly like to use the JPQL abstractions instead of native
SQL. Any help will be appreciated!
*** Other Notes : ***
* I have looked into classloader conflicts, but I'm sure if this is
the problem. Our Jetty container does not load any jar's other than
the bare necessities - hibernate, jpa, etc are loaded within specific
web app contexts. I've also set the Play application context to use
"parentLoaderPriority = false" to prevent the parent classloader from
interfering with play.
* A full stacktrace of the error in our Jetty/deployed application :
@659ljjo2c
Internal Server Error (500)
Execution exception (In /app/controllers/Homepage.java around line 28)
JPAQueryException occured : Error while executing query from
models.CMS where elementType = ? order by elementIndex: Unknown column
'elementType' in 'where clause'
play.exceptions.JavaExecutionException: Error while executing query
<strong>from models.CMS where elementType = ? order by elementIndex</
strong>: Unknown column 'elementType' in 'where clause'
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:285)
at play.server.ServletWrapper
$ServletInvocation.execute(ServletWrapper.java:472)
at play.Invoker$Invocation.run(Invoker.java:187)
at play.server.ServletWrapper
$ServletInvocation.run(ServletWrapper.java:463)
at play.Invoker.invokeInThread(Invoker.java:61)
at play.server.ServletWrapper.service(ServletWrapper.java:113)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:
530)
at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:
426)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:
119)
at
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:
494)
at
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:
229)
at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:
931)
at
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
361)
at
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:
186)
at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:
867)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:
117)
at
org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:
224)
at
org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:
126)
at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:
113)
at
org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:
335)
at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:
113)
at org.eclipse.jetty.server.Server.handle(Server.java:337)
at
org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:
581)
at org.eclipse.jetty.server.HttpConnection
$RequestHandler.headerComplete(HttpConnection.java:1005)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:560)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:
222)
at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:
417)
at
org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
474)
at org.eclipse.jetty.util.thread.QueuedThreadPool
$2.run(QueuedThreadPool.java:437)
at java.lang.Thread.run(Thread.java:636)
Caused by: play.db.jpa.JPABase$JPAQueryException: Error while
executing query <strong>from models.CMS where elementType = ? order by
elementIndex</strong>: Unknown column 'elementType' in 'where clause'
at play.db.jpa.GenericModel$JPAQuery.first(GenericModel.java:301)
at controllers.Homepage.index(Homepage.java:28)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:
408)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:
403)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:176)
... 30 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Unknown column 'elementType' in 'where clause'
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.Util.getInstance(Util.java:384)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)
at
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:
2113)
at
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:
2275)
at
com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:
76)
at
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:
208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1869)
at org.hibernate.loader.Loader.doQuery(Loader.java:718)
at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:
270)
at org.hibernate.loader.Loader.doList(Loader.java:2449)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2192)
at org.hibernate.loader.Loader.list(Loader.java:2187)
at
org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:
936)
at
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:
196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1258)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:241)
at play.db.jpa.GenericModel$JPAQuery.first(GenericModel.java:295)
... 34 more