Production Mode App Won't Load in Browser

We can’t get the Vaadin app to load in the browser. We just get the background and the loading indicator. It works in dev mode. We tested with multiple browsers.

We just updated to 24.7.3 including the other required deps (Spring, Node, GSON, Jackson, etc.). We are using Java 21. Also, this is a Spring Boot app and we are building with Gradle (> gradle installDist").

Update: The gradle build is not the cause of the problem. Behaves the same when run directly from Eclipse, changing only this property in application.properties: vaadin.productionMode = true.

So what’s in the dev-console and the network-tab of the browser? What
are the server-logs saying?

How do you enable production mode? It won’t work if all you do is change the property in application.properties. With the default Gradle configuration, you need to use the -Pvaadin.productionMode option. Launching in production mode directly from an IDE like Eclipse doesn’t work since it needs to do some special things at build time.

The browser shows that its loading the initial parts of the webapp but when it gets to the part where it should load the main view, nothing comes back from the server. The heartbeats start and are working but no View.

We have this in the build.gradle:

vaadin {
	optimizeBundle = false
	productionMode = true
}

Is that not enough?

We did realize that there are a lot of things in the build script that have to be switched for prod but we just changed that and the behavior is the same.

The web server is not returning the Main View to the browser.

I tested doing a production build with GitHub - vaadin/base-starter-spring-gradle: Starting point for a Spring Boot based Vaadin application using Gradle build and that works as expected either when run as ./gradlew clean build -Pvaadin.productionMode or when adding the productionMode setting to build.gradle and just running ./gradlew clean build.

Whatever is broken is somehow specific to something else in your setup but I don’t have any direct ideas on what specifically might lead to the symptoms that you describe.

Could you be more specific. No reponse? Empty response? Response with an error?

The last request from the browser looks like this:

GET
	wss://192.168.40.151:8443/jobe/VAADIN/push?v-r=push&v-uiId=2&v-pushId=29a9a749-4ff7-45b0-ad5c-2501239f6fef&X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=4.0.1&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json; charset=UTF-8&X-atmo-protocol=true&X-Vaadin-LastSeenServerSyncId=0
Status
101

That looks like the switchover to websockets and I guess that’s how Vaadin loads Views?

No response comes back at all.

I also found this:

	build\vaadin-generated\META-INF\VAADIN\config\flow-build-info.json
	"productionMode": false,

This means you haven’t build your application correctly. Take a look at Leif’s example and compare it with your setup - your setup must be broken.

I will do that, thank you.

Make sure, that the Gradle task vaadinBuildFrontend runs for your
production artifact. Depending on what targets you build or what
versions you use, that might be something you must configure yourself.

E.g. this makes the bootJar task depend on it.

tasks.withType<BootJar> {
    dependsOn(tasks.withType<VaadinBuildFrontendTask>())
    archiveClassifier = "fat"
}

(see
Making sure you're not a bot!)

Views are typically loaded over HTTP. The websocket is used only for changes that are triggered by the server (unless you have changed the configuration to use Transport.WEBSOCKET) whereas loading a view is triggered by the client so that the view is in a regular HTTP response. You can look for key strings from your view in the POST responses to check whether the view has already been sent to the client.

Did you check for any unexpected 404 responses or for anything suspicious in the browser console?

Thanks for all the help. We got it working finally. There were so many things to change I couldn’t list them all here.

We found a bug in Spring. You cannot have a class named Properties in your project or its dependencies. Spring maps it to java.util.Properties. Spring is not following the java specs here.

If your app does not run with the gradle bootRun task, that’s a red flag that means something is wrong with your config, even if the app runs by other means.

bootRun does not create an installation folder, so trying to reference anything under that will fail (like a logs or conf folder).

You need to be very careful to set properties the right way. And, if your application.properties is not in the location that Spring expects, you will have to configure it.

Production mode requires using the “-Pvaadin.productionMode” option on the cmd line to build and run. Setting props in the application.properties or your build.gradle is not enough.

That, plus about 35 other things. The Vaadin docs are hard to translate into a recipe of steps.