4

I am trying to run my web app with IDEA intellij and tomcat server. I downloaded tomcat server, paste it in program files, made CATALINA_HOME and edit path to %CATALINA_HOME%\bin; . My run config:

enter image description here

When I start tomcat server from bin/startup.bat and try to run project I got error Error running event: Address localhost:8080 already in use.

When I don't start tomcat with bat file first I got an error: Application server was not connected before run configuration stop, reason: Unable to ping server at localhost:1099. When I run that bat script from tomcat and go to localhost:8080 i see tomcat start window.

JimHawkins
  • 4,843
  • 8
  • 35
  • 55
Spasoje Petronijević
  • 1,476
  • 3
  • 13
  • 27
  • You should not be manually running the .bat file at all if Tomcat properly configured in intellij. Check your tomcat configuration files, make sure they point to the correct startup, and potentially add in the option to kill the tomcat server before startup. – Compass Jan 03 '17 at 19:14
  • @Compass Thank you for answer. When I do not start tomcat manually i got 2nd error as I wrote. Which config file I should check? – Spasoje Petronijević Jan 03 '17 at 19:28
  • I think it's this one. http://stackoverflow.com/questions/19068977/intellij-cant-start-simple-web-application-unable-to-ping-server-at-localhost – Compass Jan 03 '17 at 19:30
  • perhaps this [answer](http://stackoverflow.com/a/35601869/1988304) of me gives you a hint ... – JimHawkins Jan 03 '17 at 20:31

4 Answers4

6
  1. check if you're using JDK 8 with Tomcat 9
  2. in your "Run Configuration", go to the tab "Deployment" and ensure that you've selected the correct war and chose a deployment path. For convenience, add the deployment path to the URL in the "After launch" section on the tab "Server"
  3. in your screenshot, on the tab "Server", I see there is no action defined in the section "Before launch". Did you delete it? By default, there are two entries like Build and Build 'simpleServlet:war' artifact. Add these entries by clicking on +
  4. before you start your web app via IntelliJ, ensure that Tomcat isn't running: open a browser and enter the URLhttp://localhost:8080 . There must be an error message "no connection" or similar. If you see the welcome page, stop Tomcat.
  5. run your application via IntelliJ enter image description here

enter image description here

JimHawkins
  • 4,843
  • 8
  • 35
  • 55
1

I've been struggling with this as a new developer and I find it's easiest when someone starts from scratch. My current version of IntelliJ is 2017.1.4. Using Tomcat 9.0.0

  1. File -> New Project -> Java -> check "Web Application" -> Name it and then Finish. Your current project directory should contain [.idea + src + web/WEB-INF] with a default index.jsp in the web directory and a web.xml in the WEB-INF directory. This step does a lot of the setup for you. This should also make steps 2 and 3 pointless.

  2. Under File -> Settings -> Facets, check if a Web Resource Directory exists (should point towards your web directory of your current project directory). If one doesn't, add one by hitting: + -> Web -> double-click resource directory to create.

  3. Under File -> Settings -> Artifacts, check if a "ProjectName:war exploded" exists. If not, create one by hitting: + -> Web Application: Exploded -> From Modules -> Select and Confirm your Project Folder.

  4. Next to the Run button in the top-right there should be a downward arrow for "Edit Configurations". Click that -> Edit Configurations -> + -> Tomcat Server -> Local. Under the Server tab, hit Configure and point to your Tomcat base directory (Ex: Tomcat 9.0.0.M22). Under Deployment Tab, hit: + -> Artifact -> "ProjectName:war exploded".

  5. Add something to your index.jsp so that you can actually see a result and hit run. It should automatically open your browser to your index.jsp page.

Normally you would have to configure your web.xml to your servlet class or use the welcome-file tags to specify which default pages to look for but index.html/index.jsp are defaults. So if you name your .jsp differently you will require additional configuration in your web.xml.

code_disciple
  • 182
  • 2
  • 17
0

Follow below steps :

  1. IntellJ IDEA we need to point the Tomcat application server after downloading from http://tomcat.apache.org/

  2. After opening the IntellJ IDEA click on the File menu on the right side you will be able to see the list inside the File menu Choose the File menu

  3. Click on the Settings -> Build, Execution, Deployment -> Application Server click on the + icon in Application Server Application

  4. Point the Tomcat Home directory to the downloaded Tomcat path say **C:/apache-tomcat-9.0.46** press Apply and Ok button

cursorrux
  • 1,382
  • 4
  • 9
  • 20
0

Resolved it by following the below configuration on my local: enter image description here

enter image description here

Jayant
  • 101
  • 1
  • 5