Working With The GWT Shell
Join the DZone community and get the full member experience.Join For Free
GWTShell supports several common command-line parameters you should be familiar with. The parameters are described in table 1:
GWTShell [-port port-number] [-noserver] [-whitelist whitelist-string]
[-blacklist blacklist-string] [-logLevel level] [-gen dir] [-out dir]
[-style style] [url]
Table 1 GWTShell parameters
|-port||Runs an embedded Tomcat instance on the specified port (defaults to 8888)|
|-noserver||Prevents the embedded Tomcat server from running, even if a port is specified|
|-whitelist||Allows the user to browse URLs that match the specified regular expressions (comma or space separated)|
|-blacklist||Prevents the user from browsing URLs that match the specified regular expressions (comma or space separated)|
|-logLevel||The logging level: ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL|
|-gen||The directory into which generated files will be written for review|
|-out||The directory to which output files will be written (defaults to current)|
|-style||Script output style: OBF[uscated], PRETTY, or DETAILED (defaults to OBF)|
|url||Launches the specified URL automatically|
The first of these parameters that you may want to tweak is -logLevel, which changes the output level of the logging console. This is the first thing you notice when the GWT shell starts up.
The logging console
The GWT shell console is a hierarchical logging display with a few simple buttons that invoke the hosted mode browser and control logging output. The logging display is controlled by the -logLevel option on the GWTShell command line. Valid log levels are shown in table 2; the default level is INFO.
Table 2 GWTShell -logLevel options
|ERROR||Shows only critical errors in the GWT shell code.|
|WARN||Shows uncaught exceptions in user code. WARN and ERROR information are displayed in red in the shell window.|
|INFO||(Default.) Shows server startup information and invocations into specific GWT modules. Most of the time, what you’ll see in this mode is simply "Starting HTTP on port 8888."|
|TRACE||Shows each request logged, as well as module instantiations, their locations on the class path, and the time. This is perhaps the most useful mode for day-to-day development. TRACE and INFO level information are displayed in gray in the shell window.|
|ALL||Shows all logging information.|
[img_assist|nid=3420|title=|desc=The GWT shell logging console shows different log level messages in different colors.|link=none|align=none|width=550|height=369]
From the GWT shell console GUI, you also have the option to invoke the hosted mode browser. The hosted mode browser is what allows you to explore your Java application using a browser and browser-based events.
The hosted mode browser
Note that it’s important to make sure you have the GWT_EXTERNAL_BROWSER environment variable set before you click Compile/Browse. For example, on Linux you would set it like this:
This defines the command line that the GWT shell will invoke to launch a browser against the hosted Tomcat.
ou can also use the hosted mode browser apart from the GWT shell’s Tomcat instance with the -noserver option. This tells the shell not to use the embedded Tomcat instance in hosted mode, but rather to use an external server that you specify. Using an external web server, or Java container, can have several advantages. You can, for example, use the standalone browser to debug and test Java UI code that is talking to PHP or .NET backends that can’t otherwise be run in the GWT shell. Or you can use a Java backend that may run in a different container than Tomcat.
Regardless of which container you use, it’s recommended that for hosted mode use you name your context path name the same as your module: for example, com.manning.gwtip.helloserver.HelloServer. Doing this will make it easier to map your service servlet calls later.
This article is excerpted from Chapter 1 of GWT in Practice, by Robert Cooper and Charlie Collins, and published in May 2008 by Manning Publications.
Opinions expressed by DZone contributors are their own.