Modifying Configuration Template "Application Context" default format for WAR?
Answered
When I create a Run/Debug Configuration for Tomcat Server and use the Deployment to add deployables, the application context for a module abc-def gets generated by IDEA as abc_def_war.
Unfortunately, the real context in Tomcat is indeed abc-def (dashes, not underscores and no _war at the end). I always modify the Application Context manually for each included module, but it is tedious and error-prone. Is there a way to modify the default format for the template?
I looked in Edit Configuration Templates and found no option to do so. I also looked in the global settings but could not find it.
Any suggestions would be greatly welcome.
Please sign in to leave a comment.
IntelliJ IDEA instructs Tomcat to use the context specified in this field. It should work with any text specified there by default, including
abc_def_war.There is no way to change the default context name.
Related issues:
https://youtrack.jetbrains.com/issue/IDEA-109843/Default-run-debug-config-for-webapps
https://youtrack.jetbrains.com/issue/IDEA-222248/Default-Application-context-name-in-Server-run-Config-for-tomcat-should-be-definable-by-module-source
Bummer on no way to change it. This is why:
And you may close this ticket.
You can use external source artifact if you build it with Maven and the context will be correct automatically from the war file name.
Right, deploying from the artifact is no problem, as it is generated correctly by Maven. It is running the artifact in the IDE that is a royal pain in the rear and requires editing every single artifact Context value in the IDE, since the IDE generates a Context that doesn't execute.
But if that is the code - no matter how inadequate - that is the code. Go ahead and close the ticket.
Same issue. Any fix available? Its been almost a year?
Robert G Paris Thanks for commenting. Unfortunately, there is no fix available yet. This issue has been open for a while and we understand the frustration.
The problem is tracked here: https://youtrack.jetbrains.com/issue/IDEA-222248 — Tomcat deployment: Application context replaces hyphens with underscores in artifact name. In the meantime, here is the workaround:
1. Open Run/Debug Configurations and select your Tomcat configuration.
2. Go to the Deployment tab.
3. Select the deployed artifact in the list.
4. Manually edit the Application context field to restore the correct path (e.g., change /my_package_war_exploded to /my-package).
Note that this has to be repeated each time the artifact is re-added to the configuration. If you haven't already, please vote on https://youtrack.jetbrains.com/issue/IDEA-222248 to help raise the priority, and watch the issue for updates.