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

Changes to Resource no longer support custom url schemes. #8886

Closed
janbartel opened this issue Nov 11, 2022 · 5 comments · Fixed by #8888
Closed

Changes to Resource no longer support custom url schemes. #8886

janbartel opened this issue Nov 11, 2022 · 5 comments · Fixed by #8888
Assignees
Labels
Bug For general bugs on Jetty side High Priority

Comments

@janbartel
Copy link
Contributor

jetty-12

In previous versions of jetty, a call like Resource.newResource("bundleresource://62.fwk1116834242/org/eclipse/jetty/webapp/webdefault.xml") would return a URLResource that could be used to eg open an input stream and read the xml content.

In jetty-12, we get the following exception instead:

Found defaults descriptor via WebXmlConfiguration.classloader: bundleresource://62.fwk1116834242/org/eclipse/jetty/ee9/webapp/webdefault-ee9.xml
2022-11-11 13:53:43.834:WARN :oejew.WebAppContext:Start Level: Equinox Container: ac1d208f-4617-41a3-b6a8-a7a1b3d9eea7: Failed startup of context o.e.j.e.w.WebAppContext@7a8e2a3c{ROOT,/,jar:file:///home/janb/src/jetty-eclipse/jetty-12.0.x/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/target/1668135220776-0/org.eclipse.osgi/89/0/bundleFile!/,false}{jar:file:/home/janb/src/jetty-eclipse/jetty-12.0.x/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/target/1668135220776-0/org.eclipse.osgi/89/0/bundleFile!/}
java.nio.file.FileSystemNotFoundException: Provider "bundleresource" not installed
at java.base/java.nio.file.Path.of(Path.java:212)
at java.base/java.nio.file.Paths.get(Paths.java:98)
at org.eclipse.jetty.util.resource.MountedPathResource.of(MountedPathResource.java:33)
at org.eclipse.jetty.util.resource.Resource.create(Resource.java:91)
at org.eclipse.jetty.util.resource.ResourceFactoryInternals$LifeCycle.newResource(ResourceFactoryInternals.java:113)
at org.eclipse.jetty.ee9.webapp.WebXmlConfiguration.preConfigure(WebXmlConfiguration.java:67)
at org.eclipse.jetty.ee9.webapp.Configurations.preConfigure(Configurations.java:498)
at org.eclipse.jetty.ee9.webapp.WebAppContext.preConfigure(WebAppContext.java:499)
at org.eclipse.jetty.ee9.webapp.WebAppContext.doStart(WebAppContext.java:528)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:171)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.Handler$Abstract.doStart(Handler.java:391)
at org.eclipse.jetty.server.handler.ContextHandler.lambda$doStart$0(ContextHandler.java:535)
at org.eclipse.jetty.server.handler.ContextHandler$Context.call(ContextHandler.java:1053)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:535)
at org.eclipse.jetty.ee9.nested.ContextHandler$CoreContextHandler.doStart(ContextHandler.java:2391)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:40)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:183)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:519)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:165)
at org.eclipse.jetty.osgi.BundleWebAppProvider.bundleAdded(BundleWebAppProvider.java:202)
at org.eclipse.jetty.osgi.BundleWebAppProvider$WebAppTracker.addingBundle(BundleWebAppProvider.java:72)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:477)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:422)
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:258)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:231)
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:452)
at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:949)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:229)
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:138)
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:130)
at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:217)
at org.eclipse.osgi.container.Module.publishEvent(Module.java:499)
at org.eclipse.osgi.container.Module.start(Module.java:486)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1852)
at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1845)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1788)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1750)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1672)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)

@janbartel janbartel added the Bug For general bugs on Jetty side label Nov 11, 2022
@janbartel janbartel moved this to To do in Jetty 12.0.ALPHAS Nov 11, 2022
@gregw
Copy link
Contributor

gregw commented Nov 11, 2022

@lorban @joakime can one of you take this issue. Moderately important as it is blocking Jan's work.

I think the issue is here: https://github.com/eclipse/jetty.project/blob/jetty-12.0.x/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java#L87-L91

We assume a URI is either able to be handled by PathResource or it can be mounted. This is not true for URIs that have some arbitrary scheme and a UrlStreamHandler installed for them.

So I think we need to revive UrlResource and come up with some logic to determine which scheme to use it for. There is a private method: java.net.URL#providers that discovers all the providers, so I guess we can do the same thing to get a list. But do we use that as a black list or a white list? as there will be handlers for things like "file", which we want Path to handle, and things like "jar" that we want to mount.

Perhaps we just have a curated list of protocols that we will mount and everything else is tried a UrlResource as last gasp effort?

@joakime
Copy link
Contributor

joakime commented Nov 11, 2022

We should be super wary of supporting custom URL streams in the long run.
The JDK is undergoing some serious changes for how this works ATM.

@joakime
Copy link
Contributor

joakime commented Nov 11, 2022

Opened PR #8888 to experiment with having Resource be created from a registered list of URI schemes that can results in a ResourceFactory that knows how to support that URI scheme.
See ResourceFactoryTest there for example

@lorban
Copy link
Contributor

lorban commented Nov 11, 2022

This also looks related: https://bugs.eclipse.org/bugs/show_bug.cgi?id=570590

joakime added a commit that referenced this issue Nov 23, 2022
…e-schemes

Issue #8886 - support extensible Resource URI schemes
@joakime
Copy link
Contributor

joakime commented Dec 1, 2022

Closing, addressed in PR #8888

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side High Priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants