Solved: How to package and deploy a REST service with gwt-maven-plugin

9 views
Skip to first unread message

Farrukh Najmi

unread,
Feb 12, 2009, 7:22:09 PM2/12/09
to gwt-maven


Here is what I did and it worked...
  • I created a server directory as sibling to client directory

    src/main/java/com/acme/server
    src/main/java/com/acme/client

  • I added dependencies to my server side code which I needed to implement my REST service
  • I updated my web.xml file to add my custom SpringServlet (does not extends GWT RemoteServiceServlet)

      <servlet>
        <servlet-name>REST Interface</servlet-name>
        <servlet-class>com.acme.RESTServlet</servlet-class>
      </servlet>
      <servlet-mapping>
         <servlet-name>REST Interface</servlet-name>
         <url-pattern>/rest/*</url-pattern>
      </servlet-mapping>

  • Made sure to not add that (non- GWT RemoteServiceServlet) servlet to my Application.gwt.xml module descriptor file.
    I learned the hard way that you only list GWT RemoteServiceServlet extensions here.
  • When I run my app in the GWT Shell I can access the servlet at:

    http://localhost:8888/rest/xxx

    The servlet can be accessed within the client code at a relative URL like:

    String urlPath = GWT.getModuleBaseURL() + "../rest/xxx";
Hope this helps others in my situation.

On Thu, Feb 12, 2009 at 11:38 AM, Farrukh Najmi <farruk...@gmail.com> wrote:


I will try packaging my REST servlet like I would in any other maven
project and see if that works.
Again any pointers on what may be different would be great. Thanks.

On Feb 12, 11:00 am, Farrukh Najmi <farrukh.n...@gmail.com> wrote:
> I would like to implement the server side code for my UI as a REST service.
> I already know how to access the REST service from my client code. What I am
> not sure of is how to package and deploy the REST service using
> gwt-maven-plugin. Any pointers would be great. Thanks.
>
> --
> Regards,
> Farrukh




--
Regards,
Farrukh

Charlie Collins

unread,
Feb 13, 2009, 3:13:54 PM2/13/09
to gwt-maven
Sorry I didn't get a chance to respond to this sooner, really busy
lately ;).

Yes, you can add regular servlets normally, just put then in your
SOURCE web.xml and away you go. (Don't put them in the module as you
note.) As an aside to this, one other thing I would mention here - in
general I probably would not even package my REST impl along with my
GWT code. Just make it a separate project on it's own completely
independent of GWT stuff (it's own WAR, etc - mock it for tests at the
GWT level, at deploy time the service calls just go to that server
impl).

On Feb 12, 7:22 pm, Farrukh Najmi <farrukh.n...@gmail.com> wrote:
> Here is what I did and it worked...
>
>    - I created a server directory as sibling to client directory
>
>    src/main/java/com/acme/server
>    src/main/java/com/acme/client
>
>    - I added dependencies to my server side code which I needed to implement
>    my REST service
>    - I updated my web.xml file to add my custom SpringServlet (does not
>    extends GWT RemoteServiceServlet)
>
>      <servlet>
>        <servlet-name>REST Interface</servlet-name>
>        <servlet-class>com.acme.RESTServlet</servlet-class>
>      </servlet>
>      <servlet-mapping>
>         <servlet-name>REST Interface</servlet-name>
>         <url-pattern>/rest/*</url-pattern>
>      </servlet-mapping>
>
>    - Made sure to not add that (non- GWT RemoteServiceServlet) servlet to my
>    Application.gwt.xml module descriptor file.
>    I learned the hard way that you only list GWT RemoteServiceServlet
>    extensions here.
>    - When I run my app in the GWT Shell I can access the servlet at:
>
>    http://localhost:8888/rest/xxx
>
>    The servlet can be accessed within the client code at a relative URL
>    like:
>
>    String urlPath = GWT.getModuleBaseURL() + "../rest/xxx";
>
> Hope this helps others in my situation.
>
Reply all
Reply to author
Forward
0 new messages