简体   繁体   中英

Is Tomcat 8's port use interfering with itself when run out of Netbeans?

We have a web application that's been running on Tomcat 7, we're moving to Tomcat 8 and are now depending on an internal microservice for the application as well. We use Netbeans.

I have made the necessary changes to configuration such that I can start the microservice app and then the web application on my machine from the command line. However, when I attempt to run the web app from within Netbeans, it tells me "Starting of Tomcat failed, the server port 8443 is already in use".

I don't know why that port is reported as in use when run from within Netbeans, but not if the same server with the same web application is run from the command line. Does anyone have any ideas on what to check?

A quick way to make progress is simply to use a port other than 8443 . That won't necessarily resolve the problem you are experiencing, but it will circumvent it. To do that:

  • Stop Tomcat.
  • Pick a port other than 8443 . I chose 8447 .
  • Run the following command from the console to verify that port 8447 is not already being used:

netstat -aon | findstr 8447

  • That's the syntax for Windows - I think it is different on Linux. If nothing is displayed then 8447 is an available port. Otherwise keep picking different port numbers until you find one which is available.
  • Take a backup of server.xml which resides in directory {Tomcat dir}/conf (so you can regress if necessary).
  • Edit server.xml replacing all instances of 8443 with 8447 , or whatever alternative port you chose, and save the file.
  • Start Tomcat. It will come up using port 8447 instead of 8443 . You can verify that in Tomcat's log shown in NetBeans; look for the string https-openssl-apr-8447 to verify:

09-Jan-2018 02:07:26.279 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"] 09-Jan-2018 02:07:26.285 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [" https-openssl-apr-8447 "] 09-Jan-2018 02:07:26.290 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"] 09-Jan-2018 02:07:26.293 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 2585 ms

  • You should now be able to test your web app. I just verified that this approach works using Tomcat 9 but I'm sure it would also work with Tomcat 8.

As a separate issue, once everything is working on port 8447 , run netstat -aon | findstr 8443 to see if port 8443 is still being used while Tomcat is running. If so then (on Windows) get the PID of the process that is still using that port, and then lookup that PID on the Details tab of Task Manager . Here's a screenshot showing that in my case port 8447 was used by PID 2340 which was an instance of java.exe for Tomcat:

Tomcat PID

If none of that resolves anything:

  • Please advise which Operating System and which version of NetBeans are being used.
  • Add the relevant portion of Tomcat's log within NetBeans to your post.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM