How to setup Errai Project with Eclipse, Maven, GWT plugin with Default Jetty

Version 2

    First let me brag about it 

    Errai project was promising amazing things and now it seems that dream is coming alive. Think about -

    1. Having fancy HTML5 template based UI  (save you from that ui buinders, hadmade GWt UI etc )

    2. Client logic in java (GWT)  - no configuration etc

    3. Full out of the box navigation support - that's a life saver in compare to MVP's activity & places. I always hated it.

    4. All possibility communication model i.e. synchronous, asynchronous, broadcasting, push (web sockets)  etc.

    5. And another best one - Use Entity beans directly in client. So No DTOs, their party projectsor some kind of JSOn conversion. It's all taken care for you.

    6. CDI and many more ..

    If Errai's team get it right and keep document etc properly (which are not right now current release is 3.x and document belongs to old release)  - It could be next Struts like in late 1990s.

    I think another challenge could be performance at development time and obviously at run time.

     

    Anyways, if you are here - I assume that you must have done your research and very well aware of these advantages & disadvantages. So to get you started and save the pain i have been through - here are the steps.

     

    1. Download latest Eclipse and install (Via Eclipse market place - Search for JBoss) corresponding Jboss toots &  Jboss studio.

    2. Go to help menu and look for control central (It's like eclipse like start up page); go to second tab (bottom) and install GWT plugin from there.

    3. Go to your eclipse work space and run following command and it will generate gwt maven project for you.

         webAppCreator -maven -out MyGwtMavenSampleApp au.com.uptick.gwt.maven.sample.MyGwtMavenSampleApp

    4. Go to Eclipse and import above project as existing maven project.

    5. Run (Run as WebApplication) and make sure it's working.

    5. Now Delete all generated java files (including in test folder) and strip down your Entry Point call to single line of GWt.log statement.

    6. Again run and make sure it's working.

    7. Now open up POM and add "errai-javaee-all" as dependency

    8. In web.xml add the following entry

    <servlet>

            <servlet-name>ErraiServlet</servlet-name>

            <servlet-class>org.jboss.errai.bus.server.servlet.DefaultBlockingServlet</servlet-class>

            <init-param>

                <param-name>auto-discover-services</param-name>

                <param-value>true</param-value>

            </init-param>

            <load-on-startup>1</load-on-startup>

        </servlet>

     

     

        <servlet-mapping>

            <servlet-name>ErraiServlet</servlet-name>

            <url-pattern>*.erraiBus</url-pattern>

        </servlet-mapping>

     

    9. Update your GWt module to like below

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN"

      "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">

    <module rename-to='yourApp'>

      <inherits name="org.jboss.errai.enterprise.All" />

    </module>


    9. create a new package under client called "local" and move your Entry point class into this new package.


    10. Move "shared" packages too under this new "local" package


    11. Annotate your entry point class with "@EntryPoint". Your entry point class will look like below

    @EntryPoint

    public class YourAppEntryPoint {

     

      @PostConstruct

      public void init() {

       GWT.log("It's working..");

      }

    }

     

    10. Again run and make sure it's working via Errai based Entry Point class.

     

    This completes your basic setup; soon i will update the document to add UI templating feature.

     

    Hope this will help.