I maintain a GWT multi-module maven project dated back to the good old golden GWT-days. We were able to debug the GWT application till now relying on classic dev mode but now due to security concerns , we are trying to setup our dev environment (Eclipse IDE) to use Super Dev Mode.
But when it comes to development, hence running Super Dev Mode, we've been encountering a bindException( ports clashing) when we try to start CodeServer.
Please find below the configs used and what exceptions we encountered:
Super Dev Mode (launcher configs)
main class: com.google.gwt.dev.DevMode
-logLevel INFO -port 8889 -remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -codeServerPort 9997 -war {directory to web app} -workDir {work directory} {module}
Observation:
Super Dev Mode starts correctly and has been configured to run on port 9997:
http://127.0.0.1:8889/app.html
Next step is I tried to launch the CodeServer:
CodeServer (launcher configs)
main class: com.google.gwt.dev.codeserver.CodeServer
-logLevel INFO -port 9876 -workDir {work directory} -src src/ {module}
Observation:
The following exception is obtained and subsequently, codeserver is never started.
[main] WARN org.eclipse.jetty.util.component.AbstractLifeCycle - FAILED ServerConnector@5c168f93{HTTP/1.1}{127.0.0.1:9876}: java.net.BindException: Address already in use java.net.BindException: Address already in use
From there, no other clues (error-out or stacktraces) are visible to me. After spending three days on the issue so far, seems we are hitting a wall here.
My queries are the following:
- Definitely the ports are clashing between CodeServer and Super Dev Mode. How can the CodeServer and Super Dev Mode be configured to work on same ports?
- when starting up the Super Dev Mode, does it internally also launches a codeserver instance on port 9876 by default.
Love to share my findings if you face similar hurdles.
Best, Javed
p.s.: In a Java 8 environment, I am able to use GWT 2.9.0 and it's Super Dev Mode (via Eclipse and thomas broyer's gwt-maven-plugin). @tbroyer p.s: when the module web page is accessed, it's still reaching out to codeserver on port 9876 (though codeserver has been configured to run on 9877)
First a small clarification:
CodeServeris Super Dev Mode, just asDevModeis. The chief difference betweenCodeServerandDevModeis thatDevModealso starts a simple application server on port 8888 by default.As such, you should not be running
CodeServerandDevModeat the same time for the same project. If you are running two projects at the same time, naturally there will be a conflict of some kind, so picking different ports is required. With that said, CodeServer/DevMode is capable of running multiple modules at the same time, as long as their classpaths are compatible.Finally, running
DevModeto run the built-in Jetty is deprecated in GWT (and is discouraged in thenet.ltgt.gwt.mavenplugin as well, see https://github.com/tbroyer/gwt-maven-archetypes/?tab=readme-ov-file#start-the-development-mode - except for windows, unless you apply the linked issue's workaround) - instead, run your own dev server, withCodeServer'slauncherDir(or DevMode'swarDir) set to create JS content that your own dev server can offer to the browser when it changes (the same as if you were editing js/html/css by hand, or using npm/etc).If the above doesn't solve your question, you might be hitting an issue where the browser stays connected to port
9876even though the server has stopped, so you cannot restart the server. I've filed https://github.com/gwtproject/gwt/issues/9944 and will put up a patch soon to fix this.Here's the full stack trace, which shows that CodeServer is called as part of DevMode doing its own work (and showing the exception you are seeing):