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

"not an allowed scheme" for GraalVM Native-Image resource:-URIs #11040

Closed
kohlschuetter opened this issue Dec 11, 2023 · 3 comments · Fixed by #11057
Closed

"not an allowed scheme" for GraalVM Native-Image resource:-URIs #11040

kohlschuetter opened this issue Dec 11, 2023 · 3 comments · Fixed by #11057
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@kohlschuetter
Copy link
Contributor

kohlschuetter commented Dec 11, 2023

Jetty version(s)
12.0.4

Jetty Environment
tested with ee10

Java version/vendor (use: java -version)
java version "21.0.1" 2023-10-17
Java(TM) SE Runtime Environment Oracle GraalVM 21.0.1+12.1 (build 21.0.1+12-jvmci-23.1-b19)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 21.0.1+12.1 (build 21.0.1+12-jvmci-23.1-b19, mixed mode, sharing)

OS type/version
any, macOS 14

Description
In PR #9136, we landed on a change to support GraalVM Native-Image resource: path URIs. Unfortunately, that seems to no longer completely work on recent GraalVM versions, or maybe I'm hitting code that I haven't triggered before.

How to reproduce?

Try resolving ResourceFactory.root().newResource(new URI("resource:/path/to/some/resource")) (which is the new GraalVM resource scheme). Make sure you try this from a native-image environment.

You'll get:

Exception in thread "main" java.lang.IllegalArgumentException: not an allowed scheme: resource:/path/to/some/resource
	at org.eclipse.jetty.util.resource.PathResource.<init>(PathResource.java:168)
	at org.eclipse.jetty.util.resource.PathResourceFactory.newResource(PathResourceFactory.java:29)
	at org.eclipse.jetty.util.resource.ResourceFactoryInternals$CompositeResourceFactory.newResource(ResourceFactoryInternals.java:232)
...

The reason for this exception is that PathResource has its own set of allowed URI schemes, independent of what is defined in ResourceFactoryInternals. Our previous workaround no longer fully works because Graal issue 5720 was fixed, so we no longer use our workaround GraalIssue5720PathResourceFactory.

A proposed fix is to register the resource: scheme from ResourceFactoryInternals if we detect we're running in native-image.

@kohlschuetter kohlschuetter added the Bug For general bugs on Jetty side label Dec 11, 2023
kohlschuetter added a commit to kohlschuetter/jetty.project that referenced this issue Dec 11, 2023
kohlschuetter added a commit to kohlschuetter/jetty.project that referenced this issue Dec 11, 2023
@joakime joakime self-assigned this Dec 11, 2023
joakime added a commit that referenced this issue Dec 13, 2023
* Using ResourceFactoryInternals.isSupported(URI) instead.
@joakime
Copy link
Contributor

joakime commented Dec 13, 2023

@kohlschuetter can you see if PR #11057 is enough for you?

@joakime joakime moved this to 🏗 In progress in Jetty 12.0.5 - FROZEN Dec 13, 2023
@joakime joakime linked a pull request Dec 13, 2023 that will close this issue
@kohlschuetter
Copy link
Contributor Author

@joakime Confirming that PR #11057 fixes this issue. Thanks!

joakime added a commit that referenced this issue Dec 14, 2023
* Using ResourceFactoryInternals.isSupported(URI) instead.
@joakime
Copy link
Contributor

joakime commented Dec 14, 2023

Merged PR #11057

@joakime joakime closed this as completed Dec 14, 2023
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Jetty 12.0.5 - FROZEN Dec 14, 2023
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
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants