How to configure IntelliJ 11 + remote tomcat 6 + maven imported modules?

15,203

1) Producing a WAR

To have IntelliJ IDEA produce the war file, you need to have a 'web' facet defined for the module.

  1. Go to File > Project Structure > Modules
  2. Select your module
  3. Add (via the '+' icon or Alt+Insert) a web facet.
  4. Configure the facet. (If you are following standards, the defaults should be OK, but check them.)

Once you have a web facet defined, you can then define a WAR artifact.

  1. Go to the "Artifacts" page in the Project Structure dialog.
  2. You will first need to create an exploded war artifact.
    1. Click the add button
    2. Select "Web Application: Exploded" and then "From Modules"
    3. In the popup, select your module. Verify that the web application artifact is correctly defined. Again, if you are following standards, the defaults should be good.
  3. Once the exploded artifact is defined, click the add artifact button again and select "Web Application: Archie", and then "For {module-name}:war exploded" (or what ever you named your exploded artifact if you did not use the default name).
  4. Verify the configuration.

IDEA will now create a war file when you build.

2) Deploy to Remote Server

You can do this as part of your run/debug configuration. See next section.

3) Remotely Debug

You simply need to create a run/debug configuration to do this.

  1. Go to Run > Edit Configurations from the menu
  2. Click the Add Icon (or type Alt + Insert) and select Tomcat Server > Remote from the pop-up list
  3. Configure the run/debug settings. I recommend clicking the Help button. It will show you what the various options are. (Be sure to pay attention which are available for Local, Remote, or Both.) Take a look at the "Remote Staging" information on the Help page. Also, be sure to select the deployment tab and select the artifact you want to deploy (and specify the context path.) The Startup/Connection tab, "Debug" section will have needed debug connection information that needs to be configured on the remote Tomcat server.
  4. By default, "Make" should be listed in the "Before Launch" section. And once you add the artifact to be deployed, the before launch should also show that the artifact will be built. If not, add it.

Once defined, you can execute this run/debug configuration. To debug, launch using the "debug" button or shortcut (Shift+F9). This will make your project, create the war, deploy it, and then connect the debugger. If you just want to run without debugging, click the Run button, or use the shortcut Shift+F10.

Share:
15,203
Nawar
Author by

Nawar

Updated on June 04, 2022

Comments

  • Nawar
    Nawar almost 2 years

    Here is what I have now:

    • Imported multiple maven modules into IntelliJ project
    • Maven targets run OK from the Maven Projects flyout - a war file is created.
    • Making the project from the "Build|Make Project" is OK too. But here no war is created, just the .class files.
    • Tomcat 6 running on another machine
    • Manually deploying the war produced by the package maven goal to the remote tomcat works OK.
    • A local tomcat 6 instance is configured as an application server. I am not going to use this instance, but the JetBrains documentation says I must have a local instance in order to have an application server configured with the IDE.
    • No artifacts and no facets are configured for the IntelliJ project.
    • The remote tomcat is run with JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=1317,suspend=n,server=y

    I want to be able to debug my server in the IntelliJ. Which means, that I must have a Run configuration, which does the following:

    1. Produces the respective war file. Making the project does not produce any war, so it should be either modified to produce one or the war should be created as part of a Run configuration. I have no idea which one is the right way.
    2. Deploys or redeploys it to the remote tomcat instance.
    3. Lets me remotely debug the code.

    How do I do it?

    EDIT

    Correction. One of the projects has the Web facet automatically added to it, because IntelliJ has noticed the ...\src\main\webapp\WEB-INF\web.xml file.

    EDIT2

    Here is my remote tomcat run configuration dialog:

    enter image description here

    The documentation says I should have the Perform on 'Update' action option in the dialog. Where is it?

    EDIT3

    I have added Spring support and Spring web services plugins to IntelliJ, since we are using them. Now IntelliJ recognized it and added the Spring facet:

    enter image description here

    However, there is still no Perform on 'Update' action option in the remote Tomcat Run Configuration dialog.

    What am I missing?

    EDIT4

    The mystery of a missing Perform on 'Update' action option is resolved - How to enable the Perform on 'Update' action option in the remote Tomcat run configuration in IntelliJ?