Hi,
Actually, I’m trying to run sample starter in tomcat in STS/Eclipse.
I found that subsequent builds(Dev-mode then Prod-mode) creates the issue, but what would be the residual information which cannot be deleted by Clean ?
Here the scenario, it’s a bit long though:
-
I have cleared all the workspace and downloaded fresh my-starter-project and imported as Maven project
-
In pom.xml, I have changed packaging to war, java to 11 and added finalName for simple war file name and performed Maven - Update project
-
From Run - Run configurations menu I have created Maven Build configuration Development Build with goal package and executed the build . Final war was 30MB in size.
-
I have added Tomcat server to Servers in STS/Eclipse and added my-starter-project to server with Run as Run on server but cancelled run due to missing application properties.
-
Then, again from Run Run configurations I have edited Tomcat profile and added -Dapplication.properties.path=“file:///C:/xxxx/STS4470-NewApp-WS/my-starter-project/src/main/resources/application.properties” to point application properties file.
-
And started the Tomcat in STS/Eclipse
-
While starting Tomcat I see lots of messages under DEBUG dev-updater and DEBUG dev-webpack and it has started normally and
-
I could access it through localhost:8080/my-starter-project, all is perfect - dev mode
-
I have stopped Tomcat server in my local STS/Eclipse
-
I have created duplicate Maven Build configuration from Run - Run configurations and chagned the goal to package -Pproduction and Profiles: production and run it.
-
Project - Clean - Clean all projects
-
Run the Production Build. This time webpack ran during build. Final war was 33MB in size.
-
I started tomcat, no errors during startup. But when I tried to access localhost:8080/my-starter-project I got Unable to read webpack stats file, on my browser and in server log.
So I guess that an issue happens when -Pproduction build made after normal build. In order to check:
- I have performed Project - Clean - Clean all projects and change the goal to clean package -Pproduction and rebuilt.
- Build completes but this time I have experienced the case explained in https://github.com/vaadin/flow/issues/7985 and added Validator exclusions to STS/Eclipse and Maven Update project again
- I got thousands of Warnings for generated html files in node_modules and added HTML Exclusion also for validation and after Maven Update project I see only two Warnings for serialVersionUID in MainView and GreetService
- Then assuming with all is OK I have re-Launched Tomcat.
- No way! Started webpack-dev-server - “Vaadin is running in DEBUG MODE” ?? goal clean -Pproduction and webpack ?
I could not be sure if my goal is correct but it was, removed target folder contents and retried the build, and relaunched the tomcat, now it turned to Prod mode but again with The stats file from webpack (stats.json) was not found. error on browser and in the log.
As a final attempt, I have cleared all the workspace again(deleted all the files in STS/Eclipse workspae), and re-execute 1-13 but this time with -Pproduction build for the first time and never built for development.
Suprise, in local it was ok with Production mode, no errors on browser it says hello anonymous user. I have transferred war file to my server and it has worked there also and accessible from browser.
So my experience is development mode, somehow persists in somewhere, for war packaging, even Project - clean, maven clean or removing target folder not helped.
Could be the clean goal before package is not executed from Run configuration ? Should I add maven-clean-plugin to production Profile section in pom.xml ?
but even with removing the all the contents of target folder did not help(resulting to not found stats.json)?
It seems the only way to run Production mode was to build first with Production and continue with it.
Maybe I have a small mistake/missing point in the above flow but I could not figure out what.
Thanks in advance.