Home > Software engineering >  vaadin 23 reporting debug mode when built for production
vaadin 23 reporting debug mode when built for production

Time:05-14

I've built my vaadin 23 app in production mode via:

mvn clean package -Pproduction -DskipTests -U

My pom.xml contains the necessary profile:

<!-- vaadin profiles -->
    <!-- https://vaadin.com/docs/latest/flow/production/production-build -->
    <profiles>
        <profile>
            <id>production</id>
            <properties>
                <vaadin.productionMode>true</vaadin.productionMode>
            </properties>

            <!-- configuration depending on environment -->
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.vaadin</groupId>
                        <artifactId>vaadin-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>build-frontend</goal>
                                </goals>
                                <phase>compile</phase>
                            </execution>
                        </executions>

                        <configuration>
                            <productionMode>true</productionMode>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <!-- .. more configuration .. -->
            <dependencies>
                <dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin</artifactId>
                    <exclusions>
                        <exclusion>
                            <groupId>com.vaadin</groupId>
                            <artifactId>vaadin-dev-server</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>

        </profile>
    </profiles>

I'm building a war file for tomcat 9 using java 17.

The war contains WEB-INF/classes/META-INF/VAADIN/config/flow-build-info.json

{
  "productionMode": true,
  "useDeprecatedV14Bootstrapping": false,
  "eagerServerLoad": false,
  "chunks": {
    "fallback": {
      "jsModules": [
        "@vaadin/select/src/vaadin-select.js",
        "./selectConnector.js",
        "@polymer/paper-ripple/paper-ripple.js",
        "./custom-media-query.js",
        "./com/github/appreciated/card/clickable-card.js",
        "./com/github/appreciated/card/stateful-card.js",
        "./grid-layout/grid-layout.js",
        "./font-awesome-iron-iconset/far.js",
        "./font-awesome-iron-iconset/fab.js",
        "./element-media-query.js",
        "@vaadin/charts/src/vaadin-chart.js",
        "@vaadin/grid-pro/src/vaadin-grid-pro.js",
        "@vaadin/grid-pro/src/vaadin-grid-pro-edit-column.js",
        "./gridProConnector.js",
        "@vaadin/board/vaadin-board-row.js",
        "@vaadin/avatar-group/src/vaadin-avatar-group.js",
        "@vaadin/crud/src/vaadin-crud.js",
        "@vaadin/crud/src/vaadin-crud-edit-column.js",
        "@vaadin/message-input/src/vaadin-message-input.js",
        "@vaadin/login/src/vaadin-login-form.js",
        "./messageListConnector.js",
        "@vaadin/message-list/src/vaadin-message-list.js",
        "@vaadin/virtual-list/vaadin-virtual-list.js",
        "./virtualListConnector.js",
        "@polymer/iron-list/iron-list.js",
        "./ironListConnector.js",
        "./ironListStyles.js",
        "@vaadin/upload/src/vaadin-upload-file.js",
        "@vaadin/login/src/vaadin-login-overlay.js",
        "@vaadin/board/vaadin-board.js",
        "./vaadin-big-decimal-field.js",
        "@vaadin/app-layout/src/vaadin-drawer-toggle.js",
        "@vaadin/confirm-dialog/src/vaadin-confirm-dialog.js",
        "@vaadin/app-layout/src/vaadin-app-layout.js"
      ],
      "cssImports": [
        {
          "value": "./styles/grid-layout.css"
        }
      ]
    }
  },
  "enableDevServer": false
}

WEB-INF/classes/META-INF/VAADIN/config/stats.json contains:

{
 "assetsByChunkName": {
  "bundle": "VAADIN/build/vaadin-bundle-7f98e7fa04576858b6f8.cache.js"
 }
}

The only problem I can see with this is that it has included modules that I'm not using but I don't believe that has any bearing on the current problem.

When I deploy the war, tomcat it is reporting:

(AtmosphereFramework.java:1087) - Atmosphere Framework 2.7.3.slf4jvaadin4 started.
(AtmosphereFramework.java:2626) - Installed AtmosphereInterceptor  Track Message Size Interceptor using | with priority BEFORE_DEFAULT 
(DefaultDeploymentConfiguration.java:155) - Following issues were discovered with deployment configuration:
WARNING: Vaadin is running in DEBUG MODE with debug features enabled, but with a prebuild frontend bundle (production ready).
When deploying application for production, disable debug features by enabling production mode!
See more from https://vaadin.com/docs/latest/flow/production/overview
[main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/local/tomcat/webapps/ROOT.war] has finished in [14,764] ms
org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
[main] org.apache.catalina.startup.Catalina.start Server startup in [14985] milliseconds

otherwise the system is working as expected.

I've followed this trouble shooting guide and everything appears to be correct: https://vaadin.com/docs/latest/flow/production/troubleshooting

CodePudding user response:

I eventually solved this problem thanks to a good idea from @Frettman.

The core problem was actually my vaadin servlet which we configure via annotations.


@WebServlet(urlPatterns =
{ "/*" }, name = "OnePub", asyncSupported = true, loadOnStartup = 1, initParams =
{
        @WebInitParam(name = "org.atmosphere.cpr.AtmosphereInterceptor", value = "dev.onepub.servlets.AtmosphereFilter"),
        @WebInitParam(name = "closeIdleSessions", value = "true"),

        /// changed this when we release.
        @WebInitParam(name = "productionMode", value = "false")

})

The problem line was the

@WebInitParam(name = "productionMode", value = "false")

changing the value to 'true' resolved the issue.

@WebInitParam(name = "productionMode", value = "true")

I did also make one other change which MAY have contributed to the fix.

My pom file production profile section contained a dependency:

<dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin</artifactId>
                    <exclusions>
                        <exclusion>
                            <groupId>com.vaadin</groupId>
                            <artifactId>vaadin-dev-server</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>

I'm not certain how this entered the pom but I change the profile section to:

<profiles>
        <profile>
            <!-- Production mode is activated using -Pproduction -->
            <id>production</id>
            <properties>
                <vaadin.productionMode>true</vaadin.productionMode>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>flow-server-production-mode</artifactId>
                </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>
    </profiles>
  • Related