runDev.bat
'java, spring' 카테고리의 다른 글
400Bad Request: 필수파라미터 누락 등의 에러, 삽질방지위해서는 에러메세지 잘보자! (0) | 2024.01.19 |
---|---|
java stream (0) | 2022.04.28 |
Quartz (0) | 2022.04.19 |
Tomcat's directories (0) | 2021.03.03 |
Java Web Application (0) | 2021.03.02 |
runDev.bat
400Bad Request: 필수파라미터 누락 등의 에러, 삽질방지위해서는 에러메세지 잘보자! (0) | 2024.01.19 |
---|---|
java stream (0) | 2022.04.28 |
Quartz (0) | 2022.04.19 |
Tomcat's directories (0) | 2021.03.03 |
Java Web Application (0) | 2021.03.02 |
SecurtyContext이런용어 때문에 보안토큰에 문제있을거라고 생각했으나 아니었음, 밑에 Exception message를 잘봐야했음
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.security.web.FilterChainProxy - Securing POST /files/manual/upload/00060101_PlantInfo/2024/01/
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.s.w.c.SecurityContextPersistenceFilter - Set SecurityContextHolder to empty SecurityContext
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.s.w.a.AnonymousAuthenticationFilter - Set SecurityContextHolder to anonymous SecurityContext
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.s.w.a.i.FilterSecurityInterceptor - Authorized public object filter invocation [POST /files/manual/upload/00060101_PlantInfo/2024/01/]
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.security.web.FilterChainProxy - Secured POST /files/manual/upload/00060101_PlantInfo/2024/01/
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.s.w.c.HttpSessionSecurityContextRepository - Did not store anonymous SecurityContext
2024-01-19 10:29:24 [http-nio-8007-exec-10] [WARN ] o.s.w.s.m.s.DefaultHandlerExceptionResolver - Resolved [org.springframework.web.multipart.support.MissingServletRequestPartException: Required request part 'UploadFiles' is not present]
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.s.w.c.HttpSessionSecurityContextRepository - Did not store anonymous SecurityContext
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.s.w.c.SecurityContextPersistenceFilter - Cleared SecurityContextHolder to complete request
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.security.web.FilterChainProxy - Securing POST /error
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.s.w.c.SecurityContextPersistenceFilter - Set SecurityContextHolder to empty SecurityContext
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.s.w.a.AnonymousAuthenticationFilter - Set SecurityContextHolder to anonymous SecurityContext
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.security.web.FilterChainProxy - Secured POST /error
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.s.w.c.HttpSessionSecurityContextRepository - Did not store anonymous SecurityContext
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.s.w.c.HttpSessionSecurityContextRepository - Did not store anonymous SecurityContext
2024-01-19 10:29:24 [http-nio-8007-exec-10] [DEBUG] o.s.s.w.c.SecurityContextPersistenceFilter - Cleared SecurityContextHolder to complete request
2024-01-19 10:29:26 [pool-2-thread-1] [DEBUG] o.a.h.i.c.PoolingHttpClientConnectionManager - Closing expired connections
2024-01-19 10:29:26 [pool-2-thread-1] [DEBUG] o.a.h.i.c.PoolingHttpClientConnectionManager - Closing connections idle longer than 30 SECONDS
[windows] sts(SpringToolSuite) eclipse 실행 script (0) | 2024.01.25 |
---|---|
java stream (0) | 2022.04.28 |
Quartz (0) | 2022.04.19 |
Tomcat's directories (0) | 2021.03.03 |
Java Web Application (0) | 2021.03.02 |
Group by
public List<RegionPayload> getAllRegions() {
List<RegionPayload> result = new ArrayList<>();
List<Region> allRegion = regionRepository.findAll();
Map<String, List<Region>> regionMap =
allRegion.stream().collect(Collectors.groupingBy(Region::getRegion));
for (Map.Entry<String, List<Region>> elem : regionMap.entrySet())
result.add(new RegionPayload(elem.getKey(), elem.getValue()));
return result;
}
import com.lge.cdp.model.Region;
import java.util.List;
import lombok.AllArgsConstructor;
// import lombok.ToString;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
// @ToString
public class RegionPayload {
private String region;
private List<Region> countryList;
}
[windows] sts(SpringToolSuite) eclipse 실행 script (0) | 2024.01.25 |
---|---|
400Bad Request: 필수파라미터 누락 등의 에러, 삽질방지위해서는 에러메세지 잘보자! (0) | 2024.01.19 |
Quartz (0) | 2022.04.19 |
Tomcat's directories (0) | 2021.03.03 |
Java Web Application (0) | 2021.03.02 |
400Bad Request: 필수파라미터 누락 등의 에러, 삽질방지위해서는 에러메세지 잘보자! (0) | 2024.01.19 |
---|---|
java stream (0) | 2022.04.28 |
Tomcat's directories (0) | 2021.03.03 |
Java Web Application (0) | 2021.03.02 |
tomcat (0) | 2021.03.02 |
bin: contains the binaries; and startup script (startup.bat for Windows and startup.sh for Unixes and Mac OS), shutdown script (shutdown.bat for Windows and shutdown.sh for Unix and Mac OS), and other binaries and scripts.
- catalina.sh - 여기에 변수 추가는 안해야함 (하지말라고 나와있음 Do not set the variables...)
- setenv.sh, setenv.bat 여기에다 java option, classpath 추가할 것
conf: contains the system-wide configuration files, such as server.xml, web.xml, and context.xml.
server.xml
<Server port="${port.shutdown}" shutdown="SHUTDOWN">
<Connector port="${port.http}" protocol="HTTP/1.1"
maxParameterCount="-1" maxPostSize="-1" maxThreads="512" connectionTimeout="90000"
redirectPort="${port.https}" URIEncoding="UTF-8"/>
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="90000"
redirectPort="8443" />
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
type="RSA" />
</SSLHostConfig>
</Connector>
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true" >
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
certificateFile="conf/localhost-rsa-cert.pem"
certificateChainFile="conf/localhost-rsa-chain.pem"
type="RSA" />
</SSLHostConfig>
</Connector>
<Connector port="${port.ajp}" protocol="AJP/1.3" redirectPort="${port.https}"
maxParameterCount="-1" maxPostSize="-1" maxThreads="512" connectionTimeout="90000" URIEncoding="UTF-8"/>
--> -Dport.http=8180 -Dport.https=8543 -Dport.ajp=8109 -Dport.shutdown=8105
nc -z 10.150.33.35 8180으로 확인결과 8180 8109 8080-open, 8543,8443-close
browser에서는 8180만 응답됨, 8080은 Whitelabel Error Page(권한없는 화면접속시 발생)
--> port="${port.http}" connectionTimeout="90000" 20000으로 고쳐도 1분후 응답받음 why?
web.xml
context.xml
webapps: contains the webapps to be deployed. You can also place the WAR (Webapp Archive) file for deployment here.
lib: contains the Tomcat's system-wide JAR files, accessible by all webapps. You could also place external JAR file (such as MySQL JDBC Driver) here.
work: Tomcat's working directory used by JSP, for JSP-to-Servlet conversion
logs: contains Tomcat's log files. You may need to check for error messages here
설정위치 | ||
|
특정 managing을 담당하는 application에 의해 남는 로그 | (in conf/logging.properties) |
|
어떤 접근에 대한 log |
(in conf/server.xml) prefix="localhost_access.log." suffix=".txt" |
|
내부적으로 관리하는 host에 대한 내용 | (in conf/logging.properties) |
|
전반적인 console 로그 (각 application에서 발생하는 system out console) |
(in bin/catalina.sh) CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out → 경로 바꾸고 싶으면 setenv.sh, setenv.bat에 CATALINA_OUT 변수와 값을 추가하자! |
|
catalina engine에 대한 내용 | (in conf/logging.properties) |
java stream (0) | 2022.04.28 |
---|---|
Quartz (0) | 2022.04.19 |
Java Web Application (0) | 2021.03.02 |
tomcat (0) | 2021.03.02 |
spring-boot profile별 실행 (0) | 2020.03.25 |
reference: https://www.journaldev.com/
JEE server driven technology (javax.servlet, javax.servlet.http)
RequestDispatcher.forwardResponse.sendRedirect
brower가 redirection을 | 알 수 없다 | 알 수 있다 |
other context로 보낼수 | 없다 | 있다 |
extra network call | 발생안함 | 발생함 |
Servlet attributes (!=init parameters defined in web.xml)
Quartz (0) | 2022.04.19 |
---|---|
Tomcat's directories (0) | 2021.03.03 |
tomcat (0) | 2021.03.02 |
spring-boot profile별 실행 (0) | 2020.03.25 |
java time - Instant, LocalDate (0) | 2020.03.16 |
Install
Component
Catalina
Manages the lifecycle of servlets, mapping a URL to a particular servlet and ensuring that the URL requester has the correct access-rights
Coyote
Connector component for Tomcat that supports the HTTP 1.1 protocol as a web server
Listens for incoming connections to the server on a specific TCP port and forwards the request to the Tomcat Engine to process the request and send back a response to the requesting client
Jasper
Application deploy 방법 3가지
JDBC 연동
context.xml <Resource ...>에 설정정보를 추가함
default value | ||
maxActive | 최대 connection 값 | 100 |
maxIdle | 최대 idle connection 허용치 | maxActive |
minIdle | 최소 idle connection 허용치 | initialSize |
initialSize | connection pool 최초 생성 갯수 | 10 |
maxWait | connection얻기위한 최대 대기시간 | 30000(ms) 30sec? |
removeAbandoned | 특정시간동안 사용하지 않는 connection 반환 | false |
removeAbandonedTimeout | ??위의 특정 시간이 아닌지?? | 60sec |
logAbandoned | connection remove될 때 log 기록 여부 | false |
testOnBorrow | getConnection()수행할때 유효성 테스트할지 여부 | false |
validationQuery | 테스트할 쿼리, select 1 | null |
JDBC driver
Virtual host
apache에서 지원하는 기능인데 tomcat에서도 지원함
여러 domain이 하나의 tomcat에서 작동하도록 해줌
설정방법
Tomcat GUI Manager>Host Manager 클릭
<role>에 admin-gui 추가해야함
localhost는 기본적으로 떠있어야 하지만
그외에 host는 내렸다 올렸다 할 수 있음
host 구성
server.xml
<Engine name="Catalina" defaultHost="localhost"> -> 기본적으로 localhost의 내용이 전달됨
Web server 연동
(linux) tar.gz 압축파일 받은 후 다음 과정 거치면 됨
$ tar xvfz tomcat-connectors-1.2.40-src.tar.gz $ cd ~/Downloads/tomcat-connectors-1.2.40-src/native $ ./configure -with-apxs=APACHE_HOME_DIR/bin/apxs (apxs 옵션은 아파치 설치 디렉토리/bin/apxs를 지정) $ make $ make install -> 이렇게 하면 Apache_home_dir/modules/mod_jk.so가 생성됨 |
생성된 mod_jk.so를 아파치에 로딩
httpd.conf에 <IfModule jk_module>...와 설정값들 추가
<IfModule jk_module> JkWorkersFile conf/workers.properties //꼭 workers.properties 파일명이 아니어도 되지만 일반적 이름쓰자! JkLogFile logs/mod_jk.log JkLogLevel info JkMountFile conf/uri.properties |
worker.[worker_name].[type_option]=[정의]
worker.list=loadbalancer worker.worker1.type=ajp13 worker.worker1.host=192.168.0.10 worker.worker1.port=8009 worker.worker1.lbfactor=1
worker.worker2.type=ajp13 worker.worker2.host=192.168.0.11 worker.worker2.port=8010 worker.worker2.lbfactor=1 //로드밸런스의 가중치 work1,2 둘다 1이므로 1:1
worker.loadbalancer.type=lb worker.loadbalancer.balance_workers=worker1, worker2 |
httpd.conf에 직접 추가하거나 uri.properties같은 별도 파일로 분리할 수도
/*.do=worker1 /*.jsp=worker2 /servlet/*=loadbalander |
Thread
Monitoring
Tip
acceptCount=10 | request Queue의 길이를 정의 idle thread가 없으면 queue에서 idle thread가 생길때까지 요청을 대기하는 queue의 길이 default값은 매우 큼, 이걸 작게 잡아두면 기다리지 않고 빨리 에러를 보내게 됨 (요청을 처리할 수 없는 상황이면 빨리 에러 코드를 보내고 싶을 때 |
enableLookups=false | 기본값은 true Servlet/JSP 코드 중에서 들어오는 http request에 대한 ip를 조회하는 명령등이 있을 경우 DNS 이름을 IP주소로 바꾸기 위해서 DNS 서버에 look up 요청을 보냄 false로 하면 서버간의 round trip발생 방지 가능 |
compression=off | HTTP message body를 gzip 현태로 압축해서 리턴하지 않음 과거에는 대역폭이 낮아서 압축해서 많이 보냈지만 요즘은 압축하고 푸는 리소스가 더 많음 |
maxConnection=8192 | 하나의 tomcat 인스턴스가 유지할 수 있는 connection의 수 현재 연결되어 있는 실제 connection의 수가 아니라 현재 사용중인 socket fd(file descriptor)의 수 socket과 file이 열리는 갯수 |
maxKeepAliveRequest=1 | HTTP 1.1 Keep Alive Connection을 사용할 때 최대 유지할 connection수를 결정 Keep Alive를 사용할 환경이 아닌 경우에 1로 두면 됨 톰캣만 사용하거나 다양한 유저가 있을 때에는 1로 하는게 좋음 항상 같은 유저가 들어온다는 보장이 없을 때는 keep alive하지 않고 매번 새로 들어올 수 있게 하는 게 좋음 |
tcpNoDelay=true | TCP 프로토콜은 기본적으로 패킷을 보낼 때 바로 보내지 않음 버퍼사이즈에 데이터가 모두 담길 때까지 패킷 전송을 보류함으로 대기 시간이 발생하는 것을 방지 트래픽이 증가하지만 현재 망 속도를 고려하였을 때 문제가 크지 않음 |
Tomcat's directories (0) | 2021.03.03 |
---|---|
Java Web Application (0) | 2021.03.02 |
spring-boot profile별 실행 (0) | 2020.03.25 |
java time - Instant, LocalDate (0) | 2020.03.16 |
Lombok (0) | 2020.02.14 |
WAS
Jar
Java Web Application (0) | 2021.03.02 |
---|---|
tomcat (0) | 2021.03.02 |
java time - Instant, LocalDate (0) | 2020.03.16 |
Lombok (0) | 2020.02.14 |
Log4j (0) | 2020.02.13 |
@RequestParam(value = "date", required = false) @DateTimeFormat(pattern = "yyyyMMdd") LocalDate date) 동작
@RequestParam(value = "date", required = false) @DateTimeFormat(pattern = "yyyyMMdd") Instant date) 에러
Instant로는 yyyymmdd로 받을 수가 없는 듯
how to check available timezone
Set<String> zoneIdSet = ZoneId.getAvailableZoneIds();
for(String zoneId:zoneIdSet) System.out.println(zoneId);
하루 더하기
[LocalDate] date.plusDays(1)
[Instant] time.plus(1, ChronoUnit.DAYS), time.plus(Duration.ofDays(1))
LocalDate -> Instant 변환
ZoneId timezone = ZoneId.of("UTC");// ZoneId.systemDefault()->KST+9
date.atStartOfDay(timezone).toInstant();
tomcat (0) | 2021.03.02 |
---|---|
spring-boot profile별 실행 (0) | 2020.03.25 |
Lombok (0) | 2020.02.14 |
Log4j (0) | 2020.02.13 |
ChannelGenre enum관련 에러 (patch시 No validator could be found for constraint) (0) | 2020.01.14 |
https://mvnrepository.com/artifact/org.projectlombok/lombok/1.18.12
이클립스 롬복설치 설명 자세함: https://dev114.tistory.com/369
spring-boot profile별 실행 (0) | 2020.03.25 |
---|---|
java time - Instant, LocalDate (0) | 2020.03.16 |
Log4j (0) | 2020.02.13 |
ChannelGenre enum관련 에러 (patch시 No validator could be found for constraint) (0) | 2020.01.14 |
Jwt Token Expire 주기 설정 (0) | 2019.11.27 |