GWT, Google Gears and OSX: The explosive mix
This is a little post that may save you hours (because you are probably using the Google Web Toolkit along with the Google Gears API, the whole thing under OSX, right ? no ? Okay, so read forward because you may one day). So the problem comes when you try to launch you damn awesome application with the GWT Hosted Mode in your Eclipse and get this ugly exception:
Jul 12, 2009 6:26:29 AM com.google.apphosting.utils.jetty.JettyLogger info
INFO: jetty-6.1.x
Jul 12, 2009 6:26:29 AM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: failed com.google.apphosting.utils.jetty.DevAppEngineWebAppContext@c45809{/,/Users/work/workspace/Athena/war}
javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:113)
at org.mortbay.xml.XmlParser.(XmlParser.java:69)
at org.mortbay.jetty.webapp.WebXmlConfiguration.webXmlParser(WebXmlConfiguration.java:83)
at org.mortbay.jetty.webapp.WebXmlConfiguration.(WebXmlConfiguration.java:78)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
And guess what ? This is actually a Java (jre) 1.5 bug ! So the easy solution is to switch to Java 1.6 which also allows you do to String.isEmpty() instead of String.length() == 0 which is just awesome (...). So you switch to Java 1.6, and try to start your app again, and then cry again when you get this clear one-line message that haunts you since you've read it:
You must use a Java 1.5 runtime to use GWT Hosted Mode on Mac OS X.
Damn.
How the hell can you get this stupid app running ? The solution is damn easy but again there's a trap. One thread on stackoverflow tells you that you should replace you gwt-gears.jar file with gwt-gears-noredist.jar that is available in the GWT Gears API archive, and tada. So you go on the GWT Gears API website and get the gwt-gears-1.2.1.zip file in the download box on the right side, and of course, there's no gwt-gears-noredist.jar file inside the archive. This is the moment where you get a little angry and depressed. Where the heck to find this file ? Well, don't ask me why, but the gwt-gears-noredist.jar file is only available in the tar archive, known as gwt-gears-1.2.1.tar.gz, that you can only find in the Downloads page of the site.
This is fucking stupid and make you feel like you've lost precious time because, so I hope this post saved you that
Hi ! I'm Jérémie, a french passionate about information retrieval, natural language processing, distributed computing, innovative web interfaces, entrepreneurship and wakeboarding !
October 21st, 2009
You are brilliant. I spent 4 days just to get to this point…and finally I found a post that told me where to find the damned noredist.jar file…once I popped that in place of the gwt-gears.jar I finally got my app to run. It boggles my mind that it was this hard to get up and running…you’d think google or eclipse would figure this out and either fix it or point you in the right direction to fix it yourself. I was about to give up…thanks again.