I have an app built on Spring-Boot (1.5.10.RELEASE) and create-react-app. Everything working fine in development (ie running spring-boot via IDE and using yarn start
to run the web app.)
Problem is when running the production package. Using embedded tomcat and running using the command java -jar target/build-app-1.0.0-SNAPSHOT.jar
Basically getting the following error messages in the browser console
Failed to decode downloaded font: <URL>
localhost/:1 Failed to decode downloaded font: http://localhost:8080/static/media/icons.af7ae505.woff2
localhost/:1 Failed to decode downloaded font: http://localhost:8080/static/media/icons.af7ae505.woff2
localhost/:1 Failed to decode downloaded font: http://localhost:8080/static/media/icons.fee66e71.woff
localhost/:1 Failed to decode downloaded font: http://localhost:8080/static/media/icons.fee66e71.woff
localhost/:1 Failed to decode downloaded font: http://localhost:8080/static/media/icons.b06871f2.ttf
localhost/:1 Failed to decode downloaded font: http://localhost:8080/static/media/icons.b06871f2.ttf
localhost/:1 OTS parsing error: Failed to convert WOFF 2.0 font to SFNT
localhost/:1 OTS parsing error: incorrect file size in WOFF header
localhost/:1 OTS parsing error: incorrect entrySelector for table directory
This is the snippet from my pom.xml
that copies the resources from the web app build directory
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-react-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes/static</outputDirectory>
<resources>
<resource>
<directory>src/main/app/build</directory>
<filtering>true</filtering>
</resource>
</resources>
<encoding>UTF-8</encoding>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>eot</nonFilteredFileExtension>
<nonFilteredFileExtension>svg</nonFilteredFileExtension>
<nonFilteredFileExtension>ttf</nonFilteredFileExtension>
<nonFilteredFileExtension>woff</nonFilteredFileExtension>
<nonFilteredFileExtension>woff2</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</execution>
</executions>
</plugin>
The fonts appear to be copied over to the target area correctly
eg from the web app build directory
$ ls -la src/main/app/build/static/media/
total 1020
drwxrwxr-x 2 pram pram 4096 Jun 17 09:44 .
drwxrwxr-x 5 pram pram 4096 Jun 17 09:44 ..
-rw-rw-r-- 1 pram pram 28123 Jun 17 09:44 flags.9c74e172.png
-rw-rw-r-- 1 pram pram 165742 Jun 17 09:44 icons.674f50d2.eot
-rw-rw-r-- 1 pram pram 444379 Jun 17 09:44 icons.912ec66d.svg
-rw-rw-r-- 1 pram pram 77160 Jun 17 09:44 icons.af7ae505.woff2
-rw-rw-r-- 1 pram pram 165548 Jun 17 09:44 icons.b06871f2.ttf
-rw-rw-r-- 1 pram pram 98024 Jun 17 09:44 icons.fee66e71.woff
-rw-rw-r-- 1 pram pram 23284 Jun 17 09:44 loader-big.a770b679.gif
-rw-rw-r-- 1 pram pram 3744 Jun 17 09:44 rw-widgets.12f0820c.woff
-rw-rw-r-- 1 pram pram 2765 Jun 17 09:44 rw-widgets.792dcd18.svg
-rw-rw-r-- 1 pram pram 6408 Jun 17 09:44 rw-widgets.bc7c4a59.eot
-rw-rw-r-- 1 pram pram 6232 Jun 17 09:44 rw-widgets.eceddf47.ttf
and from the target
$ ls -la target/classes/static/static/media/
total 1020
drwxrwxr-x 2 pram pram 4096 Jun 17 09:44 .
drwxrwxr-x 5 pram pram 4096 Jun 17 09:44 ..
-rw-rw-r-- 1 pram pram 28123 Jun 17 09:44 flags.9c74e172.png
-rw-rw-r-- 1 pram pram 165742 Jun 17 09:44 icons.674f50d2.eot
-rw-rw-r-- 1 pram pram 444379 Jun 17 09:44 icons.912ec66d.svg
-rw-rw-r-- 1 pram pram 77160 Jun 17 09:44 icons.af7ae505.woff2
-rw-rw-r-- 1 pram pram 165548 Jun 17 09:44 icons.b06871f2.ttf
-rw-rw-r-- 1 pram pram 98024 Jun 17 09:44 icons.fee66e71.woff
-rw-rw-r-- 1 pram pram 23284 Jun 17 09:44 loader-big.a770b679.gif
-rw-rw-r-- 1 pram pram 3744 Jun 17 09:44 rw-widgets.12f0820c.woff
-rw-rw-r-- 1 pram pram 2765 Jun 17 09:44 rw-widgets.792dcd18.svg
-rw-rw-r-- 1 pram pram 6408 Jun 17 09:44 rw-widgets.bc7c4a59.eot
-rw-rw-r-- 1 pram pram 6232 Jun 17 09:44 rw-widgets.eceddf47.ttf
and within the deployment artifact
$ unzip -vl target/build-app-1.0.0-SNAPSHOT.jar | grep "static/media"
0 Stored 0 0% 2018-06-17 09:44 00000000 BOOT-INF/classes/static/static/media/
3744 Defl:N 3681 2% 2018-06-17 09:44 a861d971 BOOT-INF/classes/static/static/media/rw-widgets.12f0820c.woff
165742 Defl:N 98260 41% 2018-06-17 09:44 ba1d704f BOOT-INF/classes/static/static/media/icons.674f50d2.eot
6232 Defl:N 3458 45% 2018-06-17 09:44 130aa154 BOOT-INF/classes/static/static/media/rw-widgets.eceddf47.ttf
98024 Defl:N 97913 0% 2018-06-17 09:44 e07b3318 BOOT-INF/classes/static/static/media/icons.fee66e71.woff
6408 Defl:N 3512 45% 2018-06-17 09:44 06efde2c BOOT-INF/classes/static/static/media/rw-widgets.bc7c4a59.eot
444379 Defl:N 136041 69% 2018-06-17 09:44 5f3bf1ae BOOT-INF/classes/static/static/media/icons.912ec66d.svg
23284 Defl:N 9111 61% 2018-06-17 09:44 254b8443 BOOT-INF/classes/static/static/media/loader-big.a770b679.gif
165548 Defl:N 98167 41% 2018-06-17 09:44 c544bc5c BOOT-INF/classes/static/static/media/icons.b06871f2.ttf
77160 Defl:N 77153 0% 2018-06-17 09:44 5517c3a7 BOOT-INF/classes/static/static/media/icons.af7ae505.woff2
2765 Defl:N 1186 57% 2018-06-17 09:44 b229e926 BOOT-INF/classes/static/static/media/rw-widgets.792dcd18.svg
28123 Defl:N 27946 1% 2018-06-17 09:44 fb476e5a BOOT-INF/classes/static/static/media/flags.9c74e172.png
So the files appear to have copied over without any problem - I confirmed that the files are fine by loading them into http://bluejamesbond.github.io/CharacterMap/
Now, if I pick one of the URLs that were displayed in the error messages eg http://localhost:8080/static/media/icons.af7ae505.woff2
and directly navigate to that in my browser it downloads. Then checking the file
-rw-rw-r-- 1 pram pram 139423 Jun 17 10:25 icons.af7ae505.woff2
compared to the file in the target area of the build artifact
-rw-rw-r-- 1 pram pram 77160 Jun 17 09:44 icons.af7ae505.woff2
The file sizes are different.
The downloaded file (when opened in sublime) displays as
774f 4632 0001 0000 0001 2d68 000d 0000
0002 efbf bdef bfbd 0001 2d0e 0004 01ef
bfbd 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 3f46 4654 4d1c 1a20 0660
00ef bfbd 7211 080a efbf bdef bfbd 28ef
bfbd efbf bd58 0136 0224 03ef bfbd 700b
efbf bd10 0004 2005 efbf bd06 07ef bfbd
755b 5209 7247 61ef bfbd efbf bdef bfbd
2aef bfbd 0def bfbd 27ef bfbd 3def bfbd
3aef bfbd 1a26 efbf bdef bfbd 3d72 efbf
bd2a 0a02 19ef bfbd 1aef bfbd efbf bd5d
0474 07ef bfbd 45ef bfbd 6eef bfbd efbf
bdef bfbd efbf bdef bfbd efbf bdef bfbd
3146 efbf bd0e efbf bd40 efbf bdef bfbd
efbf bdef bfbd 7cef bfbd efbf bd14 0866
efbf bd6d efbf bd60 efbf bd24 d891 efbf
bd40 645b 4251 1124 285b 553c 2b28 efbf
bdef bfbd 4050 efbf bd35 1eef bfbd 60ef
and so on
And when opened in vi
wOF2^@^A^@^@^@^A-h^@^M^@^@^@^B��^@^A-^N^@^D^A�^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@?FFTM^\^Z ^F`^@�r^Q^H
��(��X^A6^B$^C�p^K�^P^@^D ^E�^F^G�u[R rGa���*�^M�'�=�:�^Z&��=r�*
I have spring-boot-starter-security
enabled with the following in the WebSecurity file
@Override
public void configure(org.springframework.security.config.annotation.web.builders.WebSecurity web) throws Exception {
web.ignoring().antMatchers(
"/asset-manifest.json",
"/favicon.ico",
"/index.html",
"/service-worker.js",
"/static/**"
);
}
Can anyone identify what could be modifying the fonts?