Thursday, October 9, 2008

 

GWT + maven2 + eclipse on 64 bit linux in 30 seconds

GWT is a toolkit for building world class web2.0 gui applications without the headache. Setting up an Eclipse dev environment on 64 bit fedora core (version 9) however required some extra steps. I heard that Google is working on a smoother 64 bit integration but until it's here you might find the list of required actions useful:

The basic installation


1. Get GWT
GWT comes in three flavours - one for win, one for mac and one for (32 bit) linux. Manual installation of gwt is not strictly reguired for maven + eclipse use but it's also convenient to have it around to be able to run your apps in hosted mode without maven.

2. Get 32 bit jdk
The default JDK in my fc 9 installation identified itself as "OpenJDK Runtime Environment (build 1.6.0-b09)" and if you try to start gwt Shell with it all you get is following error message:


Exception in thread "main" java.lang.UnsatisfiedLinkError: ...gwt-linux-1.5.2/libswt-pi-gtk-3235.so: .../gwt/gwt-linux-1.5.2/libswt-pi-gtk-3235.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)


The cure to this problem is to fetch and install a 32 bit java from sun.

3. Install some required 32 bit libraries:

If your see error like:

Exception in thread "main" java.lang.UnsatisfiedLinkError: .../gwt/gwt-linux-1.5.2/libswt-pi-gtk-3235.so: libXtst.so.6: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1778)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1674)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1005)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:132)
at org.eclipse.swt.internal.gtk.OS.(OS.java:22)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54)
at org.eclipse.swt.widgets.Display.(Display.java:126)
at com.google.gwt.dev.GWTShell.(GWTShell.java:301)
Could not find the main class: com.google.gwt.dev.GWTShell. Program will exit.


you need to install 32 bit version of libXtst.
sudo yum install libXtst.i386

If you see error like

Exception in thread "main" java.lang.UnsatisfiedLinkError: .../libswt-pi-gtk-3235.so: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory

You need to install gtk2

sudo yum install gtk2.i386



If you see an error like

** Unable to load Mozilla for hosted mode **
java.lang.UnsatisfiedLinkError: .../gwt/gwt-linux-1.5.2/mozilla-1.7.12/libxpcom.so: libstdc++.so.5: cannot open shared object file: No such file or directory


you need to install the 32 bit compat-libstdc++ library:
sudo yum install compat-libstdc++-33.i386

You are now ready for command line development of GWT apps. Just remember to set the path so that the 32 bit java is used to launch the GWT Shell.

Alternative way for maven users


1. Get 32 bit jdk

2. Install the required 32 bit libraries

3. Check out sample maven app that uses gwt-maven

svn co http://gwt-maven.googlecode.com/svn/trunk/maven-googlewebtoolkit2-plugin/simplesample/ sample

Launch the sample application


cd sample
mvn gwt:gwt



Launching GTW Shell from eclipse


1. Import (or check out from scm) your project into eclipse
2. From Run menu select Run Configurations
3. Right click Java Application from left side of the screen and select new
4. Set com.google.gwt.dev.GWTShell as Main class
5. At Arguments tab enter the module name as program argument (in the sample it is com.totsp.sample.Application)
6. From tab JRE make sure that the 32 bit jre is used for the project
7. From tab Classpath click Advanced... select Add Folders and select the src/java folder from your project (ot the folder that contains the <package>/Module.gwt.xml file)
8. Click 'Apply' and 'Run'

Your GWT app is now running and you can enjoy features like nice fast dev cyckle edit->save->refresh, debugger etc.

Labels: , , ,



Comments



Nice post, quick, to the point, and good info.
# posted by Blogger Charlie "Atrox" Collins : October 10, 2008 2:27 PM  



Rather than replacing the default 64bit version of Java, would anyone know how to modify the Maven script to use a supplementary 32bit JRE instead?
# posted by Blogger Casper Bang : May 17, 2009 6:08 PM  



I was getting the mozilla-1.7.12/libxpcom.so problem. You saved my day. Thanks.
# posted by Blogger Kiran : June 24, 2009 12:37 PM  



Hi!

Worked on the first try! Great info.
One minor update: On Fedora 11 (my box) there are *.i586 versions of packages.

Many thanks.
# posted by Blogger Miroslav Beranič ml. : September 16, 2009 10:07 PM  

Post a Comment



<< Home

Navigation