GWT Development Mode with Eclipse/Maven

14,434

Description: The web.xml file does not exist

gwt-maven-plugin creates a project with 'war' packaging format (it's a web app so no surpirse here). Web.xml for this project will be under 'src/main/webapp' folder which will be copied to the 'war' directory (which is set as the output directory) as part of the 'resources' phase in the maven build life-cycle. You should always use

mvn compile gwt:run

or

mvn install gwt:run

so that resources are copied, all java files are compiled and gwt:compile is also invoked (since it is bound to the 'compile' phase automatically)

[WARN] No startup URLs supplied and no plausible ones found -- use -startupUrl

As per the stackoverflow link you used as reference, only your maven build file is setup with startupUrl. In order for it to work in Eclipse, you must edit the Run Configuration of your project and add the '-statupUrl' command line arguments to the existing arguments in the "Arguments" panel.

However, this is just a warning and it should not stop you from running your GWT application from eclipse. If you are facing the same "web.xml" problem here as well, it could be because you did not compile your project in your IDE before invoking "Run as Web Application". I suggest you to disable "Build Automatically" option for this project and always build it manually and invoke "GWT Compile" and then try "Run as web application"

EDIT: Related to the above, is it possible to debug a GWT app running in development mode started by gwt:compile gwt:run?

In general you must use "Remote Application" debug configuration for remote debugging a process. However I am not sure if it will work for GWT projects.

Share:
14,434
sdoca
Author by

sdoca

Updated on June 08, 2022

Comments

  • sdoca
    sdoca almost 2 years

    I am just starting with GWT. I use Eclipse and have installed the GWT plugin.

    I have followed the directions here Maven GWT 2.0 and Eclipse to set up a GWT project using the gwt-maven-plugin. When I run the Maven goals gwt:compile gwt:run, GWT Development Mode is launched and I can copy the url from it to my browser and view the label.

    However, the project has this problem:

    Description: The web.xml file does not exist
    Resource: WEB-INF   
    Path: /GWTExample/war
    Location: Unknown
    Type: Google Web App Problem
    

    If I try to run the project as a Google Web Application, I get this warning:

    [WARN] No startup URLs supplied and no plausible ones found -- use -startupUrl
    

    I can get rid of the problem by copying the web.xml to the war directory, but I still get the URL issue when running as a Google Web App.

    If I'm using Maven and GWT in Eclipse, should I just ignore the web.xml problem and always run applications in development mode via the Maven goals? Or is there a way to set things so I can run as a Google Web App?

    EDIT: Related to the above, is it possible to debug a GWT app running in development mode started by gwt:compile gwt:run? I have added breakpoints to my application but it doesn't stop on them. I'm not sure if it is something I've configured wrong or if it's just not possible.

    Update:

    In response to Prem's answer...

    When I run a compile gwt:run, the web.xml file isn't copied. When I run the install gwt:run, I get this error:

    [INFO] --- gwt-maven-plugin:1.2:test (default) @ SampleGWT ---
    [INFO] using GWT jars from project dependencies : 2.0.4
    [INFO] establishing classpath list (scope = test)
    [ERROR] java.lang.NoClassDefFoundError: org/codehaus/mojo/gwt/test/MavenTestRunner
    [ERROR] Caused by: java.lang.ClassNotFoundException: org.codehaus.mojo.gwt.test.MavenTestRunner
    [ERROR]     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    [ERROR]     at java.security.AccessController.doPrivileged(Native Method)
    [ERROR]     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    [ERROR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    [ERROR]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    [ERROR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    [ERROR] Could not find the main class: org.codehaus.mojo.gwt.test.MavenTestRunner.  Program will exit.
    [ERROR] Exception in thread "main"
    

    I’m guessing that bug http://jira.codehaus.org/browse/MGWT-24 is included in version 1.2 of the gwt-maven-plugin. Normally I wouldn’t run install on a project that builds a war file, but I would expect to at least get past the test phase of the build cycle.

    Does anybody have any idea why I would get this error on the install but not the compile goals? Also, should I be expecting either goal to copy the web.xml file from src/main/webapp/WEB-INF/web.xml to the /war directory?