hwo to get the server working?

192 views
Skip to first unread message

Mike O.

unread,
Aug 25, 2018, 11:19:10 AM8/25/18
to GWT Users
Hello,

I am new to GWT (but not to Java) and have no experience with servers.  I have downloaded GWT and am running the StockWatcher example.
I can change the example and recompile, but there is no server running.
In the attached image, the bottom right shows the lack of server and the upper middle shows the error when I hit send in the window.

Do I need to separately start a server (like tomcat) and link it to this project somehow?  Or am I merely missing an option/flag?
Are there step-by-step instructions?  Unless I missed it, the GWT instructions do not mention the server side.

Thank you,
Michael


If it helps, these are the exact steps I took:

1) New GWT Application Project - and fill in as on: http://www.gwtproject.org/doc/latest/tutorial/create.html
Note - I use the option: default SDK (GWT 2.7.0 - 2.7.0)

2) I compile (right-click on StockWatcher folder in Explorer --> GWT --> Compile) the example and the output is:
    Compiling module com.google.gwt.sample.stockwatcher.StockWatcher
        ...
       Compile of permutations succeeded
       Compilation succeeded -- 11.252s
    Linking into /home/<name>/eclipse-workspace/StockWatcher/war/stockwatcher
        Link succeeded
        Linking succeeded -- 0.207s

3) I then run (right-click on StockWatcher folder in Explorer --> Run As --> GWT Development Mode) the example and the output is:
    Turning off precompile in incremental mode.
    Super Dev Mode starting up
        workDir: /tmp/gwt-codeserver-1813876122864786922.tmp
        Loading Java files in com.google.gwt.sample.stockwatcher.StockWatcher.
        Module setup completed in 8634 ms
    2018-08-25 14:54:22.459:INFO:oejs.Server:jetty-8.y.z-SNAPSHOT
    2018-08-25 14:54:22.495:INFO:oejs.AbstractConnector:Started SelectChann...@127.0.0.1:9876

    The code server is ready at http://localhost:9876/

4) I copy http://localhost:9876/ (or http://127.0.0.1:9876/) into a web terminal and copy the "Dev Mode On" and "Dev Mode Off" buttons into the toolbar

5) Follow the StockWatcher folder down into war/ and right-click on stockwatcher.html and open in browser (see image 1 attached)

6) Hit Enter on the stockwatcher.html window and get the error window appear

Screenshot from 2018-08-25 15-16-05.png

Thomas Broyer

unread,
Aug 25, 2018, 11:53:22 AM8/25/18
to GWT Users
    2018-08-25 14:54:22.495:INFO:oejs.AbstractConnector:Started SelectChannelConnector@127.0.0.1:9876


    The code server is ready at http://localhost:9876/

You should use "GWT Development Mode with Jetty" instead (see https://gwt-plugins.github.io/documentation/gwt-eclipse-plugin/devmodes/DevMode.html)
 
4) I copy http://localhost:9876/ (or http://127.0.0.1:9876/) into a web terminal and copy the "Dev Mode On" and "Dev Mode Off" buttons into the toolbar

IIRC (haven't used Eclipse for a while), if you switch to the "Development Mode" view, you should get a different link, specifically it should be http://localhost:8888/

Mike O.

unread,
Aug 25, 2018, 1:11:52 PM8/25/18
to GWT Users
Thomas,

Thanks so much - it worked great.

One more (related) question, if I may.  How do I best update the server-side code?  Right clicking on the text editor in the IDE and selecting "Validate" works (as does exiting the IDE and re-running).  Is that the best / only way?

Thanks again,
Michael O.


In detail,

1) I edited line 28 in GreetingServiceImpl.java (under com.google.gwt.sample.stockwatcher.server under src folder under the StockWatcher project)
from: return "Hello, " + input + ...
to: return "Hello there, " + input + ...

2) Right-click on the text-editor and save and then right-click again and hit validate.

3) Hit the "Send" button on the client-side webpage

andy...@gmail.com

unread,
Aug 25, 2018, 4:07:14 PM8/25/18
to GWT Users
You can also run a local instance of your target server and set the noServer option on the gwt plugin. I do this using a maven project in NetBeans, for example, which has built in support for my target platform (wildfly, and previously glassfish). It's also impossible for my project to run on jetty to begin with since I'm using a wide range of Java EE features on top of basic servlets. 

The benefit of this is that you can run on a configuration nearly identical to your target platform and the application automatically re-deploys on save. The workflow is very smooth with no need to ever restart the server during normal development. Let me know if you want me to post additional details such as excerpts of my pom.xml showing how the project is configured. 
    2018-08-25 14:54:22.495:INFO:oejs.AbstractConnector:Started SelectChannelConnector@127.0.0.1:9876


    The code server is ready at http://localhost:9876/

Mike O.

unread,
Aug 26, 2018, 5:53:04 PM8/26/18
to GWT Users
Andrew,

That is very generous, and if you have the time, I would certainly look at it.  That said, I am totally new to using IDEs (having programmed in text editors up to now) and although I have just spent some time since your email reading up on Maven, I don't know enough about servers (though I have used sockets) or IDEs to really understand the difference or make an good decision between them - I think I will stick with the jetty option on Eclipse for a bit - get to understand it, and then look into Maven.

If you have a minute though, I would be interested in hearing which Java EE features do not work with jetty.

Michael

Andrew Somerville

unread,
Aug 27, 2018, 8:14:24 AM8/27/18
to GWT Users
No problem, Mike. 

Jetty isn't a Java EE container, it's simply a servlet container. That means it runs your app with a very minimal set of built-in functionality and none of the Java EE functionality. Essentially, everything your app does, it must do itself, including authentication, database access, etc.. Your app must include the libraries for whatever type of servlet it uses. Essentially no services are made available to your app by the container. This is great if you're not even using Java EE, and are instead using some other Java web framework. Lets say you're using Spring, for example...

Maven, however, isn't related to Java EE. Maven is a type of java project that automatically loads its dependencies - you just list them in the pom.xml file - and builds or runs your application. Some of the features of Maven are also offered by eclipse/netbeans. I generally recommend beginners with Java actually start with a Maven project, however you might need some hints on how to integrate GWT. 

Thomas Broyer

unread,
Aug 27, 2018, 12:16:50 PM8/27/18
to GWT Users


On Monday, August 27, 2018 at 2:14:24 PM UTC+2, Andrew Somerville wrote:
No problem, Mike. 

Jetty isn't a Java EE container, it's simply a servlet container. That means it runs your app with a very minimal set of built-in functionality and none of the Java EE functionality. Essentially, everything your app does, it must do itself, including authentication, database access, etc.. Your app must include the libraries for whatever type of servlet it uses. Essentially no services are made available to your app by the container. This is great if you're not even using Java EE, and are instead using some other Java web framework. Lets say you're using Spring, for example...


The embedded Jetty server from the DevMode however is not really configurable, and is really only meant for webapps that don't use any of those features (i.e. that you can deploy in any servlet container without any specific configuration).

Fwiw, DevMode is discouraged nowadays for most production apps (because of those limitations, and the way it loads the webapp's classes and resources, which can easily break your apps in weird and hard-to-diagnose ways). It's great for small applications  though, like the StockWatcher example, where you want to jump right into coding with GWT (or small repro cases for bugs) and don't have many (or any) third-party dependencies. That way, you can learn GWT and Java servlet development "fast", and gradually acquire skills and switch to more "industrial" tools like Maven or Gradle as build tools, external servlet containers (either run from your IDE, or by your build tool), etc.

Andrew Somerville

unread,
Aug 27, 2018, 12:36:09 PM8/27/18
to GWT Users
I stand corrected on Jetty, it seems in recent years they have included a selective subset of Java EE tech that I wasn't aware of. 

I work on large enterprise apps and DevMode is invaluable for rapidly recompiling on the front end during development. However, your point is well-made placed, that if you couldn't run DevMode on your actual production environment it would be essentially useless. 

This is the section of my pom.xml file that makes this possible. This change prevents the plugin from starting up the built-in Jetty server and instead deploys on the development server in Netbeans. To start dev mode I simply run the gwt-run goal, re-run the webapp and refresh the page. 

When I deploy, I stop the dev mode server and "Clean and Build", producing a non-development war file. This completely eliminates any compatibility issues between the test environment and the final deployment. They are both the same. The simple argument why this is safe is this: the only meaningful difference from the webapp's point of view is that the GWT compiler only compiles 1 permutation and that the front end code is sourced through the DevMode code server. Otherwise, the running app doesn't know any different. 

Annoyances occasionally arise when changing classes serialized between the client and server. The dev plugin doesn't appear to pick up on these changes with every server back end. The Netbeans Glassfish plugin was the best, only requiring me to re-run the generateAsync goal for most cases. With wilffly I often have to run a Build and Run after making such changes. But the majority of the time, the DevMode plugin correctly handles changes to the front end. 

<pre>
  <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>${gwt.version}</version>
                <executions>
                    <execution>
                        <goals>                            
                            <goal>compile</goal>
                            <goal>generateAsync</goal>        
                        </goals>
                    </execution>
                </executions> 
                <configuration>
                    <noServer>true</noServer>
                    <runTarget>YourAppNameHere</runTarget>
                    <port>8080</port>
                    <extraJvmArgs>-Xmx4g -Xms2g</extraJvmArgs>
                </configuration>    
            </plugin>
</pre>

Thomas Broyer

unread,
Aug 27, 2018, 6:53:36 PM8/27/18
to GWT Users
Sorry if I wasn't clear: DevMode with -noserver is basically the same as CodeServer. The embedded server is discouraged, not CodeServer (or DevMode with -noserver).

管理人です。

unread,
Aug 27, 2018, 8:07:44 PM8/27/18
to google-we...@googlegroups.com
If possible, you should use Super dev mode.
If you install tomcat on the embedded server, you can use it without problems.
I am using Raspberry pi

2018年8月28日(火) 7:53 Thomas Broyer <t.br...@gmail.com>:
Sorry if I wasn't clear: DevMode with -noserver is basically the same as CodeServer. The embedded server is discouraged, not CodeServer (or DevMode with -noserver).

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Andrew Somerville

unread,
Aug 28, 2018, 8:04:32 AM8/28/18
to GWT Users
Correct, the code server is the only component I'm using. 

Thomas Broyer

unread,
Aug 28, 2018, 2:32:00 PM8/28/18
to GWT Users
Oh please don't confuse things further! "embedded" as is "running within the same process as DevMode", not a "small hardware device"
Reply all
Reply to author
Forward
0 new messages