IntelliJ and Tomcat.. Howto..?

TomcatIntellij Idea

Tomcat Problem Overview


Using Netbeans, I develop sites with Tomcat as the local server to manage it. In Netbeans it was "Install, write hit Run and it works" How do I pull the same thing off in IntelliJ?

I can't find step-by-step instructions for this.

Tomcat Solutions


Solution 1 - Tomcat

NOTE: Community Edition doesn't support JEE.

First, you will need to install a local Tomcat server. It sounds like you may have already done this.

Next, on the toolbar at the top of IntelliJ, click the down arrow just to the left of the Run and Debug icons. There will be an option to Edit Configurations. In the resulting popup, click the Add icon, then click Tomcat and Local.

From that dialog, you will need to click the Configure... button next to Application Server to tell IntelliJ where Tomcat is installed.

Solution 2 - Tomcat

Here is step-by-step instruction for Tomcat configuration in IntellijIdea:

  1. Create IntellijIdea project via WebApplication template. Idea should be Ultimate version, not Community edition

enter image description here

  1. Go to Run-Edit configutaion and set up Tomcat location folder, so Idea will know about your tomcat server enter image description here

  2. Go to Deployment tab and select Artifact. Apply enter image description here

  3. In src folder put your servlet (you can try my example for testing purpose) enter image description here

  4. Go to web.xml file and link your's servlet like this

enter image description here

  1. In web folder put your's .jsp files (for example hey.jsp)

enter image description here

  1. Now you can start you app via IntellijIdea. Run(Shift+F10) and enjoy your app in browser:

- to jsp files: http://localhost:8080/hey.jsp (or index.jsp by default)

- to servlets via virtual link you set in web.xml : http://localhost:8080/st

Solution 3 - Tomcat

Which version of IntelliJ are you using? Note that since last year, IntelliJ exists in two versions:

  • Ultimate Edition, which is the complete IDE
  • Community Edition, which is free but does not support JavaEE developments.

(see differences here)

In case you are using the Community Edition, you will not be able to manage a Tomcat installation.

In case you are using the Ultimate Edition, you can have a look at:

Solution 4 - Tomcat

You can also debug tomcat using the community edition (Unlike what is said above).

Start tomcat in debug mode, for example like this: .\catalina.bat jpda run

In intellij: Run > Edit Configurations > +

Select "Remote" Name the connection: "somename" Set "Port:" 8000 (default 5005)

Select Run > Debug "somename"

Solution 5 - Tomcat

Please verify that the required plug-ins are enabled in Settings | Plugins, most likely you've disabled several of them, that's why you don't see all the facet options.

For the step by step tutorial, see: Creating a simple Web application and deploying it to Tomcat.

Solution 6 - Tomcat

The problem I had was due to the fact that I was unknowingly editing the default values and not a new Tomcat instance at all. Click the plus sign at the top left part of the Run window and select Tomcat | Local from there.

Solution 7 - Tomcat

In Netbeans you can right click on the project and run it, but in IntelliJ IDEA you have to select the index.jsp file or the welcome file to run the project.

this is because Netbeans generate the following tag in web.xml and IntelliJ do not.

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMantarView Question on Stackoverflow
Solution 1 - TomcatSteven BenitezView Answer on Stackoverflow
Solution 2 - TomcatAconicView Answer on Stackoverflow
Solution 3 - TomcatRomain LinsolasView Answer on Stackoverflow
Solution 4 - TomcatMartinMView Answer on Stackoverflow
Solution 5 - TomcatCrazyCoderView Answer on Stackoverflow
Solution 6 - TomcatdamdView Answer on Stackoverflow
Solution 7 - TomcatAmmar BozorgvarView Answer on Stackoverflow