Vaadin 14+ npm mode - Production profile

What are the steps required to run in Production mode?

I have downloaded the starter (pre-release) plain java ‘Click me’ application and it works when run via:
mvn jetty:run
But, if I try mvn jetty:run -Pproduction, I get errors:

[qtp218446003-22]
 ERROR com.vaadin.flow.server.frontend.FrontendUtils - Cannot get the 'stats.json' from the classpath 'META-INF/VAADIN/config/stats.json'
[qtp218446003-22]
 ERROR com.vaadin.flow.server.DefaultErrorHandler - 
com.vaadin.flow.server.BootstrapException: Unable to read webpack stats file.
        at com.vaadin.flow.server.BootstrapHandler$BootstrapPageBuilder.setupFrameworkLibraries(BootstrapHandler.java:837)
        at com.vaadin.flow.server.BootstrapHandler$BootstrapPageBuilder.setupDocumentHead(BootstrapHandler.java:718)
        at com.vaadin.flow.server.BootstrapHandler$BootstrapPageBuilder.getBootstrapPage(BootstrapHandler.java:521)

Hi Syam,

If you want to try production mode locally you should use jetty:run-war. So, you should run your app using mvn jetty:run-war -Pproduction. The instruction in the README will be updated. Thanks for reporting this issue :slight_smile:

Thank you

I have one more observation. As suggested, I tried the following command to run in Production mode.

mvn jetty:run-war -Pproduction

It created a war file and running fine. Is this the war file I have to take to a Production machine? If so, I noticed that in the stats.json file, full-path folder names from my Development machine are used (have a look at the "identifier" and "moduleIdentifier" tags).

Hi,
I get the same error. pom.xml is configured as production mode and using wildfly 18.
I did checked this path 'META-INF/VAADIN/config/stats.json' and I see stats.json is not there.

What is the reason for it?
what should I do to solve it?

08:38:21,075 ERROR [com.vaadin.flow.server.frontend.FrontendUtils]
 (default task-5) Cannot get the 'stats.json' from the classpath 'META-INF/VAADIN/config/stats.json'
08:38:21,076 ERROR [com.vaadin.flow.server.DefaultErrorHandler]
 (default task-5) : com.vaadin.flow.server.BootstrapException: Unable to read webpack stats file.
	at com.vaadin.flow.server.BootstrapHandler$BootstrapPageBuilder.setupFrameworkLibraries(BootstrapHandler.java:872)
	at com.vaadin.flow.server.BootstrapHandler$BootstrapPageBuilder.setupDocumentHead(BootstrapHandler.java:749)
	at com.vaadin.flow.server.BootstrapHandler$BootstrapPageBuilder.getBootstrapPage(BootstrapHandler.java:524)
	at com.vaadin.flow.server.communication.WebComponentBootstrapHandler.synchronizedHandleRequest(WebComponentBootstrapHandler.java:195)
	at com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
	at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1540)
	at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:247)
	at com.vaadin.cdi.CdiVaadinServlet.service(CdiVaadinServlet.java:65)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
	at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
	at io.undertow.websockets.jsr.JsrWebSocketFilter.doFilter(JsrWebSocketFilter.java:173)
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
	at io.opentracing.contrib.jaxrs2.server.SpanFinishingFilter.doFilter(SpanFinishingFilter.java:52)
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

Hi, i faced the same issue this morning so in a command prompt inside the root project folder you have to launch :

node node_modules\webpack\bin\webpack.js

This will build the desired file stats.json .

Luigi Ducci:
Hi, i faced the same issue this morning so in a command prompt inside the root project folder you have to launch :

node node_modules\webpack\bin\webpack.js

This will build the desired file stats.json .

Hi, thanks for your reply.

I did executed as you mention getting following error.

C:\Development\workspace\soft\counting-web>node node_modules\webpack\bin\webpack.js
i 「atl」: Using typescript@3.7.3 from typescript
i 「atl」: Using tsconfig.json from C:/Development/workspace/soft/counting-web/tsconfig.json
i 「atl」: Checking started in a separate process...
× 「atl」: Checking finished with 2 errors
Hash: fa7e89b7006d4e70abbe
Version: webpack 4.42.0
Time: 3332ms
Built at: 2020-05-07 8:53:28
Entrypoint bundle =
[0]
 ../target/index.ts + 1 modules 92.2 KiB {0} [built]

    | ../target/index.ts 1.46 KiB [built]

    |     + 1 hidden module

ERROR in ../target/index.ts
Module not found: Error: Can't resolve '../target/frontend/generated-flow-imports' in 'C:\Development\workspace\soft\counting-web\target'
 @ ../target/index.ts 17:19-70

ERROR in ../target/index.ts
Module not found: Error: Can't resolve '@vaadin/flow-frontend/Flow' in 'C:\Development\workspace\soft\counting-web\target'
 @ ../target/index.ts 15:0-50 16:33-37

ERROR in chunk bundle [entry]

build/vaadin-bundle-a427b921febfb9ca0ea2.cache.js
C:\Development\workspace\soft\counting-web\node_modules\awesome-typescript-loader\dist\entry.js!C:\Development\workspace\soft\counting-web\target\index.ts 052da964a93a474bf00dd0019aa9cf65
Unexpected token (17:33)
| // import Flow module to enable navigation to Vaadin server-side views
| 
| const { serverSideRoutes } = new !(function webpackMissingModule() { var e = new Error("Cannot find module '@vaadin/flow-frontend/Flow'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())({
|     imports: () => Promise.resolve().then(function webpackMissingModule() { var e = new Error("Cannot find module '../target/frontend/generated-flow-imports'"); e.code = 'MODULE_NOT_FOUND'; throw e; })
| });

ERROR in [at-loader]
 ./target/index.ts:18:20 
    TS2307: Cannot find module '@vaadin/flow-frontend/Flow'.

ERROR in [at-loader]
 ./target/index.ts:21:25 
    TS2307: Cannot find module '../target/frontend/generated-flow-imports'.
Child html-webpack-plugin for "index.html":
     1 asset
    Entrypoint undefined = index.html
    [0]
 ../node_modules/html-webpack-plugin/lib/loader.js!../target/index.html 1.08 KiB {0} [built]

        + 3 hidden modules