Monday, June 9, 2014

Somehow I got it to work: Tapestry 5.4-beta10 and Google App Engine

Aside from a bunch of crummy errors and missing files, I manage to to get Tapestry 5.4-beta10 to run in a Google App Engine instance. Here's what I learned:
  1. Java 8 and Tapestry 5 don't like each other. A bunch of guys reported it like Matt Raible. There's a work around and it isn't exactly safe for production (yet).
  2. YUIcompressor is missing again from the staging repo.
  3. You need to MAKE sure that your GAE instance name matches your appengine-web.xml application name. 
So how to go about getting your Tapestry5 into GAE. 
  1. Start by creating a Tapestry 5 project via maven. Which one though depends on what version of Java is on your dev machine. I'm running Java 8 so I had to use something greater than 5.4-beta4. I just updated the pom.xml and ran mvn clean compile.
  2. Add a appengine-web.xml to the src/main/webapp/WEB-INF folder.
    <?xml version="1.0" encoding="utf-8"?>  
     <appengine-web-app xmlns="http://appengine.google.com/ns/1.0">  
       <application>YOURAPPNAMEHERE</application>  
       <version>1</version>  
       <threadsafe>true</threadsafe>  
       <sessions-enabled>true</sessions-enabled>  
     </appengine-web-app>
    
  3. Edit the pom.xml to include google app engine devserver. Look for the plugins section and add this lines.
    <!-- Run the application using "mvn appengine:devserver" -->  
     <plugin>  
               <groupId>com.google.appengine</groupId>  
               <artifactId>appengine-maven-plugin</artifactId>  
               <version>${appengine.target.version}</version>  
               <configuration>  
                         <enableJarClasses>false</enableJarClasses>  
                         <port>8182</port>  
                         <address>0.0.0.0</address>  
               </configuration>  
     </plugin> 
    
    Also, add these values in the properties node:
            <appengine.target.version>1.9.6</appengine.target.version>
    
  4. Run mvn appengine:devserver
    There is where it gets hairy, if it fails to run, check the stack trace. If it says yuicompressor is missing then comment it out in the pom.xml and then make sure to run the app in dev mode by adding this line in the AppModule.java in the contributeApplicationDefaults method:
       configuration.add(SymbolConstants.PRODUCTION_MODE, false);
    
    There should clear it up. If there are more problems refer to the appengine docs for maven.
  5. If all goes well and you should have a running Tapestry5 app running locally inside a appengine devserver instance. The next step is to upload it to the appengine servers because that's the whole point.
  6. Run mvn appengine:update
    There should open a web page where authentication code to paste into the command line. Also, I do hope you already created a matching app engine project. No? You are a dumbass.
Here is my tapestry5 after all of that.