OnDemand
(Nico M)
October 23, 2024, 5:17pm
1
Hi there,
anyone has an idea what the problem could be?
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
I have a prepear-frontend goal in my pom
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-frontend</goal>
<goal>build-frontend</goal>
</goals>
</execution>
</executions>
</plugin>
Locally it starts in IntelliJ but as soon as I run mvn clean package -Pproduction and want to run the jar the error occur
knoobie
(Christian Knoop)
October 23, 2024, 5:22pm
2
Where did you get that example from? Never use both goals at the same time - I repeat: never
Please check an example pom from start.vaadin.com how it should look
OnDemand
(Nico M)
October 23, 2024, 5:28pm
3
I just tried it, usually I have only
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<goals>
<goal>build-frontend</goal>
</goals>
</execution>
</executions>
</plugin>
The problem occur since I moved to a new Mac but what should this relates to?
marcoc_753
(Marco Collovati)
October 23, 2024, 5:41pm
4
So the problem happens when you run java -jar target/whatever-x.y.z.jar
, right?
If so, that’s really weird because if the artifact is built for production (and you can check it by inspecting the META-INF/VAADIN/config/flow-build-info.json
file inside the JAR) you should not reach the point that logs the posted message.
So, my guess is that either the JAR is not built for production or there is another flow-build-info.json
with wrong contents in the classpath.
OnDemand
(Nico M)
October 23, 2024, 5:50pm
5
Thank you.
I can not find this file. Really strange
now I get the following info from Jenkins who build it
Caused by: java.lang.IllegalStateException: Running project in development mode with no access to folder ‘/var/lib/jenkins/workspace/xxx-App-PRD’.
Build project in production mode instead, see Deploying to Production | Flow | Vaadin Docs
Ah got the file inside the jar:
“productionMode”: false,
but why?
Maybe this will help, need to check
marcoc_753
(Marco Collovati)
October 23, 2024, 5:56pm
6
Looks like that the build-frontend goal is not executed.
Please check the maven output. Also, make sure that you have build-frontend goal configured in your pom. It will be most likely in a “production” profile; make sure you are activating the profile during the build.
Matti
(Matti Tahvonen)
October 23, 2024, 6:02pm
7
@knoobie Would you elaborate why not both? That is what I have been doing successfully “forever”. The prepare-frontend is not needed for Spring Boot projects (for dev mode).
But that combination should be there only for “production build”…
OnDemand
(Nico M)
October 23, 2024, 6:10pm
8
the flow-build-info.json build by Jenkins has
{
“productionMode”: true,
“eagerServerLoad”: false,
“react.enable”: true,
“applicationIdentifier”: “app-444675b0c0393820e342569c0a89ca8cea56784a640f35af8492ee5b0277b739”
}
so why does it give me that error: 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
and my pom contains:
<build>
<plugins>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>flow-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<goals>
<!-- This goal compiles the frontend for production -->
<goal>build-frontend</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<goals>
<goal>build-frontend</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
I dont get it
Matti
(Matti Tahvonen)
October 23, 2024, 6:28pm
9
To me that looks just fine. Very similar to what my build generates.
Would you post the fulll pom.xml? I’m e.g. interested which version & if you are excluding the dev mode dependencies? That at least used to be optional (if that flow-build.info was there), but maybe there is a regression that dev mode kicks in if it just happens to be on the classpath?
1 Like
marcoc_753
(Marco Collovati)
October 23, 2024, 6:38pm
10
Why do you have both flow-maven-plugin and vaadin-maven-plugin?
Please, only use vaadin-maven-plugin
marcoc_753
(Marco Collovati)
October 23, 2024, 6:41pm
11
Can you also clarify your process?
You build the application on Jenkins, then get the built jar from there and you run it locally?
OnDemand
(Nico M)
October 23, 2024, 6:46pm
12
Now I have added vaadin-dev in exclusion
<profile>
<!-- Production mode is activated using -Pproduction -->
<id>production</id>
<dependencies>
<!-- Exclude development dependencies from production -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-core</artifactId>
<exclusions>
<exclusion>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-dev</artifactId> <<<<<<<added!
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<goals>
<goal>build-frontend</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
and I could build it locally and uploaded it to the server, it has started. Lets see what Jenkins now will do
knoobie
(Christian Knoop)
October 23, 2024, 6:48pm
13
If I’m not mistaken… one is “just” development stuff… and the other one is doing the production mode heavy lifting… e.g. also builds the prod bundle… which can interfere later on if present locally… so I would always encourage against this combination so that people don’t accidentally have a local production bundle that is the culprit of interesting bugs :(
Matti
(Matti Tahvonen)
October 23, 2024, 6:52pm
14
build-frontend is the thing that does the optimised bundle. To get back to development mode one (at least previously) needed mvn clean (or mvn vaadin:prepare-frontend, but that is not executed if you start your app directly via IDE), but maybe now with this new feature/regression, it is not necessary anymore.
OnDemand
(Nico M)
October 23, 2024, 6:53pm
15
Thank you @Matti 🩵 it has started again, either I broke my pom or the hint with the exclusion did the trick
OnDemand
(Nico M)
October 23, 2024, 6:55pm
16
@Matti here is my pom, if you have a minute you could have an eye on it, maybe there are more issues I dont see
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mydomain.app</groupId>
<artifactId>mydomain</artifactId>
<name>mydomain</name>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<vaadin.version>24.5.0</vaadin.version>
<kotlin.version>1.9.10</kotlin.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.1</version>
</parent>
<repositories>
<!-- The order of definitions matters. Explicitly defining central here to make sure it has the highest priority. -->
<!-- Main Maven repository -->
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- Repository used by many Vaadin add-ons -->
<repository>
<id>Vaadin Directory</id>
<url>https://maven.vaadin.com/vaadin-addons</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!-- Main Maven repository -->
<pluginRepository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.vaadin.olli</groupId>
<artifactId>browser-opener</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.9.0</version>
</dependency>
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>2.11.5</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.20.5</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.2-jre</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>com.flowingcode.addons</groupId>
<artifactId>font-awesome-iron-iconset</artifactId>
<version>5.2.2</version>
</dependency>
<dependency>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.14.2</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<!-- Replace artifactId with vaadin-core to use only free components -->
<artifactId>vaadin-core</artifactId>
<exclusions>
<!-- Webjars are only needed when running in Vaadin 13 compatibility mode -->
<exclusion>
<groupId>com.vaadin.webjar</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.webjars.bowergithub.insites</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.webjars.bowergithub.polymer</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.webjars.bowergithub.polymerelements</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.webjars.bowergithub.vaadin</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.webjars.bowergithub.webcomponents</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>
vaadin-spring-boot-starter
</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>7.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.1.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>dev.mett.vaadin</groupId>
<artifactId>tooltip</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>com.wontlost</groupId>
<artifactId>ckeditor-vaadin</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.vaadin.klaudeta</groupId>
<artifactId>grid-pagination</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.github.mwiede</groupId>
<artifactId>jsch</artifactId>
<version>0.2.18</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>6.4.10</version>
</dependency>
<dependency>
<groupId>com.univocity</groupId>
<artifactId>univocity-parsers</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt-hibernate5</artifactId>
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>5.3.14</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>9.21.1</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-mysql</artifactId>
<version>9.21.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.3</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-testbench</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.15.3</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
<build>
<finalName>app</finalName>
<defaultGoal>spring-boot:run</defaultGoal>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/java</source>
<source>target/generated-sources/annotations</source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/test/java</source>
<source>target/generated-test-sources/test-annotations</source>
</sourceDirs>
</configuration>
</execution>
</executions>
<configuration>
<jvmTarget>11</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.43.0</version>
<configuration>
<java>
<eclipse>
<version>4.33</version>
<file>${project.basedir}/eclipse-formatter.xml</file>
</eclipse>
</java>
</configuration>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-frontend</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- Production mode is activated using -Pproduction -->
<id>production</id>
<dependencies>
<!-- Exclude development dependencies from production -->
<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>
<goals>
<goal>build-frontend</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>it</id>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>start-spring-boot</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-spring-boot</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Runs the integration tests (*IT) after the server is started -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<trimStackTrace>false</trimStackTrace>
<enableAssertions>true</enableAssertions>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Matti
(Matti Tahvonen)
October 23, 2024, 6:59pm
17
Most likely a regresison (or some new feature I’m not aware of) that flow-build.info flag is not respected if dev modes is (for some reason) still on the classpath. I can verify that in a moment.
Anyways, after this incident I’m again more confident we should do something like this by default:
GitHub - viritin/viritin-sb: Viritin project starter (parent pom) for better Vaadin + Spring Boot DX (<-- should update this to 24.5).
knoobie
(Christian Knoop)
October 23, 2024, 7:01pm
18
Yeah that clean is probably the things most people won’t do and have weird problems afterwards… just from yesterday: Production build breaks future development · Issue #20294 · vaadin/flow · GitHub
knoobie
(Christian Knoop)
October 23, 2024, 7:02pm
19
Why are you defining so many versions on your dependencies when you are using the spring boot parent? This is normal a guarantee to create a maintenance and debug nightmare
1 Like
Matti
(Matti Tahvonen)
October 23, 2024, 7:09pm
20
I tested with a fresh Vaadin project and there I couldn’t reproduce. So not really sure what is was happening. Getting too late for me today, but at least you got forward now
And, yeah, I was going to comment something like @knoobie , you should be able to leave out many of your dependency versions and leave that for Spring Boot. Might or might not be related. Some IDEs give you even warnings if you overried them in your project’s pom.xml.
1 Like