Generator-jhipster: Windows: cannot run production build for a monolith app with version 5.8.2

Created on 17 Apr 2019  Β·  9Comments  Β·  Source: jhipster/generator-jhipster

Overview of the issue

Cannot run production build for a monolith app with version 5.8.2

Motivation for or Use Case

I was using jhipster 5.8.1 for my project and ran into issues with primeng and was suggested in one of the github issues to upgrade to v 5.8.2. It did solve the problem but now I create a production war file using mvnw -Pprod package command.

I tried generating an app from scratch(both cli and online) but still being shown the same error. Please help.

Reproduce the error
  1. Generate a jhipster Monolith project (Angular) on 5.8.2 cli or online tool
  2. Run mvnw to make sure it works.(it does)
  3. run production build using mvnw -Pprod package command.

[INFO] > [email protected] lint E:\Projects\jhipsterSampleApplication
[INFO] > tslint --project tsconfig.json -e 'node_modules/'
[INFO]
[ERROR] No valid rules have been specified for JavaScript files
[ERROR] Γ’?? Deprecation Warning:
[ERROR]
[ERROR] Option "setupTestFrameworkScriptFile" was replaced by configuration "setupFilesAfterEnv", which supports multiple paths.
[ERROR]
[ERROR] Please update your configuration.
[ERROR]
[ERROR] Configuration Documentation:
[ERROR] https://jestjs.io/docs/configuration.html
[ERROR]
[INFO] No tests found, exiting with code 1
[INFO] Run with --passWithNoTests to exit with code 0
[INFO] In E:\Projects\jhipsterSampleApplication
[INFO] 481 files checked.
[INFO] testMatch: E:/Projects/jhipsterSampleApplication/src/test/javascript/spec/
+(*.)+(spec.ts) - 0 matches
[INFO] testPathIgnorePatterns: \node_modules\ - 481 matches
[INFO] testRegex: - 0 matches
[ERROR] npm ERR! code ELIFECYCLE
[INFO] Pattern: - 0 matches
[ERROR] npm ERR! errno 1
[ERROR] npm ERR! [email protected] test: npm run lint && jest --coverage --logHeapUsage -w=2 --config src/test/javascript/jest.conf.js
[ERROR] npm ERR! Exit status 1
[ERROR] npm ERR!
[ERROR] npm ERR! Failed at the [email protected] test script.
[ERROR] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[ERROR]
[ERROR] npm ERR! A complete log of this run can be found in:
[ERROR] npm ERR! C:Users\Muiz\AppData\Roaming\npm-cache_logs\2019-04-17T04_18_14_774Z-debug.log
[ERROR] npm ERR! code ELIFECYCLE
[ERROR] npm ERR! errno 1
[ERROR] npm ERR! [email protected] webpack:test: npm run test
[ERROR] npm ERR! Exit status 1
[ERROR] npm ERR!
[ERROR] npm ERR! Failed at the [email protected] webpack:test script.
[ERROR] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[ERROR]
[ERROR] npm ERR! A complete log of this run can be found in:
[ERROR] npm ERR! C:Users\Muiz\AppData\Roaming\npm-cache_logs\2019-04-17T04_18_14_811Z-debug.log
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:25 min
[INFO] Finished at: 2019-04-17T09:48:14+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:npm (webpack build test) on project jhipster-sample-application: Failed to run task: 'npm run webpack:test' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

JHipster Version(s)
[email protected] E:\Projects\jhipsterSampleApplication
`-- [email protected]

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "gitCompany": "",
    "baseName": "jhipsterSampleApplication",
    "packageName": "io.github.jhipster.application",
    "packageFolder": "io/github/jhipster/application",
    "serverPort": 8080,
    "serviceDiscoveryType": false,
    "authenticationType": "jwt",
    "uaaBaseName": "../uaa",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "enableSwaggerCodegen": "true",
    "messageBroker": false,
    "buildTool": "maven",
    "useSass": false,
    "clientPackageManager": "npm",
    "testFrameworks": [],
    "enableTranslation": false,
    "nativeLanguage": "en",
    "languages": [
      "en"
    ],
    "clientFramework": "angularX",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "5.8.2",
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": []
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory


JDL entity definitions


Environment and Tools

java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

git version 2.20.1.windows.1

node: v10.15.1

npm: 6.7.0

yeoman: 2.0.6

yarn: 1.13.0

Docker version 18.09.1, build 4c52b90

docker-compose version 1.23.2, build 1110ad01

INFO! Congratulations, JHipster execution is complete!.

area

All 9 comments

It seems that your sample application doesn't have any UI test cases. You can resolve this in different ways:

  • add unit tests for UI code
  • update test script to pass additional flag --passWithNoTests
  • skip execution of tests in your maven build with -DskipTests

[INFO] No tests found, exiting with code 1
[INFO] Run with --passWithNoTests to exit with code 0

I have no problem for packaging a JHipster project with 5.8.2.
You can see the logs above.

There is something related to your environment, so plz provide more information / use case to reproduce your issue.

  • be sure you're not behind proxy or it is correctly configured
  • try to clean your node_modules then npm install
07:55:07 in ~/tmp 
➜ git clone [email protected]:jhipster/jhipster-sample-app.git                                              
Clonage dans 'jhipster-sample-app'...
remote: Enumerating objects: 25153, done.
remote: Total 25153 (delta 0), reused 0 (delta 0), pack-reused 25153
RΓ©ception d'objets: 100% (25153/25153), 34.50 MiB | 614.00 KiB/s, fait.
RΓ©solution des deltas: 100% (14643/14643), fait.

07:56:20 in ~/tmp took 1m 3s 
➜ cd jhipster-sample-app 

07:56:23 in ~/tmp/jhipster-sample-app on ξ‚  master 
➜ ./mvnw -Pprod package               
[INFO] Scanning for projects...
[INFO] 
[INFO] -------< io.github.jhipster.sample:jhipster-sample-application >--------
[INFO] Building Jhipster Sample Application 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:copy-resources (default-resources) @ jhipster-sample-application ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] Copying 20 resources
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ jhipster-sample-application ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] Copying 20 resources

(...)

[ERROR] 
[ERROR] Test Suites: 39 passed, 39 total
[ERROR] Tests:       130 passed, 130 total
[ERROR] Snapshots:   0 total
[ERROR] Time:        42.209s
[ERROR] Ran all test suites.
[INFO] 
[INFO] --- maven-war-plugin:3.2.2:war (default-war) @ jhipster-sample-application ---
[INFO] Packaging webapp
[INFO] Assembling webapp [jhipster-sample-application] in [/home/pgrimaud/tmp/jhipster-sample-app/target/jhipster-sample-application-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp webResources [/home/pgrimaud/tmp/jhipster-sample-app/src/main/webapp] to [/home/pgrimaud/tmp/jhipster-sample-app/target/jhipster-sample-application-0.0.1-SNAPSHOT]
[INFO] Copying webapp resources [/home/pgrimaud/tmp/jhipster-sample-app/target/www]
[INFO] Webapp assembled in [297 msecs]
[INFO] Building war: /home/pgrimaud/tmp/jhipster-sample-app/target/jhipster-sample-application-0.0.1-SNAPSHOT.war
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.0.8.RELEASE:repackage (default) @ jhipster-sample-application ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  04:01 min
[INFO] Finished at: 2019-04-17T08:00:39+02:00
[INFO] ------------------------------------------------------------------------

@MuizNadeem it comes from a change in Jest v24. As the logs says:
Option "setupTestFrameworkScriptFile" was replaced by configuration "setupFilesAfterEnv", which supports multiple paths.

So you need to go into the jest.config.js file and change the property setupTestFrameworkScriptFile with setupFilesAfterEnv and it will work.

It seems that your sample application doesn't have any UI test cases. You can resolve this in different ways:

  • add unit tests for UI code
  • update test script to pass additional flag --passWithNoTests
  • skip execution of tests in your maven build with -DskipTests

[INFO] No tests found, exiting with code 1
[INFO] Run with --passWithNoTests to exit with code 0

This is a blank app created using jhipster generator. I have done the same using older versions of the generator and did not face any problems generating a production package.

@MuizNadeem it comes from a change in Jest v24. As the logs says:
Option "setupTestFrameworkScriptFile" was replaced by configuration "setupFilesAfterEnv", which supports multiple paths.

So you need to go into the jest.config.js file and change the property setupTestFrameworkScriptFile with setupFilesAfterEnv and it will work.

@wmarques I have cleaned my local and global node_modules and also replaced setupFilesAfterEnv: '<rootDir>/src/test/javascript/jest.ts' with setupFilesAfterEnv: ['<rootDir>/src/test/javascript/jest.ts'] in jest.conf.js file, as suggested.
But the tests are still not being picked up. Can you please help?

```
E:\Projects\jhipsterSampleApplication>npm run test

[email protected] test E:\Projects\jhipsterSampleApplication
npm run lint && jest --coverage --logHeapUsage -w=2 --config src/test/javascript/jest.conf.js

[email protected] lint E:\Projects\jhipsterSampleApplication
tslint --project tsconfig.json -e 'node_modules/**'

No valid rules have been specified for JavaScript files
No tests found, exiting with code 1
Run with --passWithNoTests to exit with code 0
In E:\Projects\jhipsterSampleApplication
620 files checked.
testMatch: E:/Projects/jhipsterSampleApplication/src/test/javascript/spec/*+(.)+(spec.ts) - 0 matches
testPathIgnorePatterns: \node_modules\ - 620 matches
testRegex: - 0 matches
Pattern: - 0 matches
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: npm run lint && jest --coverage --logHeapUsage -w=2 --config src/test/javascript/jest.conf.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:Users\Muiz\AppData\Roaming\npm-cache_logs\2019-04-17T14_36_03_333Z-debug.log```

I am attaching the unmodified copy of the jhipster monolith app that was generated online.
Please help me with the steps to run the jest tests.
jhipsterSampleApplication.zip

With your provided code, I am able to build with production profile and found no issues.

./mvnw -Pprod clean package

It seems to be an issue with your environment

@vishal423

It seems like the regex used in jest.conf.js file to match spec.ts files fails to match in windows file system. I was able to generate a prod build on my linux machine and also using gitlab ci.

I have no problems starting this app with dev profile. using ./mvnw command.
However, the application fails to start using the generated war using prod profile. ./mvnw -Pprod clean package

Were you able to start the app using the generated war at your end??

Pasting the error log below :

 java -jar aamwala-0.0.1-SNAPSHOT.war

        β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
        β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘ β•šβ•β•β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β•β•β•β• β•šβ•β•β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β•β•β•β•β•β• β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—
        β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—     β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
  β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•”β•β•β•β•β•   β•šβ•β•β•β–ˆβ–ˆβ•—    β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•”β•β•β•β•   β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘
  β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘       β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•    β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘  β•šβ–ˆβ–ˆβ•—
   β•šβ•β•β•β•β•β•  β•šβ•β•   β•šβ•β• β•šβ•β•β•β•β•β•β•β• β•šβ•β•       β•šβ•β•β•β•β•β•     β•šβ•β•    β•šβ•β•β•β•β•β•β•β• β•šβ•β•   β•šβ•β•

:: JHipster πŸ€“  :: Running Spring Boot 2.0.8.RELEASE ::
:: https://www.jhipster.tech ::

2019-04-18 22:27:34.478 ERROR 8470 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Could not locate PropertySource and the fail fast property is set, failing
    at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:136)
    at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:94)
    at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:628)
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:364)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
    at com.almasstronics.com.AamwalaApp.main(AamwalaApp.java:65)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
    at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:58)
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8761/config/Aamwala/prod/master": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:696)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:644)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:564)
    at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.getRemoteEnvironment(ConfigServicePropertySourceLocator.java:218)
    at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:96)
    ... 13 common frames omitted
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
    at sun.net.www.http.HttpClient.New(HttpClient.java:339)
    at sun.net.www.http.HttpClient.New(HttpClient.java:357)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984)
    at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:76)
    at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
    at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:687)
    ... 17 common frames omitted

Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8761/config/Aamwala/prod/master": Connection refused (Connection refused);

Your app requires the jhipster registry to be running which is strange because the .yo-rc.json file you pasted had "serviceDiscoveryType": false,

For the original problem, it comes from the testMatch by jest on Windows.
See this ticket https://github.com/facebook/jest/issues/7914 and the suggested solution https://github.com/facebook/jest/issues/7914#issuecomment-464352069

You can apply this diff to fix the problem in your project:

diff --git a/src/test/javascript/jest.conf.js b/src/test/javascript/jest.conf.js
index 4ad6991..a7ff010 100644
--- a/src/test/javascript/jest.conf.js
+++ b/src/test/javascript/jest.conf.js
@@ -21,7 +21,7 @@ module.exports = {
     ],
     testResultsProcessor: 'jest-sonar-reporter',
     transformIgnorePatterns: ['node_modules/(?!@angular/common/locales)'],
-    testMatch: ['<rootDir>/src/test/javascript/spec/**/+(*.)+(spec.ts)'],
+    testMatch: ['<rootDir>/src/test/javascript/spec/**/@(*.)@(spec.ts)'],
     rootDir: '../../../',
     testURL: "http://localhost/"
 };
Was this page helpful?
0 / 5 - 0 ratings

Related issues

lsadehaan picture lsadehaan  Β·  3Comments

SudharakaP picture SudharakaP  Β·  3Comments

edvjacek picture edvjacek  Β·  3Comments

kaidohallik picture kaidohallik  Β·  3Comments

ahmedeldeeb25 picture ahmedeldeeb25  Β·  3Comments