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.

0
6 comments

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

0

Bummer on no way to change it.   This is why:

  • When the project/module is named abc-def, the generated war (in the maven repository) will be abc-def.war and the context in Tomcat itself is http://<server>.<domain>:<port>/abc-def
  • But for some crazy reason IntelliJ chooses to default to abc_dev_war.
  • The only way to fix it is to manually rename - in the Run/Debug configuration Deployment tab - and for each deployed artifact - the Application context to the correct Tomcat value.   

 

  • That is doable but quite a nuisance.
  • So… I would suggest to the IDEA developers that they either change their naming convention or allow users to specify a pattern for the context naming based on the name name of the project/module.

And you may close this ticket.  

0

You can use external source artifact if you build it with Maven and the context will be correct automatically from the war file name.

0

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.

0

Same issue. Any fix available? Its been almost a year?

0

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.

0

Please sign in to leave a comment.