In dev mode application works perfectly. When i try command mvnw -Pprod package -DskipTests i get BUILD FAILURE with this error :
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:yarn (webpack build prod) on project two-g-hub: Failed to run task
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
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.apache.maven.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:39)
at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:122)
at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:50)
Caused by: org.apache.maven.plugin.MojoFailureException: Failed to run task
at com.github.eirslett.maven.plugins.frontend.mojo.AbstractFrontendMojo.execute(AbstractFrontendMojo.java:100)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 27 more
Caused by: com.github.eirslett.maven.plugins.frontend.lib.TaskRunnerException: 'yarn run webpack:prod' failed.
at com.github.eirslett.maven.plugins.frontend.lib.YarnTaskExecutor.execute(YarnTaskExecutor.java:64)
at com.github.eirslett.maven.plugins.frontend.mojo.YarnMojo.execute(YarnMojo.java:65)
at com.github.eirslett.maven.plugins.frontend.mojo.AbstractFrontendMojo.execute(AbstractFrontendMojo.java:94)
... 29 more
Caused by: com.github.eirslett.maven.plugins.frontend.lib.ProcessExecutionException: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at com.github.eirslett.maven.plugins.frontend.lib.ProcessExecutor.execute(ProcessExecutor.java:82)
at com.github.eirslett.maven.plugins.frontend.lib.ProcessExecutor.executeAndRedirectOutput(ProcessExecutor.java:64)
at com.github.eirslett.maven.plugins.frontend.lib.YarnExecutor.executeAndRedirectOutput(YarnExecutor.java:28)
at com.github.eirslett.maven.plugins.frontend.lib.YarnTaskExecutor.execute(YarnTaskExecutor.java:58)
... 31 more
Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
at com.github.eirslett.maven.plugins.frontend.lib.ProcessExecutor.execute(ProcessExecutor.java:74)
... 34 more
I even created completely new Jhipster application and run command : mvnw -Pprod package -DskipTests and got the same error.
.yo-rc.json file generated in the root folder
.yo-rc.json file
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.twognation.hub",
"nativeLanguage": "en"
},
"jhipsterVersion": "4.14.1",
"baseName": "TwoGHub",
"packageName": "com.twognation.hub",
"packageFolder": "com/twognation/hub",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "ehcache",
"enableHibernateCache": true,
"websocket": "spring-websocket",
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "postgresql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSocialSignIn": true,
"enableSwaggerCodegen": false,
"jwtSecretKey": "replaced-by-jhipster-info",
"clientFramework": "angularX",
"useSass": true,
"clientPackageManager": "yarn",
"applicationType": "monolith",
"testFrameworks": [
"gatling",
"cucumber",
"protractor"
],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"zh-cn",
"zh-tw",
"et",
"de",
"it",
"ru",
"sr"
],
"herokuDeployType": "jar"
}
}
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
git version 2.14.2.windows.2
node: v8.9.4
npm: 5.6.0
yeoman: 2.0.1
yarn: 1.5.1
I generated a project using the .yo-rc.json you provided, and ran mvnw -Pprod package -DskipTests without any issues. Can you link to a gist with the full build log? Also try running the build command outside of mvn with yarn run webpack:prod
Hi @stefantwog Are you building on a Linux machine? Once I had some issues when trying to build on a CentOS 7 server. I managed to solve them by creating a symlink to yarn before launching ./mvnw yarn.
sh "ln -fs yarn-v1.3.2 node/yarn/dist"
sh "./mvnw com.github.eirslett:frontend-maven-plugin:yarn"
Didn't investigate enough to create a issue though.
Like @ruddell, I couldn't reproduce the issue.
We need more information to reproduce.
I am working on Windows. Wierd thing is that me and my colleague are doing same steps :
It works for him, but i still get this error. I tried everything : removing .m2 folder, deleting node_modules and i still get this.
Does anyone have some idea i am stuck for 4 days now.
does running the yarm commands manually work?
As @ruddell asked you, could you please show the full log as a gist? The error you have pasted is not enough. Also, as this is a prod build, it is isolated from your own node and yarn global installations, same for your project's node_modules.
If it works for your colleague, maybe you have different versions of Windows, type ver in a command prompt and compare. If you want to compare further, use systeminfo
Here is full build log :
https://gist.github.com/stefantwog/426054a384322a222e3ace811f166285
Are you running Windows 64 bits? How much RAM do you have?
Command failed with exit code 3221225477 makes me suspect that you don't have enough RAM, more than 4 GB is required for AOT build and this means 64 bits version of Windows and NodeJS.
yes win 64, i have 16gb ram, can i configure it to use more than 4gb?
Yes edit package.json, look for --max_old_space_size=4096
Also make sure your NodeJS is a 64bit version, --max_old_space_size=4096 will cause a failure for NodeJS 32-bit https://github.com/jhipster/jhipster.github.io/pull/560 .
You can run the following command to tell which type you have installed: node -p "process.arch"
True though it would be a little more difficult to run node -p "process.arch" from frontend-maven-plugin context.
$ node -p "process.arch"
x64
"scripts": {
"lint": "tslint --project tsconfig.json -e 'node_modules/**'",
"lint:fix": "yarn run lint -- --fix",
"ngc": "ngc -p tsconfig-aot.json",
"cleanup": "rimraf target/{aot,www}",
"clean-www": "rimraf target//www/app/{src,target/}",
"start": "yarn run webpack:dev",
"serve": "yarn run start",
"build": "yarn run webpack:prod",
"test": "yarn run lint && karma start src/test/javascript/karma.conf.js",
"test:watch": "yarn test -- --watch",
"webpack:dev": "yarn run webpack-dev-server -- --config webpack/webpack.dev.js --progress --inline --hot --profile --port=9060 --watch-content-base",
"webpack:build:main": "yarn run webpack -- --config webpack/webpack.dev.js --progress --profile",
"webpack:build": "yarn run cleanup && yarn run webpack:build:main",
"webpack:prod:main": "yarn run webpack -- --config webpack/webpack.prod.js --profile",
"webpack:prod": "yarn run cleanup && yarn run webpack:prod:main && yarn run clean-www",
"webpack:test": "yarn run test",
"webpack-dev-server": "node --max_old_space_size=4096 node_modules/webpack-dev-server/bin/webpack-dev-server.js",
"webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js",
"e2e": "protractor src/test/javascript/protractor.conf.js",
"postinstall": "webdriver-manager update && node node_modules/phantomjs-prebuilt/install.js"
}
when i try to run only this command :
$ yarn run cleanup && yarn run webpack:prod:main && yarn run clean-www
yarn run v1.9.4
$ rimraf target/{aot,www}
Done in 0.30s.
yarn run v1.9.4
$ yarn run webpack -- --config webpack/webpack.prod.js --profile
warning From Yarn 1.0 onwards, scripts don't require "--" for options to be forwarded. In a future version, any explicit "--" will be forwarded as-is to the scripts.
$ node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js --config webpack/webpack.prod.js --profile
MergetJsonsWebpackPlugin compilation started...
MergetJsonsWebpackPlugin compilation completed...
It get stuck here and don't move
Which version of Windows?
OS Name : Microsoft Windows 10 Pro
Version : 10.0.17134 Build 17134
Then I have no idea. I thought this was the problem of the notifier in system icon tray that exists in Windows 7.
I set --max_old_space_size=2048 for Prod script and it worked. If someone can explain why is this so others can solve issues like mine and not waste 4 days.
2048 will not be enough as soon as your app grows.
I suspect that the node installed by the maven frontend in node sub folder is 32 bit, an easy way to be sure is to modify your package.json to run "node -p process.arch"
~yml
"webpack:prod": "node -p process.arch && yarn run cleanup && yarn run webpack:prod:main && yarn run clean-www",
~
We should catch the error and/or document it
Yeah you are right :
[INFO] $ node -p process.arch yarn run cleanup && yarn run webpack:prod:main && yarn run clean-www
[INFO] ia32
How can i fix this ?
You should ask the author of frontend-maven-plugin.
Code dealing with architecture is: https://github.com/eirslett/frontend-maven-plugin/blob/0a0d2b0076c2b03016a73d9023024bc18648cf40/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/Platform.java#L4-L14
I suppose that the value of java system property "os.arch" is wrong and leads to wrong download. Maybe java -version does not return 64 bits on your system or could be forced in plugin configuration.
i get amd64 from os.arch
I set --max_old_space_size=2048 for Prod script and it worked. If someone can explain why is this so others can solve issues like mine and not waste 4 days.
Thank you, this worked. I was struggling with this a lot.
node -p process.arch yarn run cleanup && yarn run webpack:prod:main && yarn run clean-www
Helped me to fix the issue. Thanks .
Hi all,
Having this issue since a period of time, i solved it by changing --max_old_space_size=2048 (it was 4096). I am running a Jhipster app on windows 7, 64 bits and ram = 4 GO (only 3,86 usable).
@HaithemOtt unfortunately as soon as your app code size grows up or uses more libraries, you will need more RAM
Effectively
Most helpful comment
I set --max_old_space_size=2048 for Prod script and it worked. If someone can explain why is this so others can solve issues like mine and not waste 4 days.