-- 가장 빨리 만나는 스프링부트

1) 포트 사용 에러

 

오류: 에이전트에 예외사항이 발생했습니다. : java.rmi.server.ExportException: Port already in use: 35199; nested exception is: 
java.net.BindException: Address already in use: JVM_Bind

 

실행 중지를 하지 않고 다시 실행하는 경우 위와 같은 에러가 종종 발생한다.

 

사용하려는 포트가 이미 사용중이라는 말로 사용중인 포트의 프로세스아이디를 찾아서 해당 프로세스를 죽여줘야 한다.

 

윈도우키+r -> cmd -> netstat 명령어로 사용중인 포트의 프로세스아이디를 찾아 킬하면 됩니다.

 

8080 사용 프로세스 검색 및 프로세스 종료시키기

 

cmd > netstat -ano | findstr 8080

실행을 하면 8080포트를 사용하는 프로세스 목록이 나옵니다.

가장 오른쪽의 프로세스 아이디를 킬해주면 됩니다.

cmd > taskkill /F /PID 8964

 

리소스 모니터에서 해당 프로세스 종료하기

작업관리자의 리소스모니터에서 해당 프로세스를 종료할 수 도 있습니다.

 

2) Unable to start embedded container

톰캣과 언더토우의 충돌

org.apache.tomcat.websocket.WsWebSocketContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer

 

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.ClassCastException: org.apache.tomcat.websocket.WsWebSocketContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
at com.example.App.main(App.java:13)
Caused by: java.lang.ClassCastException: org.apache.tomcat.websocket.WsWebSocketContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer
at io.undertow.websockets.jsr.Bootstrap.handleDeployment(Bootstrap.java:62)
at io.undertow.servlet.core.DeploymentManagerImpl.handleExtensions(DeploymentManagerImpl.java:244)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:149)
at org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory.createDeploymentManager(UndertowEmbeddedServletContainerFactory.java:340)
at org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory.getEmbeddedServletContainer(UndertowEmbeddedServletContainerFactory.java:203)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:157)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 7 common frames omitted

 

 

pom.xml 에서 스프링 부트의 기본 서버인 톰캣과 추가된 서버 언더토우의 충돌문제

 

	<dependency>
  		<groupId>org.springframework.boot</groupId>
  		<artifactId>spring-boot-starter-web</artifactId>
  	</dependency>
 
  	<dependency>
  		<groupId>org.springframework.boot</groupId>
  		<artifactId>spring-boot-starter-undertow</artifactId>
  	</dependency>

디팬던시에 undertow가 추가된 경우

spring-boot-starter-web 부분에서 톰캣을 사용하지 않는다는 설정을 추가해 주어야 한다.

  	<dependency>
  		<groupId>org.springframework.boot</groupId>
  		<artifactId>spring-boot-starter-web</artifactId>
 		<exclusions>
  			<exclusion>
  				<groupId>org.apache.tomcat.embed</groupId>
  				<artifactId>tomcat-embed-websocket</artifactId>
  			</exclusion>
  		</exclusions>
  	</dependency>
  	<dependency>
  		<groupId>org.springframework.boot</groupId>
  		<artifactId>spring-boot-starter-undertow</artifactId>
  	</dependency>

또는 undertow를 사용하지 않는 방법이 있다.

 

+ Recent posts