question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Embedded Undertow throws MalformedURLException when archive filename contains characters that are reserved in a URL

See original GitHub issue

Embedded Undertow in WAR stopped working for us since we upgraded to Spring Boot 1.5.2.RELEASE. I tried to make a small sample but can’t reproduce it in the sample. Wonder if any expert can give me some hints from the stack trace.

The problem went away after we switched to Tomcat but we like the small foot-print of Undertow.

The POM segment used to build the WAR,

        <profile>
            <id>prod</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <configuration />
                    </plugin>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>build-info</goal>
                                    <goal>repackage</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-undertow</artifactId>
                </dependency>
            </dependencies>
        </profile>

The exception with stack trace,

2017-05-18 15:37:49.699 ERROR 3732 --- [  XNIO-2 I/O-15] io.undertow.request                      : UT005071: Undertow r
equest failed HttpServerExchange{ GET /catalog-dev/api/providers request {Connection=[keep-alive], Accept=[text/html,app
lication/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8], Accept-Language=[en-US,en;q=0.8], Accept-Encoding=[gzip,
 deflate, sdch], User-Agent=[Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.
0.2987.133 Safari/537.36], Upgrade-Insecure-Requests=[1], Host=[osialr-2008-vmt:8888]} response {}}

java.lang.RuntimeException: java.net.MalformedURLException: No !/ in spec 'file:M:\Source\catalog\search\server\target\c
atalog-server'
        at io.undertow.servlet.handlers.ServletPathMatches.getServletHandlerByPath(ServletPathMatches.java:126)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:151)
        at io.undertow.server.handlers.HttpContinueReadHandler.handleRequest(HttpContinueReadHandler.java:65)
        at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:94)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:211)
        at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:243)
        at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:134)
        at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:148)
        at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:92)
        at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:51)
        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
        at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:291)
        at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:286)
        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
        at org.xnio.nio.QueuedNioTcpServer$1.run(QueuedNioTcpServer.java:128)
        at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:580)
        at org.xnio.nio.WorkerThread.run(WorkerThread.java:464)
Caused by: java.net.MalformedURLException: No !/ in spec 'file:M:\Source\catalog\search\server\target\catalog-server'
        at java.net.URL.<init>(Unknown Source)
        at java.net.URL.<init>(Unknown Source)
        at java.net.URL.<init>(Unknown Source)
        at org.springframework.boot.context.embedded.undertow.JarResourceManager.getResource(JarResourceManager.java:50)

        at org.springframework.boot.context.embedded.undertow.CompositeResourceManager.getResource(CompositeResourceMana
ger.java:51)
        at io.undertow.servlet.handlers.ServletPathMatches.getServletHandlerByPath(ServletPathMatches.java:96)
        ... 16 common frames omitted
Caused by: java.lang.IllegalArgumentException: No !/ in spec 'file:M:\Source\catalog\search\server\target\catalog-server
'
        at org.springframework.boot.loader.jar.Handler.getFileFromSpec(Handler.java:159)
        at org.springframework.boot.loader.jar.Handler.parseURL(Handler.java:149)
        ... 22 common frames omitted

2017-05-18 15:38:09.312 ERROR 3732 --- [  XNIO-2 I/O-15] io.undertow.request                      : UT005071: Undertow r
equest failed HttpServerExchange{ GET /catalog-dev/api/groups request {Connection=[keep-alive], Accept=[text/html,applic
ation/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8], Accept-Language=[en-US,en;q=0.8], Accept-Encoding=[gzip, de
flate, sdch], User-Agent=[Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2
987.133 Safari/537.36], Upgrade-Insecure-Requests=[1], Host=[osialr-2008-vmt:8888]} response {}}

java.lang.RuntimeException: java.net.MalformedURLException: No !/ in spec 'file:M:\Source\catalog\search\server\target\c
atalog-server'
        at io.undertow.servlet.handlers.ServletPathMatches.getServletHandlerByPath(ServletPathMatches.java:126)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:151)
        at io.undertow.server.handlers.HttpContinueReadHandler.handleRequest(HttpContinueReadHandler.java:65)
        at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:94)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:211)
        at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:243)
        at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:134)
        at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:58)
        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
        at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
        at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:88)
        at org.xnio.nio.WorkerThread.run(WorkerThread.java:559)
Caused by: java.net.MalformedURLException: No !/ in spec 'file:M:\Source\catalog\search\server\target\catalog-server'
        at java.net.URL.<init>(Unknown Source)
        at java.net.URL.<init>(Unknown Source)
        at java.net.URL.<init>(Unknown Source)
        at org.springframework.boot.context.embedded.undertow.JarResourceManager.getResource(JarResourceManager.java:50)

        at org.springframework.boot.context.embedded.undertow.CompositeResourceManager.getResource(CompositeResourceMana
ger.java:51)
        at io.undertow.servlet.handlers.ServletPathMatches.getServletHandlerByPath(ServletPathMatches.java:96)
        ... 11 common frames omitted
Caused by: java.lang.IllegalArgumentException: No !/ in spec 'file:M:\Source\catalog\search\server\target\catalog-server
'
        at org.springframework.boot.loader.jar.Handler.getFileFromSpec(Handler.java:159)
        at org.springframework.boot.loader.jar.Handler.parseURL(Handler.java:149)
        ... 17 common frames omitted

Versions: Spring Boot: 1.5.2.RELEASE Java: version “1.8.0_121” Java HotSpot™ 64-Bit Server VM (build 25.121-b13, mixed mode) OS: Windows 10 64-bit

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
zzcodercommented, Sep 5, 2021

Traced the issue to Undertow and reported the bug: https://issues.redhat.com/browse/UNDERTOW-1958

0reactions
zzcodercommented, Sep 13, 2021

I was confused. The bug is in the Undertow integration code so it’s a Spring Boot’s bug after all. Here is the message from Undertow team:

Spring class: https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/JarResourceManager.java#L39 contain file reference with all the quirks. This is most likely place that should handle it properly.

I attached an example, you can reproduce the error like this,

mvn package
java -jar target/test-server##1.0.war
curl "http://localhost:8080/hello"

exec-war-bug.zip

Read more comments on GitHub >

github_iconTop Results From Across the Web

Embedded Undertow throws MalformedURLException when ...
Embedded Undertow throws MalformedURLException when archive filename contains characters that are reserved in a URL #28032.
Read more >
spring-projects/spring-boot v2.4.11 on GitHub - NewReleases.io
... existing value" error #27693; Embedded Undertow throws MalformedURLException when archive filename contains characters that are reserved in a URL #9283 ...
Read more >
Spring Boot - Browse /v2.5.5 at SourceForge.net
... Embedded Undertow throws MalformedURLException when archive filename contains characters that are reserved in a URL #28032; Concurrent image builds ...
Read more >
Getting a MalformedURLException on an encoded URL
I have functionality which will take in URLs and process them. These URLs can contain characters such as [ or spaces.
Read more >
vue.js - You Yuxi criticizes users for arbitrarily deploying Vue/Vite ...
... When the archive file name contains characters reserved in the URL, the embedded Undertow throws MalformedURLException #28032; Concurrent image build ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found