-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Jetty 12 FileID no longer recognizes "jar" extension as isWebArchiveFile #12889
Comments
For the record, the deployment process is being rewritten in 12.1.x to fix various things. See The ContextProvider and WebAppProvider don't actually exist anymore, starting in 12.1.0 |
The support for JAR as a webarchive was deprecate the moment Java introduced Multi-Release JAR file format. The replacement deployer in Jetty 12.1.0 already address your other concerns. |
Closing. Not going to be fixed by adding jar back to FileID.isWebArchive methods in Jetty 12.0.x There are other FileID methods present that better identify the role of the file (eg: isLibArchive, isJavaArchive, isArchive, etc) As for the behavior in Deploy, please wait for Jetty 12.1.0 and test again, if you still have a feature request, file it against that codebase. |
@joakime I'm just going to reopen this for a little bit to find out exactly what the use-case is. @gonphsn Can you detail your use-case a bit more. What exactly do you mean by "webapp enabled jars"? how are they produced and why are they not war files? |
Our jar files are built to contain the WEB-INF directory at the top level: These jar files were utilized by WebAppProvider to build the respective servlet that the jar provides when installed. They are not *war files because Jetty WebAppProvider facilitated using *.jar as the source file, and not exclusively *.war files. It worked, so we used it. Jars could be used in 9/10/11, and now they have been (purposefully) disabled in 12. We are prepared to wait for 12.1 for the more orthodox solution, but our current model of deployment will be dependent on Jetty 12.1 providing a way to use jar files as the source of the WEB-INF directory. |
A WEB-INF should either be in a WAR file, or a web-fragment. |
Actually, in |
This issue was opened against the local filesystem scanner deployer, not osgi. The osgi layers don't even use this local filesystem scanner deployer. Also, the osgi layers in 12.1.0 don't have issue with FileID.isWebArchive excluding |
As 9/10/11 have accepted jar files as deployable files without any reported problems, then I'm inclined to consider supporting this. I.e. a jar file that does contain a WEB-INF should be OK to deploy, but one that doesn't should not be deployed (unlike a war file without a WEB-INF). I.e the criteria to deploy an archive should be : named *.war OR contains WEB-INF. |
@gregw that means cracking open and investigating every jar we see for that WEB-INF directory during deployment scanning, right? I was going to say that an exploded JAR would need special attention, but that isn't really the case, a directory that came from an extracted JAR or WAR would look the same. |
We'd only have to crack open any jar files that are dropped in the top level of
Yes - that would do it. Let the jar files be passed all the way in, then when creating the ContextHandler (when we crack open the archive anyway), if there is neither a
We'd need to check as we exploded. If the user explodes, then OK |
We check if it is a |
Basically, if we intend to support this, then the change will be in many more places than just the deploy scanner. |
@joakime but we have supported it in the past, so I'm assuming most code will be OK with it. I.e. unless we explicitly changed it in those many places when we removed it from the supported paths check, then we should be fine. It's an easy thing to test. |
Just tested this on Jetty 10.0.24, you cannot have a JAR in Looking at the Link to WebAppProvider.FileFilter in 10.0.24 The statement from the OP that it works in Jetty 10/11 isn't accurate. |
The code we use in 9/10/11 is:
This functions to create a WebAppContext because getConextHandler considers jar files as satisfying the "isWebArchiveFile":
The parallel effort in Jetty 12 with WebAppProvider -> ContextProvider:
no longer functions because the Jetty 12 ContextProvider continues to use:
Meaning that our workflow permitted the creation of a context handler with jar files in 9/10/11 and now it no longer functions in 12 because ContextProvider no longer considers a "jar" file as a candidate. I could re-compile and test, but my initial impression was yes, it makes sense to update the definition of isWebArchive to exclusively apply to "war" files; however, if that is the case, is it reasonable that Jetty 12 ContextProvider is modified to:
This is almost certainly moot if you say that you will be completely overhauling the ContextProvider in 12.1 (which we will absolutely adopt), but just trying to raise awareness that:
We will have to significantly restructure our servlet deployment if this is something that can't be supported, but my impression of the code is that this was not explicitly prevented in any way by how 9/10/11 ContextProvider was implemented. I just got the impression that isWebArchive was changed (which I believe makes total sense) but that then ContextProvider was not updated to reflect that it needed an extra conditional. I think our use case was abnormal and something that fell through the cracks, but it definitely does function - even perhaps unintentionally - for 9/10/11 just fine. |
You are not using the The behavior you have is more akin to a custom When PR #12583 merges for Jetty 12.1.x then you have other options to make it work. |
The Jetty 12.1.0.alpha2 release is now available on Maven Central. Your code would look something like this with that version of Jetty ... Deployer deployer = server.getBean(Deployer.class);
Environment environment = Environment.ensure("ee11", WebAppContext.class);
ContextHandlerFactory contextHandlerFactory = new StandardContextHandlerFactory();
// Iterate through all modules that are Web Archives and load them into Jetty.
Arrays.stream((ModuleInfo[])Sys.getRegistry().getModules())
.forEach(info ->
{
SecurityUtil.doPrivileged((PrivilegedAction<Void>)() ->
{
try
{
ContextHandler contextHandler = contextHandlerFactory.newContextHandler(
server,
environment,
module.getFile().toPath()
module.getOtherFilePaths()
attributes);
deployer.deploy(contextHandler); The The You can optionally make your entire Arrays.forEach a Jetty bean and have it be part of the lifecycle of Jetty as well. |
Ok, we will re-evaluate against the "jetty-12.1.x" artifacts and re-submit under that context if necessary. For posterity, the exception we see at present in 12.0 is:
|
Jetty version(s)
Compare Jetty 9/10/11 to Jetty 12.0.16
Jetty Environment
jetty-core
Java version/vendor
(use: java -version)
openjdk version "21.0.6" 2025-01-21 LTS
OpenJDK Runtime Environment Zulu21.40+18-SA (build 21.0.6+7-LTS)
OpenJDK 64-Bit Server VM Zulu21.40+18-SA (build 21.0.6+7-LTS, mixed mode, sharing)
OS type/version
Windows, but behavior would be OS agnostic
Description
The Jetty 12 FIleID utility class no longer recognizes "jar" as a succesful case of isWebArchiveFile().
See Jetty 9/10/11:
See Jetty 12:
In practice this means I can no longer use ContextProvider (previously WebAppProvider) as a way to deploy webapp enabled jars:
I empathize with the new implementation of FileID to avoid conflating "jar" and "war" extensions; however, would it not be sensible to then modify the ContextProvider.java to:
To carry forward the Jetty 9/10/11 deployment capabilities of ContextProvider?
How to reproduce?
Call FileID.isWebArchive("foo.jar"), observe false return value. Or rather, observe that you cannot use "jar" files to deploy webapps via ContextProvider in the same manner as they were with WebAppProvider.
The text was updated successfully, but these errors were encountered: