Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix to allow applications to add Jetty servlets and filters. #105

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

lachlan-roberts
Copy link
Collaborator

Jetty Servlets like the DefaultServlet require classes contained in runtime-impl-jetty12.jar to run so it can't be done by the application classloader.

The logic inside AppEngineWebAppContext.startContext is being run before the processing of web.xml and so the Jetty servlets were not being instantiated. I used a hack with a ListenerHolder.doStart to get around this but maybe there is some better interception point for this.

Also server.getDefaultStyleSheet() was returning null due to some classloader behaviour causing the default servlet not to start. So I also have a workaround for this.

@@ -104,12 +106,21 @@ public void start(String serverInfo, ServletEngineAdapter.Config runtimeOptions)
threadPool.setVirtualThreadsExecutor(VirtualThreads.getDefaultVirtualThreadsExecutor());
logger.atInfo().log("Configuring Appengine web server virtual threads.");
}

// The server.getDefaultStyleSheet() returns is returning null because of some classloading issue,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you be either more or less vague than "some classloading issue"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Turned this into a TODO to investigate why we need to do this, otherwise I could just remove the comment all together.

@gregw
Copy link
Contributor

gregw commented Mar 22, 2024

@lachlan-roberts the issue is that jetty-9 had a startWebapp() method that allowed interception of startup after metadata.resolve.
This is not present in jetty-12 in any environment. I will put it back. So this PR is OK if the fix is needed now, but ideally we should wait for the next release of jetty-12 with the proper fix.

@gregw
Copy link
Contributor

gregw commented Mar 22, 2024

@lachlan-roberts I have opened jetty/jetty.project#11553

@lachlan-roberts
Copy link
Collaborator Author

@gregw @ludoch I updated this to use the startWebapp() method from 12.0.8 so this is ready to merge.

@ludoch ludoch removed their request for review April 24, 2024 02:38
@copybara-service copybara-service bot merged commit 97f644a into main Apr 24, 2024
7 checks passed
@lachlan-roberts lachlan-roberts deleted the defaultServlet-classloading branch April 24, 2024 03:14
srinjoyray pushed a commit that referenced this pull request Nov 12, 2024
…loading

PiperOrigin-RevId: 627582402
Change-Id: Ib2ff3d4d9af285738adf92ffe3bc90014338982f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants