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

Unable to load resources from webjars and MVNPM in dev mode in 3.7.1 #38576

Closed
itatdcer opened this issue Feb 4, 2024 · 14 comments
Closed

Unable to load resources from webjars and MVNPM in dev mode in 3.7.1 #38576

itatdcer opened this issue Feb 4, 2024 · 14 comments
Labels
area/vertx kind/bug Something isn't working triage/upstream Used for issues which are caused by issues in upstream projects/dependency

Comments

@itatdcer
Copy link

itatdcer commented Feb 4, 2024

Describe the bug

Using webjars where the artifactId has a dash stopped working in Quarkus 3.7.1. It worked with previous versions.

Expected behavior

Serve static resoyrec as excpeted

Actual behavior

Content not found

How to Reproduce?

In maven, declare:

<dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-webjars-locator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.webjars.npm</groupId>
            <artifactId>bootstrap-icons</artifactId>
            <version>1.11.2</version>
        </dependency>

In a html file, use:

<link rel="stylesheet" media="screen" href="/webjars/bootstrap-icons/font/bootstrap-icons.css" />

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@itatdcer itatdcer added the kind/bug Something isn't working label Feb 4, 2024
@yrodiere
Copy link
Member

yrodiere commented Feb 5, 2024

Thanks for reporting. I'm not qualified to investigate but will try to find someone who is.

I'm not sure who maintains this module... history would suggest @phillip-kruger maybe? @majlantalik also made a change recently.

Also, @geoand @gsmet I'm really not sure how to tag this one; should we add a area/web label on GitHub?

@phillip-kruger
Copy link
Member

I think @cescoffier is looking at this. A.f.a.i.k it's in vertx

@cescoffier
Copy link
Member

Do you u have the stack trace or a reproducer?

I do not believe my fix is related to - in names, but was working around some weird error in the JDK Jar api

@itatdcer
Copy link
Author

itatdcer commented Feb 5, 2024

I created a new project from code start. You can get it here: https://github.com/itatdcer/webjars-error-reproducer

You can change in pom.xml the platform version between 3.6.3 (works) and 3.7.1 (error). Just access the index.html page and check network error getting the cc file.

The stack trace:

2024-02-05 08:43:04,353 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, qute, resteasy-reactive, resteasy-reactive-jackson, smallrye-context-propagation, vertx, webjars-locator]                                                                                                                                                      
2024-02-05 08:43:23,153 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (vert.x-eventloop-thread-1) HTTP Request to /webjars/bootstrap-icons/1.11.2/font/bootstrap-icons.css failed, error id: 6045c762-c13d-4a9c-9e6b-1a5d242352d3-1: io.vertx.core.VertxException: Unable to unpack file at path 'jar:file:///home/seseso/.m2/repository/org/webjars/npm/bootstrap-icons/1.11.2/bootstrap-icons-1.11.2.jar!/META-INF/resources/webjars/bootstrap-icons/1.11.2/font'                                                                                                                                                                                                                                                
        at io.vertx.core.file.impl.FileResolverImpl.unpackFromJarURL(FileResolverImpl.java:360)                                                                                                                                                                                                                                                           
        at io.vertx.core.file.impl.FileResolverImpl.unpackUrlResource(FileResolverImpl.java:247)                                                                                                                                                                                                                                                          
        at io.vertx.core.file.impl.FileResolverImpl.resolveFile(FileResolverImpl.java:170)
        at io.vertx.core.impl.VertxImpl.resolveFile(VertxImpl.java:929)
        at io.vertx.core.file.impl.FileSystemImpl$20.perform(FileSystemImpl.java:1135)
        at io.vertx.core.file.impl.FileSystemImpl$20.perform(FileSystemImpl.java:1133)
        at io.vertx.core.file.impl.FileSystemImpl$BlockingAction.handle(FileSystemImpl.java:1174)
        at io.vertx.core.file.impl.FileSystemImpl$BlockingAction.handle(FileSystemImpl.java:1156)
        at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:190)
        at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:276)
        at io.vertx.core.impl.ContextImpl.lambda$internalExecuteBlocking$2(ContextImpl.java:209)
        at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.io.FileNotFoundException: JAR entry META-INF/resources/webjars/bootstrap-icons/1.11.2/font not found in /home/seseso/.m2/repository/org/webjars/npm/bootstrap-icons/1.11.2/bootstrap-icons-1.11.2.jar
        at java.base/sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:146)
        at java.base/sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:92)
        at io.vertx.core.file.impl.FileResolverImpl.unpackFromJarURL(FileResolverImpl.java:320)
        ... 18 more

@cescoffier
Copy link
Member

thanks! At least, the exception looks the same, so, my fix should work (trying now).

@vietj here is another reproducer.

@geoand
Copy link
Contributor

geoand commented Feb 5, 2024

This is indeed a serious problem as @cescoffier and I encountered in on Friday while we also had someone report something similar in Zulip

@cescoffier
Copy link
Member

cescoffier commented Feb 5, 2024

My fix works, but I'm not sure it's totally correct. It looks very weird, and I am unable to reproduce it in a pure vertx setup.

@yrodiere yrodiere changed the title wejars with "-" in artefactId stopped working in 3.7.1 webjars with "-" in artefactId stopped working in 3.7.1 Feb 5, 2024
@cescoffier
Copy link
Member

So... it's a classloading issue or some friction between the Quarkus classloader used in dev (the prod classloader is different and does not trigger the problem - to be validated) and Vert.x.

@cescoffier cescoffier changed the title webjars with "-" in artefactId stopped working in 3.7.1 Unable to load resoruces from webjars and MVNPM in dev mode in 3.7.1 Feb 5, 2024
@cescoffier cescoffier changed the title Unable to load resoruces from webjars and MVNPM in dev mode in 3.7.1 Unable to load resources from webjars and MVNPM in dev mode in 3.7.1 Feb 5, 2024
@cescoffier
Copy link
Member

So, the issue is that in dev mode, the Quarkus classloader provides URLs for directories found in Jar files. However, Jar Files do not include directories, which means that if the FileResolver from Vert.x tries to open that URL, it fails.

I've opened a PR in Vert.x to make the code more robust and detect this case.

@cescoffier
Copy link
Member

My Vert.x fix has been merged (well, the second rewrite of the fix). Waiting for the vert.x release.

@cescoffier cescoffier added the triage/upstream Used for issues which are caused by issues in upstream projects/dependency label Feb 5, 2024
@geoand
Copy link
Contributor

geoand commented Feb 5, 2024

Thanks a ton @cescoffier!

@cescoffier
Copy link
Member

I should add that it's not a "pure" Vert.x issue, it's a joint responsibility between Quarkus (having a classloader returning URLs for directories) and Vert.x. We decided that fixing it in Vert.x was easier and safer.

@geoand
Copy link
Contributor

geoand commented Feb 5, 2024

Great call!

cescoffier added a commit to cescoffier/quarkus that referenced this issue Feb 7, 2024
The only detected breaking changes are related to the vertx-mutiny-http-proxy module which is not used in Quarkus.

Full release notes are there: https://github.com/vert-x3/wiki/wiki/4.5.3-Release-Notes.

Important:
 - Fix CVE-2024-1300 io.vertx:vertx-core: memory leak when a TCP server is configured with TLS and SNI support
 - Fix the classloading issue for NVMPN and WebJars in dev mode (quarkusio#38576)
gsmet pushed a commit to cescoffier/quarkus that referenced this issue Feb 7, 2024
The only detected breaking changes are related to the vertx-mutiny-http-proxy module which is not used in Quarkus.

Full release notes are there: https://github.com/vert-x3/wiki/wiki/4.5.3-Release-Notes.

Important:
 - Fix CVE-2024-1300 io.vertx:vertx-core: memory leak when a TCP server is configured with TLS and SNI support
 - Fix the classloading issue for NVMPN and WebJars in dev mode (quarkusio#38576)
@cescoffier
Copy link
Member

Closed with the vert.x upgrade

gsmet pushed a commit to gsmet/quarkus that referenced this issue Feb 7, 2024
The only detected breaking changes are related to the vertx-mutiny-http-proxy module which is not used in Quarkus.

Full release notes are there: https://github.com/vert-x3/wiki/wiki/4.5.3-Release-Notes.

Important:
 - Fix CVE-2024-1300 io.vertx:vertx-core: memory leak when a TCP server is configured with TLS and SNI support
 - Fix the classloading issue for NVMPN and WebJars in dev mode (quarkusio#38576)
(cherry picked from commit 7bcbb99)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vertx kind/bug Something isn't working triage/upstream Used for issues which are caused by issues in upstream projects/dependency
Projects
None yet
Development

No branches or pull requests

5 participants