Using Java 11 on the server to implement GWT-RPC services

397 views
Skip to first unread message

Adrian Smith

unread,
Jul 17, 2019, 4:56:58 AM7/17/19
to GWT Users
I understand that GWT 2.8.2 supports translation of Java 8 syntax, and not Java 11.

But I thought there might be a good chance that could use Java 11 features on the server (e.g. Jetty) that responds to GWT-RPC requests.

This works fine in deployment mode: Mark the project as Java 11 in Maven, compile the WAR with Maven, GWT creates the JS fine, and then the Java 11 servlet container executes the WAR fine, and the server code can make use of Java 11 features.

However in "super dev mode" it doesn't work, and also doesn't really give an errors (neither on the console in Maven, nor in the "Jetty" tab of the "super dev mode" console.)

With a Java 11 JVM but specifying Java 8 in Maven (as is the default from the Maven archtetype), everything works fine:

$ java -version
openjdk version "11.0.2" 2019-01-15
$ ~/Downloads/gwt-2.8.2/webAppCreator -templates maven,sample -out Foo com.mycompany.Foo
$ cd Foo
$ mvn clean war:exploded gwt:devmode

That all works fine.

However, when I change, in the pom.xml

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

Then when I execute 

$ mvn clean war:exploded gwt:devmode

The "super dev mode" console opens, however when I click on "Launch Default Browser" I see "503 Service Unavailable" in the browser. That error message comes from Jetty.

There is a note in the "Jetty" tab of the "super dev mode" console about the 503 but just request/response headers and no further information. There is also nothing printed to the terminal console where I executed the "mvn" command.

Note: I have not changed the source code at all. It's the default Maven archetype source code, which doesn't use any Java 11 syntax.

I have also tried changing the <sourceLevel>1.8</sourceLevel> in Maven's GWT plugin section, however, as I expected, that failed immediately with a clear error message that the GWT compiler doesn't support > 1.8, which is fine. I know that's a lot of work, but I figured I could at least use Java 11 features on the server.

Am I missing something simple, or is this more complex than I imagine and thus is not supported?

Thomas Broyer

unread,
Jul 17, 2019, 5:12:26 AM7/17/19
to GWT Users
This is again a case where splitting client and server code into separate Maven modules will help (see https://github.com/tbroyer/gwt-maven-archetypes/).
The problem here is (probably) that GWT tries to load the compiled classes, and can't because it doesn't understand Java 11 bytecode.
So you'll want to compile the shared and client code to Java 8 bytecode, and the server-only code to Java 11 bytecode.

Yuichi Sugimura

unread,
Jul 17, 2019, 5:31:37 AM7/17/19
to google-we...@googlegroups.com
Hello, I've got the very same situation but in the different environment.

I think perhaps it is because old version of jetty(9.2) is embedded in
gwt-dev.jar(2.3.2). This version of jetty doesn't seem to run on Java9
or later.

So you should exclude org.eclipse.jetty package from gwt-dev.jar and
attach newer version of jetty to classpath.

Here's my blog post(in Japanese) about this. Maybe you can use some
translation site.

https://www.gwtcenter.com/execute-gwt282-on-java9-or-later

Hope this helps.
> --
> 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
> <mailto:google-web-tool...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-web-toolkit/f3185b58-73f2-4e21-8775-bdc393e24d24%40googlegroups.com
> <https://groups.google.com/d/msgid/google-web-toolkit/f3185b58-73f2-4e21-8775-bdc393e24d24%40googlegroups.com?utm_medium=email&utm_source=footer>.

Adrian Smith

unread,
Jul 17, 2019, 6:53:20 AM7/17/19
to GWT Users
Hello Thomas,

Thanks for the answer about splitting the Maven modules. That worked great!

In case anyone else is trying it, here's what I did:
  • Used the "mvn archetype:generate" from the link https://github.com/tbroyer/gwt-maven-archetypes/ with the artifact "modular-webapp"
  • In the root "pom.xml" upgraded the "jetty-maven-plugin" to the latest version I found on Maven Central (I used "9.4.19.v20190610")
  • In the "server/pom.xml" added a plugin like
         <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
            <source>11</source>
            <target>11</target>
          </configuration>
        </plugin>
  • Followed the rest of the instructions to run the software from the link above
This approach also has the advantage that the IDE understands that the "server" part is Java 11 but the "client" and "shared" sections are Java 8 and can show appropriate syntax errors (e.g. usage of "var" keyword).

Thanks again,
Adrian

Adrian Smith

unread,
Jul 17, 2019, 9:10:08 AM7/17/19
to GWT Users
Thanks Yuichi,

It turns out in the Super Dev Mode UI in the Jetty tab there was an error that Jetty couldn't start, and clicking on that showed me the stack backtrace in the bottom half of the window, and indeed it was some annotation processing problem with Jetty (common problem with older Jetty versions with Java 11).

Thanks to your blog post (translation worked nicely!) I did some investigation. I didn't get your method to work, but I did find out that if I all Maven (super dev mode) with the following command-line I can get my original single-Maven-project to use the Jetty of my choosing, and now Super Dev Mode can serve Java 11 server-side code:

mvn -Djetty.version=9.4.19.v20190610 war:exploded gwt:devmode 

Adrian
Reply all
Reply to author
Forward
0 new messages