3

enter image description hereI downloaded the project from "start.vaadin.com". Then I did "mvn install", everything worked fine.

When I run "mvn spring-boot:run", it generates an error when trying to compile the frontend: "com.vaadin.flow.server.BootstrapException: Unable to read webpack stats file."

I don't work with the Maven Central, but with a local repository at my university. My PC does not have access to the Internet, only to the Nexus repository of my university: "http://nexus.prod.uci.cu/repository/maven-all/". This repository has the maven and node (i.e. npm) services. However, as you could see, there are no dependency problems. The "mvn install" worked correctly. I disabled the firewall. However, I infer that the problem is with the "npm install" that Vaadin does when trying to compile the frontend. It is possible that my PC is trying to use the Node repository from the Internet and not my University's repository, in which case it couldn't as it doesn't have Internet access. I configured my npm to use my University's repository, but I keep getting this error.

Here is the browser output after waiting for about three minutes:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Apr 26 17:55:55 GMT-05:00 2021
There was an unexpected error (type=Internal Server Error, status=500).
com.vaadin.flow.server.BootstrapException: Unable to read webpack stats file.
com.vaadin.flow.server.ServiceException: com.vaadin.flow.server.BootstrapException: Unable to read webpack stats file.
    at com.vaadin.flow.server.VaadinService.handleExceptionDuringRequest(VaadinService.java:1596)
    at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1559)
    at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:247)
    at com.vaadin.flow.spring.SpringServlet.service(SpringServlet.java:111)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:710)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:457)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:352)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
    at org.springframework.web.servlet.mvc.ServletForwardingController.handleRequestInternal(ServletForwardingController.java:141)
    at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:177)
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:52)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1060)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:962)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1707)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: com.vaadin.flow.server.BootstrapException: Unable to read webpack stats file.
    at com.vaadin.flow.server.BootstrapHandler$BootstrapPageBuilder.setupFrameworkLibraries(BootstrapHandler.java:894)
    at com.vaadin.flow.server.BootstrapHandler$BootstrapPageBuilder.setupDocumentHead(BootstrapHandler.java:771)
    at com.vaadin.flow.server.BootstrapHandler$BootstrapPageBuilder.getBootstrapPage(BootstrapHandler.java:540)
    at com.vaadin.flow.server.BootstrapHandler.synchronizedHandleRequest(BootstrapHandler.java:481)
    at com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
    at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1547)
    ... 52 more
Caused by: java.net.ConnectException: Connection refused: connect
    at java.base/java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.base/java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
    at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:400)
    at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:243)
    at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:225)
    at java.base/java.net.PlainSocketImpl.connect(PlainSocketImpl.java:148)
    at java.base/java.net.Socket.connect(Socket.java:591)
    at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:177)
    at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:474)
    at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:569)
    at java.base/sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
    at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:341)
    at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:362)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1242)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1181)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1075)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:1009)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1581)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)
    at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:527)
    at com.vaadin.flow.server.frontend.FrontendUtils.getStatsAssetsByChunkName(FrontendUtils.java:566)
    at com.vaadin.flow.server.BootstrapHandler$BootstrapPageBuilder.appendNpmBundle(BootstrapHandler.java:910)
    at com.vaadin.flow.server.BootstrapHandler$BootstrapPageBuilder.setupFrameworkLibraries(BootstrapHandler.java:892)
    ... 57 more

The pom.xml is the same as the one generated from the Vaadin site. I already wrote on the Vaadin page.

I comment something curious that is happening to me with "Hello World in Vaadin". When I create the project from the maven archetype, like this:

"mvn -B archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=LATEST -DgroupId=org.test -DartifactId=webapp -Dversion=1.0-SNAPSHOT"

As explained in "https://vaadin.com/learn/tutorials/import-maven-project-eclipse"

It doesn't work for me. Even in production mode: "mvn jetty:run -Pproduction". The browser starts and does not generate an error, but it does not show what the "Hello World" should show. It shows a page informing "you are offline", and explaining that "my app needs internet connection to work. You do not seem to have access to the server right now. Check your internet conecction and try reloading the page to use the application". Attached is an image of my screen, with the browser running the application.

Why does this happen with jetty and not with spring-boot ?

Manuel
  • 31
  • 7
  • It seems like the root cause is `Connection refused: connect`. Any chance you may have a firewall or something blocking local traffic? Do you see any exceptions in the server log? – Marcus Hellberg Apr 26 '21 at 22:21
  • Hi Marcus Hellberg, thank you for replying. I edited my question and included items related to the maven and node repository I use. I would appreciate an answer from you. Regards. – Manuel Apr 26 '21 at 23:02
  • How did you configure the node repository on the local machine? – Simon Martinelli Apr 27 '21 at 07:18
  • The ".npmrc" file I am using is this one: registry = http://nexus.prod.uci.cu/repository/npm-all no-proxy = nexus.prod.uci.cu strict-ssl = false I've put it everywhere, in the project directory and in all the places required by the bibliography. – Manuel Apr 27 '21 at 10:19
  • Marcus asked for an exception. Here is what I found: 1) com.vaadin.flow.server.BootstrapException: Unable to read webpack stats file. 2) Caused by: java.net.ConnectException: Connection refused: connect 3) java.net.ConnectException: Connection refused: connect – Manuel Apr 27 '21 at 10:42

2 Answers2

2

The exception would seem to be for trying to connect to the webpack-dev-server to get the assets from the generated stats.

To rule out a problem with the packages and connection you could try to run a production build with mvn spring-boot:run -Pproduction. If that works then at least the node and maven packages get downloaded correctly.

If the production mode works then when running development mode there might be in the logs Webpack failed with the exception: that would indicate that the devServer failed to start and some information on why.

Also by setting the logger to log debug you should get the command string used to start the webpack-dev-server that is something like

[0m2021-04-28 07:25:38.105 DEBUG 60260 --- [         task-2] dev-webpack                              : 
C:\Program Files\nodejs\node.exe \ 
    .\node_modules\webpack-dev-server\bin\webpack-dev-server.js \ 
    --config .\webpack.config.js --port 62103 \ 
    --watchDogPort=62102 -d --inline=false `

Where you can try to connect to the devServer in this case by going to localhost:62103. This should show you a folder structure with only a config folder, but if you go to localhost:62103/stats.json you should receive a json file starting with something like {"hash":"c827122594d41ad4f7df","assetsByChunkName":{"bundle":"build/vaadin-bundle-...

The way to get the debug logging is to add into application.properties the line logging.level.root = debug. As there is a lot of output I would recommend piping to a file e.g. running mvn > out.txt and searching from the text file for the errors and information.

Hope this helps to find out what the issue is.

  • Thank you Mikael Grankvist!!!. With your help I managed to run "Hello World in Vaadin". With "mvn spring-boot:run -Pproduction" everything worked correctly. But when I run "mvn spring-boot:run" the same problem continues. I can't find "application.properties", where is that in the "Pom.xml" file? Sorry for my lack of knowledge. – Manuel Apr 29 '21 at 14:45
  • Now I also know that the Nexus repository of my University is working correctly. I will keep trying to find the cause of the error in development mode. – Manuel Apr 29 '21 at 14:59
  • I edited my question. Adding something curious that happens to me with the same "Hello World in Vaadin". Apparently the version built with the Vaadin archetype needs internet and the one built from the site download does not. – Manuel Apr 29 '21 at 15:17
  • `application.properties` is a file in `src/java/main/resources/` in a Spring-boot application. The archetype created version actually uses v19.0.x instead of v14.5.x – Mikael Grankvist Apr 30 '21 at 04:12
  • Is there any exceptions in the server logs for the archetype execution? The offline page is probably shown due an unexpected response from the server making the client say that the server is not reachable e.g. you are offline. For jetty you could try running `mvn package jetty:run -Pproduction` as for some reason now and then jetty:run seems to skip some goals. – Mikael Grankvist Apr 30 '21 at 05:21
  • The errors are these:Starting Frontend compilation dev-webpack: Running webpack to compile frontend resources. This may take a moment, please stand by... 2021-04-25 17:52:05.147 INFO 7812 --- [ task-2] dev-webpack : Started webpack-dev-server. Time: 60015ms 2021-04-25 17:52:07.887 ERROR 7812 --- [nio-8080-exec-8] c.v.flow.server.DefaultErrorHandler : com.vaadin.flow.server.BootstrapException: Unable to read webpack stats file.Caused by: java.net.ConnectException: Connection refused: connect. java.net.ConnectException: – Manuel Apr 30 '21 at 23:22
  • With jetty I also used the production mode, i.e.: "mvn package jetty:run -Pproduction". – Manuel Apr 30 '21 at 23:27
  • It still sounds like there is something blocking connections to localhost. Did you try to connect to the webpack-dev-server directly from the browser to see if it is up and serving the correct files? – Mikael Grankvist May 03 '21 at 03:38
1

I had the same issue. Vaadin is not compatible with newer versions of node and npm. For a workaround please see the ticket.