generator-jhipster: WARs are not executed on Tomcat while jars are working

Overview of the issue

I export as war and when i try to remote machine tomcat, it gives error.

Motivation for or Use Case

I cant deploy to tomcat.

Reproduce the error

1- Use jhipster to generate spring + angular project with gradle 2- Export as war with that command:

./gradlew -Pwar clean bootWar

because

./gradlew -Pprod -Pwar clean bootWar

gives error:

FAILURE: Build failed with an exception.

  • What went wrong: Task ‘bootWar??’ not found in root project ‘halil’. Some candidates are: ‘bootJar’, ‘bootWar’.

  • Try: Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 2s`

so , i use this:

``./gradlew -Pwar clean bootWar` then it gives war. 3- Put to tomcat. Then get error 4- Export as jar with that:

./gradlew -Pprod -Pjar clean bootJar 5- Use java -jar xx.jar to run and there is no error

Related issues

https://github.com/jhipster/generator-jhipster/issues/9829#issuecomment-589649434 https://github.com/jhipster/generator-jhipster/issues/5996

Suggest a Fix

I also tried to change new BaseHrefWebpackPlugin({ baseHref: to war file name but did not work

maybe tomcat versions

JHipster Version(s)
JHipster configuration

jhipster info INFO! Using JHipster version installed locally in current project’s node_modules INFO! Executing jhipster:info INFO! Options: from-cli: true Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
halil@0.0.1-SNAPSHOT C:\Projects\WORK\halil
`-- generator-jhipster@6.7.1

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.bpn.legolas",
      "nativeLanguage": "tr"
    },
    "jhipsterVersion": "6.7.1",
    "applicationType": "monolith",
    "baseName": "halil",
    "packageName": "com.bpn.legolas",
    "packageFolder": "com/bpn/legolas",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "no",
    "enableHibernateCache": false,
    "websocket": false,
    "databaseType": "no",
    "devDatabaseType": "no",
    "prodDatabaseType": "no",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "gradle",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "angularX",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1582210924944,
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": true,
    "nativeLanguage": "tr",
    "languages": ["tr", "al", "ar-ly"],
    "blueprints": []
  }
}
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_231” Java™ SE Runtime Environment (build 1.8.0_231-b11) Java HotSpot™ 64-Bit Server VM (build 25.231-b11, mixed mode)

git version 2.21.0.windows.1

node: v12.14.1

npm: 6.13.4

yeoman: 3.1.1

yarn: 1.22.0

INFO! Congratulations, JHipster execution is complete!

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

none

Browsers and Operating System

windows 10. chrome my machine client machine is same too tomcat version: 8.5 **java:**8

  • [x ] Checking this box is mandatory (this is just to show you read everything)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 23 (15 by maintainers)

Most upvoted comments

Here what I know, from my recent tests:

  • Maven + War (using java -jar *.war) -> KO
  • Maven + War + Tomcat -> KO
  • Gradle + War -> OK
  • Gradle + War + Tomcat -> KO That’s why it’s disabled in our CI currently (except for Gradle)

Then, I already discussed with @PierreBesson about it, and I think it’s time for removing War packaging. It requires too much effort to maintain it, for nothing. It’s broken since months, but no one wants to fix it.

So, @aydincaner : you are really welcome to provide a PR and propose a fix, as you’re using War file.

@caneraydinbey Based on the screenshots, you are deploying under a context path, but did not configure the baseHref. In your case it should be /halil-2-0.0.1-SNAPSHOT/ (configure it here)

@rennydonny, I just tried with a gateway project and don’t see any issue. In your shared configurations, you have missed the trailing slash and base: '/gateway' should be base: '/gateway/'

@rennydonny please open a new issue with all required details rather than commenting a 7 months old issue

@caneraydinbey Your baseHref needs to match the baseHref in my last message, you forgot the trailing slash. It will apply to both dev and prod, so you may want to copy the BaseHrefWebpackPlugin config to webpack.prod.js and only apply it there (or configure the same context path in dev).

@geyuqiu jar with gradle worked also in tomcat?

@pascalgrimaud i dont think i can do that PR. I need too much time

Ajd i am putting two screenshots. They seem maybe helpful. The error in the console and in the network tab.

Annotation 2020-02-24 121554

Annotation 2020-02-24 121821

've never had a great relationship with gradle, maybe it was because of unclear error messages of missing gradle dependencies I don’t remember. I could be wrong because of Gradle improvements in the last few years. Nonetheless… I tried to avoid that, except for Android, where there are no alternatives xD