RE: Vaadin 10 with Spring Boot packages as JAR

I didn’t try it but I had the same question for bakery (Vaadin 8). The resources are in webapp folder and should be in resources/static. That won’t work if you deploy as a jar.

Here my “question”.
I don’t understand why the login.html is in webapp instead of resources/static.
It’s not recommended and won’t work if you package it in a jar.
See https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html
I’ll also put vaadin themes inside resources folder.
(Not a real bug but I think it will work in all cases if login.html is in resources/static).

Hi there,

i am trying to create a Vaadin 10 application using spring boot and Maven packaged as a standalone JAR and i am having trouble getting the frontend resources to work. I am using the Spring Starter Skeleton. The frontend resources can’t be found when starting the final application from the JAR. The examples I found so far all use WAR files instead of JAR files.
Even after reading this https://vaadin.com/docs/v10/flow/web-components/tutorial-flow-maven-plugin.html i cannot get it to work.
Is there an example around somewhere that shows how to build a vaadin 10 spring boot application as a JAR with Maven?
Where in the final JAR do the resources need to be? Which source folders exactly?

Thanks helping me out,

Markus

I have the same issue. Vaadin 10 + Spring Boot + kotlin packaged with spring-boot maven plugin into executable jar.
But custom resources like css styles or another html that lies nearby in webapp directory can’t be accessed when running jar (404 error).

Does that mean I need to somehow tell spring boot to take static resources from that folder? Or can I do that through vaadin api?

Are there any official recommendations how to run Vaadin 10 with Spring Boot in a fat jar? I have the same issue.

Nahh… Forum is dead for monthes. No official recomendations found.
But just stepped into that resources issue again if use pathing jar to shorten gradle command line.
So looks like a Vaadin bug for me - it can’t load resources from jars (at least on Windows)

For me it does not make sense to locally run Vaadin 10 with Spring Boot without a external Container but not able to package and run this a fat jar. In previous versions - I think version 8 with Spring Boot - this was working. Hopefully somebody (official) reads this post and can clarify this issue.

Hi,
just check https://vaadin.com/start/v10-project-base-spring - it created Spring boot JAR file. It was fix around 1.0.0 of V10. I am now running some beta version of our app in production as V10 + Spring boot 2.0 JAR.
Regards,
Matic

This is not in any way specific to Vaadin 10, but rather a generic difference between WAR and JAR packaging. On the other hand, previous Vaadin versions used a non-standard convention and then used various internal tricks to still make things work. With Vaadin 10, we are instead relying on the standard way of handling static files, which might cause some surprises for anyone who is used to previous versons.

When you deploy an application as a WAR file, the static resources should be in the root of the WAR file. With the default Maven directory setup, this means that the files should be inside src/main/webapp/.

When you deploy as a JAR file, the static resources needs to be inside META-INF/resources/ in that JAR file. In the Maven world, this means that the files go to src/main/resources/META-INF/resources/.

If you take a working application and change the packaging method, you also need to move the resource files accordingly.

Leif Åstrand:
This is not in any way specific to Vaadin 10, but rather a generic difference between WAR and JAR packaging. On the other hand, previous Vaadin versions used a non-standard convention and then used various internal tricks to still make things work. With Vaadin 10, we are instead relying on the standard way of handling static files, which might cause some surprises for anyone who is used to previous versons.

When you deploy an application as a WAR file, the static resources should be in the root of the WAR file. With the default Maven directory setup, this means that the files should be inside src/main/webapp/.

When you deploy as a JAR file, the static resources needs to be inside META-INF/resources/ in that JAR file. In the Maven world, this means that the files go to src/main/resources/META-INF/resources/.

If you take a working application and change the packaging method, you also need to move the resource files accordingly.

Thank you very much. I’m sorry, I’ve got it - it was too late yesterday. I have tested the “full-stack-spring” example and this build for WAR file deployment with src/main/webapp/, of course. Your explanation solved my problem.

I can confirm that it works now, though my project layout have webapp/ directory and no META-INF/resources. No changes to working WAR project were required for me.
Dependencies I use:

<vaadin.version>10.0.1</vaadin.version>
<spring-boot.version>2.0.0.RELEASE</spring-boot.version>
<flow.maven.plugin.version>1.0.0</flow.maven.plugin.version>