Closed alejandro-du closed 4 years ago
In fact it's even worse: no need to replace the existing icon at all.
The provided icon in the skeleton src/main/resources/META-INF/resources/icons/icon.png
is shown being run via spring-boot:run
but a default icon ( totally different one) is shown being run via java -jar
.
This is a Spring issue.
The problem is that all classes being packaged in Jar goes into BOOT-INF
folder.
But resources goes to META-INF
directly (not as a sub-package of BOOT-INF
).
Then embedded servlet container is responsible for finding the resources (as static web resources).
By default Tomcat is used . TomcatServletWebServerFactory
has code in its nested StaticResourceConfigurer
which scans Jars for "/META-INF/resources"
folders. But that works only for Jars inside the Jar (library Jars) and the "/META-INF" inside the Jar itself is not handled.
So as a result: the code in Flow tries to search the static web resource using a Servlet context and it's not able to find it (see above). The proper way to fix this would be fix the project itself specifically for this case since Spring is not able to handle this properly. So it should be fixed in skeleton-starter project itself.
I'm going to implement a workaround as well in Flow for this specific case: search the resource in classpath if it's not found via a servlet context. But this is more a hack (and it's not really correct to fix this Spring specific case in Flow repo).
A workaround in Flow : https://github.com/vaadin/flow/pull/8808 A proper fix in skeleton: https://github.com/vaadin/skeleton-starter-flow-spring/pull/381
Another way to solve this would be to use the approach prototyped in https://github.com/vaadin/flow/tree/webpack-workbox to enable offline routing using the webpack workbox plugin
It moves all @PWA
, manifest, sw.js and icon handling to the build phase instead of runtime.
In Vaadin 22.0.5 it's not working again (in Vaadin 14 everything is ok though)
This is because the default icon now is in resources as well, from exampledata-4.1.0.jar dependency, which eventually breaks the workaround #8808.
I used truezip-maven-plugin to remove the default icon from exampledata-4.1.0.jar archive during package step, as another temporary workaround for this situation.
Exampledata has been fixed in 4.1.1
Thank you
Description of the bug
When packaging a project as a JAR, using a custom
icon.png
insrc/main/resources/META-INF/resources/icons
, and running withjava -jar ...
, the custom favicon is not shown (it is shown correctly when running themain
method in IntelliJ IDEA, though). The problem is the same with both development and production builds.Minimal reproducible example
Go to https://vaadin.com/start/v14. Create a Spring Boot project. Replace the
icon.png
file with a custom one. Build withmvn package
. Run with ´java -jar ...`.Expected behavior
Should show the custom icon.
Actual behavior
Shows the default white circle with a blue background icon.
Versions: