[오류] Ajax에서 404

url을 똑같이 mapping 했는데 404 에러가 났다.
오류를 읽어보니 web.xml에서 servlet 설정을 다시 해야된다는 것 같다.
비동기가 여러군데에서 실행되어 충돌되는 것 같은데,
아직 정확한 원인이 뭔지 모르겠다.

같은 팀원이 web socket으로 화상채팅, 채팅을 구현하고 있는데
그것때문에 자꾸 충돌이 나는 것 같다.

java.lang.IllegalArgumentException: Async support must be enabled on a servlet and for all filters involved in async request processing. This is done in Java code using the Servlet API or by adding "<async-supported>true</async-supported>" to servlet and filter declarations in web.xml. Also you must use a Servlet 3.0+ container
	at org.springframework.util.Assert.isTrue(Assert.java:118)
	at org.springframework.http.server.ServletServerHttpAsyncRequestControl.<init>(ServletServerHttpAsyncRequestControl.java:61)
	at org.springframework.http.server.ServletServerHttpRequest.getAsyncRequestControl(ServletServerHttpRequest.java:224)
	at org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession.handleInitialRequest(AbstractHttpSockJsSession.java:225)
	at org.springframework.web.socket.sockjs.transport.handler.AbstractHttpSendingTransportHandler.handleRequestInternal(AbstractHttpSendingTransportHandler.java:76)
	at org.springframework.web.socket.sockjs.transport.handler.HtmlFileTransportHandler.handleRequestInternal(HtmlFileTransportHandler.java:123)
	at org.springframework.web.socket.sockjs.transport.handler.AbstractHttpSendingTransportHandler.handleRequest(AbstractHttpSendingTransportHandler.java:66)
	at org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService.handleTransportRequest(TransportHandlingSockJsService.java:313)
	at org.springframework.web.socket.sockjs.support.AbstractSockJsService.handleRequest(AbstractSockJsService.java:439)
	at org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler.handleRequest(SockJsHttpRequestHandler.java:134)
	at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:53)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

WARN : org.springframework.web.servlet.PageNotFound - No mapping for GET /error/Exception
Fri Apr 15 16:47:48 KST 2022 : 3djlakl1 익셉션 발생: Async support must be enabled on a servlet and for all filters involved in async request processing. This is done in Java code using the Servlet API or by adding "<async-supported>true</async-supported>" to servlet and filter declarations in web.xml. Also you must use a Servlet 3.0+ container
4월 15, 2022 4:47:48 오후 org.apache.catalina.core.StandardWrapperValve invoke
심각: Servlet.service() for servlet [appServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS request, uri=http://localhost/echo/901/3djlakl1/xhr?t=1650008868508; nested exception is org.springframework.web.socket.sockjs.SockJsTransportFailureException: Failed to open session; nested exception is java.lang.IllegalArgumentException: Async support must be enabled on a servlet and for all filters involved in async request processing. This is done in Java code using the Servlet API or by adding "<async-supported>true</async-supported>" to servlet and filter declarations in web.xml. Also you must use a Servlet 3.0+ container] with root cause
java.lang.IllegalArgumentException: Async support must be enabled on a servlet and for all filters involved in async request processing. This is done in Java code using the Servlet API or by adding "<async-supported>true</async-supported>" to servlet and filter declarations in web.xml. Also you must use a Servlet 3.0+ container
	at org.springframework.util.Assert.isTrue(Assert.java:118)
	at org.springframework.http.server.ServletServerHttpAsyncRequestControl.<init>(ServletServerHttpAsyncRequestControl.java:61)
	at org.springframework.http.server.ServletServerHttpRequest.getAsyncRequestControl(ServletServerHttpRequest.java:224)
	at org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession.handleInitialRequest(AbstractHttpSockJsSession.java:225)
	at org.springframework.web.socket.sockjs.transport.handler.AbstractHttpSendingTransportHandler.handleRequestInternal(AbstractHttpSendingTransportHandler.java:76)
	at org.springframework.web.socket.sockjs.transport.handler.AbstractHttpSendingTransportHandler.handleRequest(AbstractHttpSendingTransportHandler.java:66)
	at org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService.handleTransportRequest(TransportHandlingSockJsService.java:313)
	at org.springframework.web.socket.sockjs.support.AbstractSockJsService.handleRequest(AbstractSockJsService.java:439)
	at org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler.handleRequest(SockJsHttpRequestHandler.java:134)
	at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:53)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

=> 이 오류는 webSocket 문제가 맞는데 ,
404 오류는 VO가 잘못되어서 오류가 났다.
VO에서 편리하게 format처리하도록 부장님이 알려주셨는데, 그 처리를 하는 중에
아래 VO에서 public String getProdInfoNmDisplay() 메서드에서 prodInfoNm이 Null값일때에도 실행되었기 때문에 Nullpointer 오류가 나고 404에러가 났던 것이다.

if로 null값일 경우를 따로 빼주니까 오류가 사라졌다.

package kr.or.tco.ordr.vo;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Repository;

@Repository
public class OrdrVO {
	private int ordrId          ; //발주아이디
	private String prodInfoId   ; //상품아이디
	private int ordrQty         ; //발주수량
	private Date ordrDt         ; //발주일
	private String brncofcId    ; //발주지점
	private String brncofcNm    ; //발주지점
	private String ordrSe       ; //발주구분
	private String ordrYn       ; //수주여부
	private String prodInfoNm   ; //상품명
	private int prodInfoPrchsAmt; //상품매입가격
	private String ordrWhyn		; //상품입고여부
	private String condition	; //모든상품 입고여부
	
	public String getOrderAmount() { //상품매입가격 * 발주수량
		String res = new DecimalFormat("#,###").format(prodInfoPrchsAmt * ordrQty); 
		res = res + "원";
		return res;
	}
	public String getProdInfoPrchsAmtDisplay() { //상품매입가격
		String res = new DecimalFormat("#,###").format(prodInfoPrchsAmt); 
		res = res + "원";
		return res;
	}
	public String getOrdrQtyDisplay() { //발주수량
		String res = new DecimalFormat("#,###").format(ordrQty); 
		return res;
	}
	public String getProdInfoNmDisplay() { //상품명
		String res = "";
		if(prodInfoNm!=null) {
			 res = this.prodInfoNm.replaceAll("_", " ");
			return res;
		}
		return res;
		
	}
	public String getOrdrDtDisplay() { //입고날짜
		String ordrDtDisplay = "";
		if(this.ordrDt != null) {
			ordrDtDisplay = new SimpleDateFormat("YYYY-MM-dd").format(this.ordrDt);
		}
		return ordrDtDisplay;
	}
	public void setOrdrDtDisplay(String ordrDtDisplay) {
		if(ordrDt != null) {
			try {
				this.ordrDt = new SimpleDateFormat("yyyy-MM-dd").parse(ordrDtDisplay);
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	public int getOrdrId() {
		return ordrId;
	}
	public void setOrdrId(int ordrId) {
		this.ordrId = ordrId;
	}
	public String getProdInfoId() {
		return prodInfoId;
	}
	public void setProdInfoId(String prodInfoId) {
		this.prodInfoId = prodInfoId;
	}
	public int getOrdrQty() {
		return ordrQty;
	}
	public void setOrdrQty(int ordrQty) {
		this.ordrQty = ordrQty;
	}
	public Date getOrdrDt() {
		return ordrDt;
	}
	public void setOrdrDt(Date ordrDt) {
		this.ordrDt = ordrDt;
	}
	public String getBrncofcId() {
		return brncofcId;
	}
	public void setBrncofcId(String brncofcId) {
		this.brncofcId = brncofcId;
	}
	public String getOrdrSe() {
		return ordrSe;
	}
	public void setOrdrSe(String ordrSe) {
		this.ordrSe = ordrSe;
	}
	public String getOrdrYn() {
		return ordrYn;
	}
	public void setOrdrYn(String ordrYn) {
		this.ordrYn = ordrYn;
	}
	public String getProdInfoNm() {
		return prodInfoNm;
	}
	public void setProdInfoNm(String prodInfoNm) {
		this.prodInfoNm = prodInfoNm;
	}
	public int getProdInfoPrchsAmt() {
		return prodInfoPrchsAmt;
	}
	public void setProdInfoPrchsAmt(int prodInfoPrchsAmt) {
		this.prodInfoPrchsAmt = prodInfoPrchsAmt;
	}
	public String getBrncofcNm() {
		return brncofcNm;
	}
	public void setBrncofcNm(String brncofcNm) {
		this.brncofcNm = brncofcNm;
	}
	public String getOrdrWhyn() {
		return ordrWhyn;
	}
	public void setOrdrWhyn(String ordrWhyn) {
		this.ordrWhyn = ordrWhyn;
	}
	public String getCondition() {
		return condition;
	}
	public void setCondition(String condition) {
		this.condition = condition;
	}
	@Override
	public String toString() {
		return "OrdrVO [ordrId=" + ordrId + ", prodInfoId=" + prodInfoId + ", ordrQty=" + ordrQty + ", ordrDt=" + ordrDt
				+ ", brncofcId=" + brncofcId + ", brncofcNm=" + brncofcNm + ", ordrSe=" + ordrSe + ", ordrYn=" + ordrYn
				+ ", prodInfoNm=" + prodInfoNm + ", prodInfoPrchsAmt=" + prodInfoPrchsAmt + ", ordrWhyn=" + ordrWhyn
				+ ", condition=" + condition + "]";
	}
	
	
}

좋은 웹페이지 즐겨찾기