Skip to content

Added Support to launch Jetty 12 from Eclipse. - #523

Open
keinhaar wants to merge 2 commits into
gwt-plugins:mainfrom
keinhaar:jetty12launcher
Open

keinhaar wants to merge 2 commits into
gwt-plugins:mainfrom
keinhaar:jetty12launcher

Conversation

@keinhaar

Copy link
Copy Markdown
Contributor
  • added com.gwtplugins.eclipse.jettylauncher plugin
  • Removed non existing classpath entry.
  • do not warn about size if gwt-servlet-jakarta.jar is used.
  • do not copy gwt-servlet.jar if gwt-servlet-jakarta.jar is used.
  • use tycho 3.0.5

This will add an integrated Jetty 12 Launcher.
On the Eclipse Server Tab you can choose between "No Server", the build in Jetty 9 Server, Jetty 12 with JEE8 (javax.servlet) or Jetty 12 with JEE 10 (jakarta.servlet)
Launching with Jetty 12 will require to set JETTY_HOME in the environment, and, if jakarta.servlet should be used, adding the jakarta.servlet API to your project.

- added com.gwtplugins.eclipse.jettylauncher plugin
- Removed non existing classpath entry.
- do not warn about size if gwt-servlet-jakarta.jar is used.
- do not copy gwt-servlet.jar if gwt-servlet-jakarta.jar is used.
- use tycho 3.0.5
@keinhaar

Copy link
Copy Markdown
Contributor Author

@niloc132
Hi Colin, could you please have a look on the error in the CI build?
Seems like the gwt version cannot be extracted from the zip.
The branch builds without problems on my system. So i dont know what to do now.

@keinhaar
keinhaar requested a review from protoism September 21, 2026 12:09
@foal foal self-assigned this Nov 15, 2026
@foal

foal commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Moved these findings to a formal review with inline comments: #523 (review)

@foal foal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this! Selecting Jetty 12 with either EE8 (javax.servlet) or EE10 (jakarta.servlet) directly in Eclipse would be useful.

I reviewed 240e55d. I have not run the plugin in Eclipse, so this review is based on the source. I am requesting changes for the runtime correctness issues described inline: the container lifecycle, startup failure propagation, automatic port reporting, bind address handling, context classloader restoration, and installation validation. The cache policy comment is a non-blocking development-workflow suggestion.

To validate the behavior, I would suggest smoke tests for both EE8 and EE10 covering a fixed port, an automatically assigned port, an occupied port, loopback binding, application refresh, shutdown, and a missing or incomplete JETTY_HOME. Given the custom classloader delegation policy, coverage for additional application dependencies and service-provider loading would also be useful.

}

@Override
public void stop() throws UnableToCompleteException

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement the container lifecycle. stop() and refresh() are both empty, and startServer() only keeps the Server in a local variable. GWT therefore cannot stop Jetty through the container API or reload the web application after server-side changes. Please retain the server and web application context, implement shutdown, and make refresh reload the application and updated classes. Terminating the whole JVM from Eclipse can hide the shutdown issue, but does not cover these lifecycle operations.

}
catch (Exception e)
{
e.printStackTrace();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Propagate startup failures. If startup fails, for example because the port is occupied, this catch block prints the exception and still allows the launcher to return a container. Please propagate startup errors through ServletContainerLauncher.start(), preserving BindException where applicable, and clean up partially started resources. Since bootstrap is invoked reflectively, please also unwrap InvocationTargetException in the launcher so callers receive the original exception type.

@Override
public int getPort()
{
return port;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return the actual bound port. With automatic port selection (port == 0), Jetty chooses a free port, but getPort() still returns 0. This gives GWT the wrong server address. Please capture connector.getLocalPort() after startup and return that value.

QueuedThreadPool pool = createThreadPool();
Server server = new Server(pool);
ServerConnector connector = new ServerConnector(server);
connector.setPort(port);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honor the configured bind address. The launcher does not override setBindAddress(), and this connector only receives a port. An explicit loopback address supplied by GWT is therefore ignored. Please retain the configured address in the launcher, pass it through to the container, and apply it with ServerConnector.setHost() before startup so developers can restrict the server to localhost.

public ServletContainer start(TreeLogger logger, int port, File appRootDir) throws BindException, Exception {
// A custom Classloader to separate the classes of the webapp and app server from the rest of the system.
Jetty12ClassLoader cl = new Jetty12ClassLoader(getJEEVersion());
Thread.currentThread().setContextClassLoader(cl);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restore the calling thread's context classloader. This changes the context classloader for the caller and leaves it changed on both success and failure. Subsequent work on that thread can then use the Jetty-specific loader unexpectedly. Please save the previous value and restore it in a finally block around bootstrap loading and invocation.


private void addJarsFrom(List<URL> urls, File dir, JEEVersion jeeVersion) throws IOException
{
File[] files = dir.listFiles();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle missing or unreadable library directories explicitly. File.listFiles() can return null, which the following loop dereferences. A missing directory in an incomplete or differently configured Jetty installation therefore produces a NullPointerException rather than a useful setup error. Please validate required directories and report their paths in a descriptive exception; handle optional directories explicitly.

DefaultServlet defaultServlet = new DefaultServlet();
ServletHolder holder = new ServletHolder(defaultServlet);
holder.setInitParameter("useFileMappedBuffer", "false");
holder.setInitParameter("cacheControl", "max-age=600, public"); // 10 Minuten Cachen

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider a development-friendly cache policy (non-blocking). This sets a ten-minute public cache policy for static resources; the EE8 implementation does the same. Developers may keep seeing stale resources after edits. Could the default be reconsidered or made configurable, particularly for resources such as *.nocache.js?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants