"Failed to determine project directory for dev mode" spring jar in container

I have a Vaadin application running from a Springboot bootable jar. That jar is deployed to a linux server, and all it needs is an application-default.properties file with some database connection settings to start. Those two files can be copied to any folder on my development machine and the application starts correctly.

If I create a container with the same two files, like so:

FROM azul/zulu-openjdk:23-latest
COPY ../../../target/*-boot.jar app.jar
COPY ../../../target/application-default.properties application-default.properties
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app.jar"]

It starts up correctly, but just prior to going online fails with:

Caused by: java.lang.IllegalStateException: Failed to determine project directory for dev mode. Directory '/' does not look like a Maven or Gradle project. Ensure that you have run the prepare-frontend Maven goal, which generates 'flow-build-info.json', prior to deploying your application
        at com.vaadin.flow.server.AbstractConfiguration.getProjectFolder(AbstractConfiguration.java:238)
        at com.vaadin.flow.server.AbstractConfiguration.getJavaResourceFolder(AbstractConfiguration.java:261)
        at com.vaadin.base.devserver.startup.DevModeInitializer.initDevModeHandler(DevModeInitializer.java:229)
        at com.vaadin.base.devserver.DevModeHandlerManagerImpl.initDevModeHandler(DevModeHandlerManagerImpl.java:104)
        at com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener.failFastContextInitialized(VaadinServletContextInitializer.java:593)
        at com.vaadin.flow.spring.VaadinServletContextInitializer$FailFastServletContextListener.contextInitialized(VaadinServletContextInitializer.java:202)

The pom calls prepare-frontend on every build, and build-frontend when building the bootable jar (-Pproduction).

		<profile>
			<id>production</id>
            <dependencies>
                <dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-core</artifactId>
                    <exclusions>
                        <exclusion>
                            <groupId>com.vaadin</groupId>
                            <artifactId>vaadin-dev</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
			<build>
				<plugins>
					<plugin>
						<groupId>com.vaadin</groupId>
						<artifactId>vaadin-maven-plugin</artifactId>
						<version>${vaadin.version}</version>
						<executions>
							<execution>
								<id>frontend</id>
								<phase>compile</phase>
								<goals>
									<goal>build-frontend</goal>
								</goals>
								<configuration>
                                    <forceProductionBuild>true</forceProductionBuild>
                                </configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

I’ve tried adding -Dvaadin.productionMode=true to the container’s ENTRYPOINT, but that does not matter. The META-INF\VAADIN\config\flow-build-info.json is present in the bootable jar:

{
  "productionMode": true,
  "eagerServerLoad": false,
  "react.enable": true,
  "applicationIdentifier": "app-48e80009bd0b96712300635e8696e2b9d909060f39d024e879de084ad1f92d4a"
}

Since the bootable jar can be started from anywhere already, why is there an issue in the container?

Seems like the dev mode dependencies are somehow sneaking into the production build. You could check with mvn dependency:tree -Pproduction to see if there’s some additional exclude that you need to add.

God, always when you’ve just made a post to a forum: I’m messing up my container builds. The application is starting now, I was barking up the wrong tree.

1 Like