NItesh Shrestha
NItesh Shrestha

Reputation: 76

Unable to start Tomcat server in IntelliJ IDEA

enter image description hereenter image description hereI found following issue whenever i try to run tomcat server with intellijidea. I have tried adding hostname to localhost but didn't work. Any suggestions? enter image description here

enter image description here

Upvotes: 1

Views: 4539

Answers (3)

Koraktor
Koraktor

Reputation: 42893

This may happen if the machine has multiple or changing IP adresses (e.g. when using VPN or Hyper-V, Docker or other virtualization).

The solution is to define the IP address Tomcat should use for RMI:

-Djava.rmi.server.hostname=127.0.0.1

(This is a sane default for a Tomcat running locally, but you’re setup might require a different one.)

This has to be set so it’s applied as a command-line argument for the JVM. This might be in IntelliJ or Tomcat itself (for Linux systems bin/setenv.sh in the Tomcat directory, for a Windows service it’s usually in HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Apache Software Foundation\Procrun 2.0\Tomcat9\Parameters\Java\Options.

Upvotes: 0

Robert
Robert

Reputation: 1

I had an issue where Tomcat appeared to have started inside IntelliJ, but when I tried to open the Tomcat homepage I was getting "HTTP 404 Not Found" in the browser. Starting Tomcat standalone (running startup.bat from the command prompt) started Tomcat and I could see the homepage fine.

I compared the output of running both standalone and within IntelliJ and noticed that CATALINA_BASE was different.

So I created a setenv.bat file in Tomcat bin directory (it was initially not there) and set CATALINA_BASE there like: set CATALINA_BASE=C:\apache-tomcat-8.5.14

After that, Tomcat starts from IntelliJ and I can access the homepage.

Just putting this out there because I was at a loss why the page was not available when Tomcat seemed to have started OK. Hope this will help someone.

Upvotes: 0

Stanislav
Stanislav

Reputation: 28096

Take a closer look at the server's output, to see the reason, why was Tomcat not started:

java.net.UnknownHostException: nitesh-pc: nitesh-pc

That could mean, that you have a problem with your hosts file (in OS Windows it could be found at {WindowsFolder}\System32\drivers\etc\hosts). You just need to add your hostname to localhost ip-address (don't forget to uncomment it, if needed), like:

127.0.0.1       localhost       nitesh-pc

And then try to restart your server again.

Upvotes: 2

Related Questions