Apache Wicket on Google App Engine for Java

Posted by dan on Apr 8, 2009 in General |

Holy smokes, that was easy. I’ve got a basic Wicket app running on Google App Engine in under 2 minutes.

3 small traps for the unwary. First of all, you need to enable sessions in your appengine config file.

    <sessions-enabled>true</sessions-enabled>

Secondly, add the following line into your WebApplication’s init() method:

	@Override
	protected void init() {
		super.init();
 
		//remove thread monitoring from resource watcher
		this.getResourceSettings().setResourcePollFrequency(null);
	}

Thirdly, override the newSessionStore() method to return HttpSessionStore, because the default second level session store uses java.io.File, which Google App Engine doesn’t allow:

	@Override
	protected ISessionStore newSessionStore()
	{	
		return new HttpSessionStore(this);
//		return new SecondLevelCacheSessionStore(this, new InMemoryPageStore());
	}

That’s because Google App Engine doesn’t want you spawning threads. Obvious enough.

So that’s it! You’re in a Wicket-land of infinite scalability…

(I’m sure there’s more to it but I was excited…)

See my stupid test here: http://transitplatform.appspot.com/

Tags: , , ,

7 Comments

Garidan
Apr 8, 2009 at 12:41 pm

Marvelous ! I just read about GAE/J and searched for someone who tried wicket and here you are. Thanks.
I think wicket is perfect for that platform.
Really good news.
thanks


 
Al
Apr 8, 2009 at 5:37 pm

dude!!, publish the source!!


 
soma
Apr 9, 2009 at 2:52 pm

thanks


 
Ai
Apr 16, 2009 at 9:51 am

Hi thanks for sharing the infos!

Currently I’m having some difficulties whith wicket having loading the html resources.

Did you change anything appart from the mentioned overrided methods?

cheers

Logs:

Apr 17, 2009 12:45:03 AM org.apache.wicket.util.resource.locator.ResourceStreamLocator locateByResourceFinder
FINE: Attempting to locate resource ‘org/gaetest/pages/HomePage.html’ on path [folders = [], webapppaths: []]
Apr 17, 2009 12:45:03 AM org.apache.wicket.util.resource.locator.ResourceStreamLocator getResourceStream
FINE: Attempting to locate resource ‘org/gaetest/pages/HomePage.html’ using classloader com.google.appengine.tools.development.IsolatedAppClassLoader@31ff23
Apr 17, 2009 12:45:03 AM org.apache.wicket.util.resource.locator.ResourceStreamLocator getResourceStream
FINE: Attempting to locate resource ‘org/gaetest/pages/HomePage.html’ using classloader com.google.appengine.tools.development.IsolatedAppClassLoader@31ff23
Apr 17, 2009 12:45:03 AM org.apache.wicket.util.resource.locator.ResourceStreamLocator getResourceStream
FINE: Attempting to locate resource ‘org/gaetest/pages/HomePage.html’ using classloader com.google.appengine.tools.development.IsolatedAppClassLoader@31ff23

SEVERE: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 17, 2009 12:45:03 AM org.apache.wicket.RequestCycle logRuntimeException
SEVERE: Markup of type ‘html’ for component ‘org.gaetest.pages.HomePage’ not found. Enable debug messages for org.apache.wicket.util.resource to get a list of all filenames tried.: [Page class = org.gaetest.pages.HomePage, id = 0, version = 0]
org.apache.wicket.markup.MarkupNotFoundException: Markup of type ‘html’ for component ‘org.gaetest.pages.HomePage’ not found. Enable debug messages for org.apache.wicket.util.resource


 
Per
Jun 27, 2009 at 2:39 pm

Really been trying this but can’t get it working in the app engine. It works fine in Eclipse but on Google I get a 404 – so I wonder where the difference is.


 
Tee Bee
Jul 14, 2009 at 6:51 pm

Hi

I agree that it works fine in Eclipse using the Google appengine plugin, but after deplyoying to Google the first page was ok, but trying to simulate some other pages I get this error: 500 Server error
and the logs is:

Uncaught exception from servlet
com.google.apphosting.api.ApiProxy$RequestTooLargeException: The request to API call datastore_v3.Put() was too large.

any idea?

regards


 
bob
Feb 2, 2010 at 7:25 pm

i had to add serialVersionUID to my wicket pages since they are stored in the session and serialized. I guess they are not required by Eclipse when I create a wicket page. before i did that, i was receiving an exception like:

javax.servlet.ServletException: java.lang.RuntimeException: java.io.InvalidClassException: wicket.LoginPage; local class incompatible: stream classdesc serialVersionUID


 

Reply

Copyright © 2010 Dan Walmsley All rights reserved. Theme by Laptop Geek.