Question

lipse plugin to try and run a new Web Application "locally" (from inside Eclipse, using the built-in Jetty container). I am following the instruction in this GWT tutorial and am running into some issues, presumably because of how I have my modules defined.

I have a Web Application project with the following directory structure:

MyWebApp/
    src/
        com.mywebapp.client.modules
            WebModule
            AppModule
            WebModule.gwt.xml
            AppModule.gwt.xml
    war/
        WEB-INF/
            lib/
            web.xml
    css/
        web-module.css
        app-module.css
    hmtl/
        web-module-host-page.html
        app-module-host-page.html

I want my app to have 2 modules: WebModule which is the "public website", and the module that loads when the user goes to http://mywebapp.com, and then there is AppModule, that downloads only after the user logs in, and contains the "private app" features of the site.

WebModule.java:

public class WebModule implements EntryPoint {
    Label label = new Label("Hello, GWT!");

    @Override
    public void onModuleLoad() {
        RootPanel.get().add(label);
    }
}

WebModule.gwt.xml:

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to="web-module">
    <inherits name="com.google.gwt.user.User"/>
    <inherits name="com.google.gwt.user.theme.standard.Standard"/>
    <entry-point class="com.mywebapp.client.modules.WebModule"/>
    <source path='client'/>
    <source path='shared'/>
</module>

web.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    version="2.5"
    xsi:schemaLocation=
        "http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <welcome-file-list>
        <welcome-file>web-module-host-page.html</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>SystemServiceServlet</servlet-name>
        <servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
        <init-param>
            <param-name>services</param-name>
            <param-value/>
        </init-param>
    </servlet>

    <servlet-mapping>
        <servlet-name>SystemServiceServlet</servlet-name>
        <url-pattern>/_ah/spi/*</url-pattern>
    </servlet-mapping>
</web-app>

web-module-host-page.html:

<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link type="text/css" rel="stylesheet" href="css/web-module.css">
    <title>Hello, GWT!</title>
    <script type="text/javascript" language="javascript" src="mywebapp/mywebapp.nocache.js"></script>
</head>

<body>
    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
    <noscript>
        Turn on javascript!
    </noscript>
</body>
</html>

To try and run this from Eclipse (in Dev Mode so that I can run/debug from a browser pointing to a localhost url), I have created a new Run Configuration like so:

Run Configurations
    Main tab
        Main class: com.google.gwt.dev.DevMode
    Server tab
        "Run built-in server" is checked at Port 8888
    GWT tab
        Code server port: 9997
        Available modules:
            AppModule - com.mywebapp.client.modules.AppModule
            WebModule - com.mywebapp.client.modules.WebModule
    Arguments tab - see below

Arguments tab >> Program arguments:

-remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -startupUrl web-module-host-page.html -logLevel INFO -codeServerPort 9997 -port 8888 -server com.google.appengine.tools.development.gwt.AppEngineLauncher -war /home/myuser/sandbox/workbench/eclipse/workspace/mywebapp/war com.mywebapp.client.modules.WebModule com.mywebapp.client.modules.AppModule

Argument tab >> VM arguments:

-Ddatastore.default_high_rep_job_policy_unapplied_job_pct=50 -Xmx512m -javaagent:/home/myuser/sandbox/workbench/google/gae-sdk/1.7.1/appengine-java-sdk-1.7.1/lib/agent/appengine-agent.jar

Finally, the question!

When I try to run this configuration, I get the following console output:

Loading modules
    com.mywebapp.client.modules.WebModule
    [ERROR] Invalid name 'web-module'
    [ERROR] Failure while parsing XML
com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
    at com.google.gwt.dev.cfg.ModuleDefSchema$NullableNameAttrCvt.convertToArg(ModuleDefSchema.java:1048)
    at com.google.gwt.dev.util.xml.HandlerArgs.convertToArg(HandlerArgs.java:64)
    at com.google.gwt.dev.util.xml.HandlerMethod.invokeBegin(HandlerMethod.java:221)
    at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.startElement(ReflectiveParser.java:294)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.parse(ReflectiveParser.java:347)
    at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.access$200(ReflectiveParser.java:68)
    at com.google.gwt.dev.util.xml.ReflectiveParser.parse(ReflectiveParser.java:418)
    at com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:296)
    at com.google.gwt.dev.cfg.ModuleDefLoader$1.load(ModuleDefLoader.java:198)
    at com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:324)
    at com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(ModuleDefLoader.java:156)
    at com.google.gwt.dev.DevModeBase.loadModule(DevModeBase.java:992)
    at com.google.gwt.dev.DevMode.loadModule(DevMode.java:557)
    at com.google.gwt.dev.DevMode.doStartup(DevMode.java:443)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1058)
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811)
    at com.google.gwt.dev.DevMode.main(DevMode.java:311)
    [ERROR] Unexpected error while processing XML
com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
    at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.parse(ReflectiveParser.java:371)
    at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.access$200(ReflectiveParser.java:68)
    at com.google.gwt.dev.util.xml.ReflectiveParser.parse(ReflectiveParser.java:418)
    at com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:296)
    at com.google.gwt.dev.cfg.ModuleDefLoader$1.load(ModuleDefLoader.java:198)
    at com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:324)
    at com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(ModuleDefLoader.java:156)
    at com.google.gwt.dev.DevModeBase.loadModule(DevModeBase.java:992)
    at com.google.gwt.dev.DevMode.loadModule(DevMode.java:557)
    at com.google.gwt.dev.DevMode.doStartup(DevMode.java:443)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1058)
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811)
    at com.google.gwt.dev.DevMode.main(DevMode.java:311)
    [ERROR] shell failed in doStartup method

Can any GWT gurus spot where my configuration is wrong (and explain why!)? The exception/error output isn't very descriptive here.

Was it helpful?

Solution

The name in rename-to has to be a dotted chain of valid Java identifiers. web-module is not a valid Java identifier (the dash in it).

Try rename-to="webModule", rename-to="webmodule" or rename-to="web.module" instead, and of course adjust your <script> tag in the HTML host page in consequence (webModule/webModule.nocache.js, webmodule/webmodule.nocache.js or web.module/web.module.nocache.js respectively).

This has nothing to do with trying to run multiple modules or whatever.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top