Hosting Apache Tapestry5.1 on GAE (Google App Engine)
Assalam Alikom
In this post, I'll try to explain the steps I took to host Tapestry5.1 on google app engine.
First of all here is my application.
First of all here is my application.
A very good place to start is here. This page will help you know what will, won't or will partially work on Google app engine.
Now straight to tapestry5.1 stuff ..
public class AppModule {
public static void contributeApplicationDefaults(MappedConfigurationconfig) {
config.add(SymbolConstants.PRODUCTION_MODE, "false"); //This mainly affects how exceptions are reported, I'm not sure - and I don't think - its vital to host tapestry on GAE.
config.add("tapestry.thread-pool-enabled", "false"); //Now this is a must !, GAE restriction.
config.add(SymbolConstants.APPLICATION_VERSION, "0.1");// This is to override the random number generated by tapestry in assets paths
}
}
2)There as a compatibility issue between tapestry5 and GAE, that's why your are obviously here !, this issue has been patched and the patch is applied to the online tapestry5 trunk here.
- Check it out (No, actually check-it out !)
- Compile it, skip the tests that maven runs if you face problems (and this is your own responsibility to do so.)
- Replace the tapestry jar files you're using with the ones you just compiled.
3)If you are using eclipse, I encourage you to download and install the Google app engine eclipse plug-in. Specially if you'll use JDO which is explained by Google regarding it's utilization in the GAE environment.
4)Now there are some issues regarding tapestry components static files:
- It's important to know that Google App Engine hosts static files on different servers than the ones that serve the servlets .
- Also tapestry has it's procedures to serve assets. Fortunately this can be handled regarding hosting tapestry on Google application engine.
- About "tapx" tapestry extensions,it doesn't obey the configuration we add to the AppModule.java class regarding the app-version property ! (I didn't try examining this locally). Too bad this is not on haward's priority list. Btw, haward is tapestry's creator, you probably know that !
The following image is a snapshot for tapestry 5.0.18 hosted on GAE (It's sometimes showed properly but I got lucky catching this snapshot to demonstrate my point) :
As you can see, the style is broken, because the .css stylesheet file url is broken !
The online website is here.
I REALLY hope tapestry becomes fully compatible with GAE. It's literally like a dream come true. A magnificent development environment and a free, reliable and powerful host like GAE !!
Haward..PLEASE make Tapestry fully compatible with GAE XD
Thank you all for reading I hope you made use of this :)
5.2 is already compatible with GAE! :)
ReplyDeleteYup, And I'm already using it :)
ReplyDeleteThis post was written like 8 months ago. Back then it was only 5.1 :)
It works locally for me but not on the cloud. I got this error with GAE4J 1.3.8/1.3.7 with Tapestry 5.2.0/5.2.1 -
ReplyDeleteFailed startup of context com.google.apphosting.utils.jetty.RuntimeAppEngineWebAppContext@185fe0c{/,/base/data/home/apps/cloudserviceapi/1.345576400327946165}
java.lang.RuntimeException: Exception constructing service 'ComponentClassResolver': Error invoking service builder method org.apache.tapestry5.services.TapestryModule.buildComponentClassResolver(ComponentClassResolverImpl, InvalidationEventHub) (at TapestryModule.java:1271) (for service 'ComponentClassResolver'): Error invoking constructor org.apache.tapestry5.internal.services.ComponentClassResolverImpl(Logger, ComponentInstantiatorSource, ClassNameLocator, String, String, Collection) (at ComponentClassResolverImpl.java:116) (for service 'ComponentClassResolver'): Exception constructing service 'FactoryDefaults': Error invoking constructor org.apache.tapestry5.ioc.internal.services.MapSymbolProvider(Map) (at MapSymbolProvider.java:30) via ...(truncated)...
Any idea how to fix it?
Thanks.
Make sure all your jars are included in your web-inf/lib folder. Some unclear exceptions could be thrown due to the absence of a class (i.e. jar) or the duplication of one. So also make sure you don't have more than one jar that carries the same class. From the stack trace, my best guess is that you have more than one jar with the same logging class in these jars.
ReplyDeleteIf I included everything, I will have the following error and I don't use Spring and Hibernate (I use JDO) -
ReplyDeletejava.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
and
Exception constructing service 'ValueEncoderSource': Error invoking service builder method org.apache.tapestry5.services.TapestryModule.buildValueEncoderSource(Map, InvalidationEventHub) (at TapestryModule.java:2269) (for service 'ValueEncoderSource'): Error invoking service contribution method org.apache.tapestry5.hibernate.HibernateModule.contributeValueEncoderSource(MappedConfiguration, boolean, HibernateSessionSource, Session, TypeCoercer, PropertyAccess, LoggerSource): Exception constructing service 'HibernateSessionSource': Error invoking service builder method org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionSource(Logger, List, RegistryShutdownHub) (at HibernateCoreModule.java:123) (for service 'HibernateSessionSource'): org/hibernate/cfg/AnnotationConfiguration
Thus I excluded tapestry-spring-5.2.1.jar and tapestry-hibernate*.jar and it works locally but why not once deployed?
I didn't mean to include every available tapestry module, I meant every jar you included in your class path, of course along with tapestry modules needed to run your application. And this includes maven dependencies.
ReplyDeleteWould you kindly list out exactly what are the jar files inside your WEB-INF/lib? Thanks!
ReplyDeleteI don't have T5.1 now as I'm using T5.2, here are the needed jars for a basic usage I suppose.
ReplyDeletecommons-io-1.3.jar
javassist-3.12.1.GA.jar
log4j-1.2.14.jar
slf4j-api-1.5.2.jar
slf4j-log4j12-1.5.2.jar
tapestry5-annotations-5.2.0.jar
tapestry-core-5.2.0.jar
tapestry-func-5.2.0.jar
tapestry-ioc-5.2.0.jar
antlr-2.7.6.jar
antlr-runtime-3.1.1.jar
commons-codec-1.3.jar
10/19/2010 01:01 AM 936,744 gwt-servlet.jar
ReplyDelete10/16/2010 12:00 PM 148,846 gwtx-1.5-20081912.jar
10/16/2010 12:00 PM 91,794 inject-16.jar
10/16/2010 12:00 PM 371,264 javamail-141.jar
10/18/2010 11:27 PM 644,148 javassist-3.12.1.GA.jar
10/19/2010 12:36 AM 192,820 jdo2-api-2.3-eb.jar
10/16/2010 12:00 PM 302,347 jiql.jar
10/19/2010 12:36 AM 8,082 jsr107cache-1.1.jar
10/18/2010 11:27 PM 367,444 log4j-1.2.14.jar
10/16/2010 12:00 PM 1,935,873 quercus.jar
10/16/2010 12:00 PM 4,694,704 resin1.jar
10/16/2010 12:00 PM 3,022,757 resin2.jar
10/18/2010 11:27 PM 17,384 slf4j-api-1.5.2.jar
10/18/2010 11:27 PM 9,501 slf4j-log4j12-1.5.2.jar
10/19/2010 09:30 AM 0 t
10/18/2010 11:27 PM 1,679,278 tapestry-core-5.2.1.jar
10/18/2010 11:27 PM 47,865 tapestry-func-5.2.1.jar
10/18/2010 11:27 PM 459,859 tapestry-ioc-5.2.1.jar
10/18/2010 11:27 PM 24,395 tapestry-json-5.2.1.jar
10/19/2010 07:48 AM 466,554 tapestry-test-5.2.1.jar
10/18/2010 11:27 PM 17,110 tapestry5-annotations-5.2.1.jar
52 File(s) 48,976,340 bytes
2 Dir(s) 67,724,955,648 bytes free
The latest error I see -
Page OrderStart did not generate any markup when rendered. This could be because its template file could not be located, or because a render phase method in the page prevented rendering.
Hide uninteresting stack frames Stack trace
org.apache.tapestry5.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:50)
org.apache.tapestry5.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:67)
org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:64)
org.apache.tapestry5.services.TapestryModule$36.handle(TapestryModule.java:2308)
Do you see anything fishy or anything else that I missed? I have the same AppModule.java like yours.
Please send me your mail. I will not publish your post so your mail should be safe.
ReplyDelete