Grails on google app engine - google-app-engine

What is the current status of grails and google app engine deployment. I am new to app engine but wonder worth exploring it. Some specific qns are
the latest plugin, which has high user rating, has any restrictions? or it work seamlessly with all gorm features
is there any issue with high startup time for grails application. How is it in real world scenario? (with a typical small and large scale application)
what about other grails plugins (like, shiro, joda time, nimble etc). I guess they wont play well. So using those libraries directly is the better option
If decided to give up goole-app as a deployment option, how easy to switch to a normal environment. The JPA support ensures the compatibility with other traditional DBs?
Not sure what else are major issues.. probably, this is the foundation for a good discussion.
thanks.

I got few good response from grails mailing list, and the conclusion shares the comment by David. see the thread here
Couple of relevant responses:
From Tomas Lin:
I would suggest looking into Gaelyk if you really want to build a
project on the App Engine. It is built from the ground up with the App
Engine as the target engine, so it can bypass problems like long
loadtimes due to Spring and Hibernate. The newly introduced plugin
mechanism guarantees that your Gaelyk applications can be extended in
a way guaranteed to work on GAE.
Gaelyk has it's own native entity persistence DSL, which is a little
cleaner that the JPA/JDO abstractions on top of the App Engine.
I currently see many HardDeadlineExceeded exceptions with the App
Engine and Grails. It is just not designed to work well with Spring
right now. Hopefully this will improve with the later releases of
Groovy, Grails and the Spring / Google partnership for GAE for
business, but I wouldn't consider Grails on GAE production ready.
Even with Gaelyk, there are reports of slow performance. So imagine
the difficulties that arise with the much bigger Grails stack.
The app-engine comes with it's own implementation of a user / security
management system based on GMail accounts. If you just want to provide
an admin / non-admin implementation, this is supported in the
appengine configuration. Cannot comment on Shiro.
Be aware that one of the major restrictions of the App Engine is the
inability to write a file, so even basic file uploading in Spring
becomes problematic since the default mechanism writes to a temporary
file. I would imagine that most of the plugins would not work out of
the box without digging into their code and changing it.
I think the biggest issue here is lack of support for native JDBC. JPA
is not as well supported as plain JDBC GORM, things like named queries
would probably not work out of the box without retrofitting. If you
want to use the latest and greatest parts of Grails, it might be
worthwhile to consider other hosting solutions.
From Aaron Eischeid
1.The GAE plugin and the JPA-GORM plugins combined do not get you all GORM features seamlessly. Though you should get basics like .save(), .delete(), and maybe .list() the dynamic finders etc. are going to be out (at least for now). I could be way off here, but I think most/all Hibernate dependent features are out or replaced by something else (since it relies on SQL under the hood and GAE doesn't currently have SQL based DB...) so for example any criteria builders are a no go. It is unclear to me how much of the dot drilling you can do on objects. For example, not sure if you could do something like:
def b = new Book()
def stores = b.authors.publishers.bookstores
One place I could use some pointers is how to use JPA in the domain classes. I am sure there is good info out there, but I just haven't found it yet.
unsure
grails plugins that include domain classes or manipulate your current domain classes are bound to have issues since you have to construct your domain classes differently to play nice with JPA which is necessary because Googles Datastore isn't quite like a relational DB. On the flip side. you can use Google's built in security so you shouldn't necessarily need plugins like Acegi or Shiro.
This probably boils down to the different levels of GORM that you can use in controllers and services and the different ways you define domain classes. Some refactoring seems inevitable unless JPA plays just as nice with SQL DB's as it does with Googles Datastore. If JPA can move like that then transferring should be easy, but by using JPA-GORM you give up some stuff you would probably want if you weren't benefiting from due to being on GAE.
Eager to hear what others have to say,
Aaron

Related

How to use JDBC on Google AppEngine

I have an application that is using JDBC to manipulate its data.
I'm looking for a way to run the application on Appengine. Unfortunately, it seems like there aren't many options besides datastore (which I just can't get used to).
I've tried to use an embedded JavaDB, but Appengine blocks FileOutputStream (throws an exception "java.io.FileOutputStream is a restricted class" on initial driver loading). Therefore, I haven't tried Sqlite.
I've also tried to use Jiql, a new project that offers a JDBC interface to Datastore. However, I just can't seem to establish a "connection". It is somewhat unclear to me how to use jiql (like: what user/pass do you supply?), despite the few examples on their site.
I've looked at Google Cloud SQL and eventually signed up for it. It seemed to be the perfect solution to our problem, until I realized it's a paid service (it'll be paid soon, once it leaves the beta phase). I prefer not to pay (yet) as I'm still testing and evaluating the potential of GAE.
--
What would you recommend, keeping in mind would like to use JDBC for the persistence layer of the application?
Thanks in advance!
GAE supports two frameworks for persistence, JPA and JDO. There are few frameworks that plays well with GAE rules like Objectify. But to start with datastore you can also take at google tutorial GAE DATASTORE. If you need to learn the relationship with JPA and support for JDBC persistence Check this Link

Need help in deciding java framework, libraries

I am planning to develop open source java application to work on google app engine as well as normal rdbms system, so please help me in choosing
MVC Framework -
Struts / Spring MVC ?
ORM -
JDO / JPA ?
I am considering performance as a key factor.
For app engine you will want a lightweight framework, both for persistance and application stuff. Google is changing their pricing model so you might want to consider how this will impact your plans as well. There is an interesting discussion on the app engine group about this: https://groups.google.com/forum/#!topic/google-appengine/ob-kMuDAAqc/discussion
Aside from that I can only comment on the choice of persistance framework:
JDO on app engine is a pain. The version they (Google) support in app engine is 1.x, which is ancient, I believe. I have had more trouble with getting things to work than I care to remember. If you have previous experience with JDO this still might be a good choice. If I were to start over again I would choose a persistence framework that was specifically written for app engine, like objectify or twig. They require less overhead and are easier to use (from my point of view). One giant plus of objectify: gives you memcache support out of the box with no extra work. How great is that?
However, you also want to support an RDBMS. If you have the time, you could roll your own abstraction layer on top of objectify and the RDBMS persistance layer of your choice. That would give you the edge in performance that you are looking for. ;)
If that is not an option I would suggest JPA (not because I have used it myself, but because I had so much trouble with JDO).
Hope this helps!
What do you mean by performance? For instance, if you're not using the always on feature, you might consider the server cold start-up time as the single thing affecting the performance the most. All the frameworks will make it slower, there's even a blog post about optimizing the cold start-up time.
For the MVC, Spring 3 is quite good at it, but it's more personal preference and what you're comfortable with. If you want something designed for AppEngine, give Gaelyk a try, it's Groovy though. For the data storage, JPA is perhaps more widely used, but I think the JDO support on App Engine is better. Both of those provide some level of platform independence, if you need to get off from App Engine. There are also Objectify-Appengine and Twig that are more tied to the platform and thus might provide better interface for managing the datastore.
I would personally go with Java EE 6 framework.So
MVC: JSF -> very lightweight and easy to develop. JSF2.x fixed many shortcoming features from JSF1.2
ORM: JPA2.0 -> since it is standard and come with Java EE 6 bundle. You can replace with Hibernate, your choice. Each has its own unique advantage features. I would not say one is better than other.
Dont forget that Java EE 6 come with EJB3.1. EJB have had its bad reputation to be heavyweight, however since EJB 3.0, it is a much different story. EJB3.1 has become much more light weight and easy to develop. Glassfish web profile provides EJBLite (Hehehehe :D :D much lighter :D)
In term of development complexity, I have to say that Spring is a bit more complex than JEE6, but again, I only touch Spring very minimal, this discussion will leave to much more experienced developers to talk about.
I would go for JSF + JPA and I'd use Spring Framework for dependency injection.
My 5ยข. :P

The quintessential JDO/JPA, GWT + GAE (Google App Engine) sample application

Is there an open source, reference implementation of a simple, correctly designed, best practiced, GWT + GAE open source application? I would like to see the best practices on the following:
Recommended GWT Page navigation, session handling
GWT best practice UI (validation, controls etc)
Work with detached objects, conversations, wizards
Effective and "as intended" integration between GWT and GAE
MVC implementation with GWT and GAE, where is the controller? (Spring?)
Using domain POJOs in the UI without writing data transfer objects?
JDO (or JPA) and DAO layer - correct mapping, transaction and service layers
A permission layer, (e.g. like Spring security/ACEGI)
Integration with client side libraries (JQuery / Sancha)
JUnit layer for both server and client side
All the samples I found so far handled a very narrow aspect of the above, and I'm sure there has to be one good "starting point" such as the one's you can find for Spring / Hibernate or RoR projects
Have you looked at Roo?
This can be used to quickly build a GWT app based on one of a number of JPA providers and databases.
It doesn't offer all the items listed but has quite a variety of optional add-ons
Unfortunately I don't know of any such reference implementation, and I don't think you're likely to find such an all-encompassing example is because:
It's much easier to understand an example that focuses on one thing, like focusing on using JDO in a GWT app, or using Spring security in a GWT app, or how to do client-side validation in a GWT app. There's no reason one sample has to include such disparate features.
In the same vein, what if I wanted this exact list of features in a reference implementation, but using something else instead of JDO? Should I expect someone to write everything all over again, with that one part replaced? It's much better to write samples and documentation for each piece of the puzzle and leave it up to developers to glue that knowledge together.
Some of the things you listed aren't exactly common usages, e.g., integration with JQuery and Sencha. That's not to say it's not possible, and there are some (focused) examples out there if you look, but it's not the main use case for GWT developers, so I don't think it makes sense in a reference implementation.
The sort of app you're talking about is very complex, something that would take multiple engineers months to write and then would have to be maintained and updated. All for a sample? Some people aren't willing to invest that kind of energy even when there's money involved!
That being said, there are some great GWT sample apps (with source available) here. Even though they don't encompass everything you listed, they'll hopefully be helpful.
There is a "Google App Engine Java and GWT Application Development" A code of the application they build during the book comes "Licensed under the Apache License, Version 2.0" so (I guess this is qualify as open source but IANAL) it worth looking at. At least it does helps me as I am working through the same set of questions. It written Nov 2010 so it is still relevant as Google Platform evolves at astonishing speed.
Declaimer - I got no relation to this book except that I am reading it.

Porting a Grails application to GAE

I currently have a Grails application I'm evaluating to port to Google App Engine and I'd like to know experiences regarding:
Acegi security: the application relies on this library to enforce the security (update: just learned that it's based on hibernate so can't be ported; any recommended replacements?).
Use of JPA or JDO instead of the hibernate plugin (I'll have to migrate the Domain classes); which one is better ?
I have a growing number of pre-generated pdf files I keep uploading; is there any foreseeable problem with this?
Thanks in advance.
This isn't the answer you want, I'm sure, but I spent some time exploring Grails on GAE and finally came to the conclusion that it's not a good fit. By the time you give up (or work around) the native Domain capabilities, forego many of the plugins, and deal with the host of other minor incompatibilities, you've essentially wiped out most of the productivity advantage of Grails. I'd consider a standard J2EE, a compatible framework, or possibly a GWT based app for GAE. If you want to stick with Grails, I'd host it on AWS or a dedicated J2EE hosting provider.
That said, I hope the integration eventually works cleanly because GAE is a pretty cool engine/model.
You may also be interested in Gaelyk (http://gaelyk.appspot.com/) Gaelyk is a lightweight wrapper which enables you to deploy applications written in Groovy to the App Engine.
Gaelyk offers a lot of the advantages of Grails including:
standards for Views, Controllers
flexible URL routing
plugin system
It has simple wrappers for the App Engine (including datastore access and coercion to POJO/POGOs, email, memcache, Jabber & more)
(although it doesn't include internationalisation, CRUD scaffolding or a HQL type query wrapper)
As it is more lightweight it doesn't have the performance issues on App Engine that Grails does and now that you can reserve instances
http://code.google.com/appengine/docs/adminconsole/instances.html#Always_On it is possible to remove the startup time problems!
I wrote a blog series about my experience with Grails on App Engine. It discusses most of your questions.

How difficult is it to migrate away from Google App Engine?

I am thinking of making an (initially) small Web Application, which would eventually have a potential to grow. All things considered Google App Engine seems like a very attractive option. Say, user base and complexity grows and for one or other reason I needed to leave GAE behind. How difficult would it be to migrate away?
1) Does GAE provide a way to export the database? What format would it be? Would it be difficult to put it under MySQL (or similar)?
2) In which areas (ex. database access, others?) would I have to use GAE API? I.e. which parts of implementation would have to be abstracted away / interfaced?
Edit: 3) Alternatively, is it even worth to abstract away GAE API?
For question #1: I don't know if GAE specifically supports exports of a database but you can always roll your own, worst case scenario. If you are in a position where you need to, you'll probably have the resources to do it, too.
For question #2: You can and should always encapsulate those kinds of outside dependencies anyway. It doesn't matter whether or not they provide interfaces. Coupling to those interfaces should be kept to an absolute minimum.
For question #3: This question is not really super-clear so I cannot answer it.
I'm speaking strictly from a java webapp point of view...
Google App Engine for python has a backup/restore utility:
http://code.google.com/appengine/articles/gae_backup_and_restore.html
There is a huge interested in porting this to the java flavor.
You can use the higher level standard database apis (JDO/JPS) to allow you to move your app away from google's database services. I suggest purchasing the data nucleus tools in order to smooth the transition from big tables to something like mysql or oracle.
The packaged services GAE provides are enumerated at
http://code.google.com/appengine/docs/java/javadoc/
The stock JRE should handle porting of the urlfetch, mail, and memcache api packages.
You'll have to find a substitute technology for the users, blobstore, xmpp, and taskqueue packages.

Resources