Repository navigation
Conversation
- 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
|
@niloc132 |
|
Moved these findings to a formal review with inline comments: #523 (review) |
foal
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
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.