zowe / zowe/api-layer

Starting API ML on Already Used Port Should Give a Specific Message

Open
#3,747 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help-wanted Priority: High size/S
Dominant language
Java
Stars
92
Forks
81
Avg merge
1d 9h
Merged PRs (30d)
46

Description

I attempted to start a newly installed instance of API ML (v2.18) I used these config values:

zowe:
  externalPort: 3000
...
components:
  gateway:
    port: 3000

However, port 3000 was being used by another application on my system and so I received these errors in the job log:

2024-09-04 20:38:01.499 <ZWEAGW1:main:33554513> ZWESVUSR WARN  (o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
2024-09-04 20:38:04.707 <ZWEAGW1:main:33554513> ZWESVUSR WARN  (o.a.c.l.WebappClassLoaderBase) The web application [ROOT] appears to have started a thread named [RxIoScheduler-1 (Evictor)] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.misc.Unsafe.park(Native Method)
 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2089)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1104)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:820)
 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1085)
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
 java.lang.Thread.run(Thread.java:825)
2024-09-04 20:38:04.778 <ZWEAGW1:main:33554513> ZWESVUSR ERROR (o.s.b.SpringApplication) Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:186)
	at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:58)
	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:365)
	at java.lang.Iterable.forEach(Iterable.java:86)
	at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:160)
	at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:128)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:949)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:594)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:409)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
	at org.zowe.apiml.gateway.GatewayApplication.main(GatewayApplication.java:58)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
	at java.lang.reflect.Method.invoke(Method.java:508)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
	at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229)
	at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43)
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:183)
	... 20 common frames omitted
Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
	at org.apache.catalina.core.StandardService.addConnector(StandardService.java:222)
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282)
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebSe
rver.java:213)
	... 22 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
	at org.apache.catalina.connector.Connector.startInternal(Connector.java:1058)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
	at org.apache.catalina.core.StandardService.addConnector(StandardService.java:219)
	... 24 common frames omitted
Caused by: java.net.SocketException: EDC5111I Permission denied. (errno2=0x744C7246)
	at sun.nio.ch.Net.bind0(Native Method)
	at sun.nio.ch.Net.bind(Net.java:460)
	at sun.nio.ch.Net.bind(Net.java:452)
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:253)
	at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:268)
	at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:223)
	at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1373)
	at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1459)
	at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:673)
	at org.apache.catalina.connector.Connector.startInternal(Connector.java:1055)
	... 26 common frames omitted

This has messages like Unable to start embedded Tomcat server and EDC5111I Permission denied. but neither of these let me to the conclusion that the port I selected was already in use. Is it possible to detect this situation and issue a specific message when it occurs?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The report names org.zowe.apiml.gateway.GatewayApplication.main and shows Spring Boot/Tomcat startup failures, but no source file or test. Start by tracing gateway startup when port 3000 is occupied and reproduce the failure; done means the job log gives a specific already-in-use-port message, with coverage for that case.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.