java.lang.IllegalStateException: 자식 컨테이너를 시작하는 중 오류 발생
org.apache.catalina.startup.HostConfig deployDescriptor 심각: 배치 descriptor [C:\springstudy\apache-tomcat-8.5.73\conf\Catalina\localhost\app.xml]을(를) 배치하는 중 오류 발생 java.lang.IllegalStateException: 자식 컨테이너를 시작하는 중 오류 발생
라이브러리 충돌로 인한 에러
해결방법
1. [Project] - [Clean]
2. Tomcat v8.5 Server at localhost → Modules → 실행되고 있는 것 선택 후 Remove
3. Servers → Tomcat v8.5 Server at localhost 마우스로 우클릭 → Clean
4. 해당 Project 마우스로 우클릭 → [Maven] → Update Project... → 해당 프로젝트 체크 후 OK 버튼 마우스로 클릭
1. 서버 클린 : Servers > Tomcat > Clean & Clean Tomcat Work Directory 2. 프로젝트 클린 : Menu > Project > Clean 3. 메이븐 업데이트 : Project Explorer > 프로젝트 우클릭 > Maven > Update Project
4가지 방법 해봐도 안됨..
3월 21, 2022 4:19:32 오후 org.apache.catalina.startup.HostConfig deployDescriptor 심각: 배치 descriptor [C:\springstudy\apache-tomcat-8.5.73\conf\Catalina\localhost\app.xml]을(를) 배치하는 중 오류 발생 java.lang.IllegalStateException: 자식 컨테이너를 시작하는 중 오류 발생
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:757) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:727) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:673) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1881) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: 구성요소 [org.apache.catalina.webresources.StandardRoot@5b39f964]을(를) 시작하지 못했습니다. at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4880) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5018) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753) ... 9 more
Caused by: java.lang.IllegalArgumentException: 지정된 주요 리소스셋 [C:\springstudy\apache-tomcat-8.5.73\webapps\app]은(는) 유효하지 않습니다. at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:747) at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:705) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ... 13 more
3월 21, 2022 4:40:09 오후 org.apache.catalina.core.StandardContext listenerStop 심각: 클래스 [org.springframework.web.context.ContextLoaderListener]의 인스턴스인 리스너에게 contextDestroyed 이벤트를 전송하는 중 예외 발생 java.lang.IllegalStateException: java.io.FileNotFoundException: C:\springstudy\apache-tomcat-8.5.73\webapps\spring16_mvc16_@ExceptionHandler\WEB-INF\lib\aspectjrt-1.6.10.jar (지정된 경로를 찾을 수 없습니다) at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.getArchiveEntry (AbstractSingleArchiveResourceSet.java:100) at org.apache.catalina.webresources.AbstractArchiveResourceSet.getResource (AbstractArchiveResourceSet.java:257) at org.apache.catalina.webresources.StandardRoot.getResourceInternal(StandardRoot.java:280) at org.apache.catalina.webresources.Cache.getResource(Cache.java:62) at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:215) at org.apache.catalina.webresources.StandardRoot.getClassLoaderResource(StandardRoot.java:224) at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2365) at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:876) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1379) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1223) at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:117) at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4811) at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5467) at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:844) at org.apache.catalina.startup.HostConfig.undeploy(HostConfig.java:1458) at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1383) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1646) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1170) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren (ContainerBase.java:1396) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren (ContainerBase.java:1400) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1368) at java.lang.Thread.run(Thread.java:748) Caused by: java.io.FileNotFoundException: C:\springstudy\apache-tomcat-8.5.73\webapps\spring16_mvc16_@ExceptionHandler\WEB-INF\lib\aspectjrt-1.6.10.jar (지정된 경로를 찾을 수 없습니다) at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.<init>(ZipFile.java:226) at java.util.zip.ZipFile.<init>(ZipFile.java:155) at java.util.jar.JarFile.<init>(JarFile.java:167) at java.util.jar.JarFile.<init>(JarFile.java:131) at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:202) at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:187) at org.apache.catalina.webresources.AbstractArchiveResourceSet.openJarFile (AbstractArchiveResourceSet.java:308) at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.getArchiveEntry (AbstractSingleArchiveResourceSet.java:96) ... 24 more
경고: 호스트 appBase 내의 docBase [C:\springstudy\apache-tomcat-8.5.73\webapps\spring16_mvc13_mybatis]이(가) 지정되었으나, 이는 무시될 것입니다. 3월 21, 2022 5:22:06 오후 org.apache.catalina.core.ContainerBase addChildInternal 심각: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: 구성요소 [org.apache.catalina.webresources.StandardRoot@675b709e]을(를) 시작하지 못했습니다. at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4880) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5018) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:727) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:673) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1881) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.IllegalArgumentException: 지정된 주요 리소스셋 [C:\springstudy\apache-tomcat-8.5.73\webapps\app]은(는) 유효하지 않습니다. at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:747) at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:705) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ... 13 more 3월 21, 2022 5:22:06 오후 org.apache.catalina.startup.HostConfig deployDescriptor 심각: 배치 descriptor [C:\springstudy\apache-tomcat-8.5.73\conf\Catalina\localhost\app.xml]을(를) 배치하는 중 오류 발생 java.lang.IllegalStateException: 자식 컨테이너를 시작하는 중 오류 발생 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:757) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:727) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:673) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1881) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.catalina.LifecycleException: 구성요소 [org.apache.catalina.webresources.StandardRoot@675b709e]을(를) 시작하지 못했습니다. at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4880) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5018) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753) ... 9 more Caused by: java.lang.IllegalArgumentException: 지정된 주요 리소스셋 [C:\springstudy\apache-tomcat-8.5.73\webapps\app]은(는) 유효하지 않습니다. at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:747) at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:705) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ... 13 more
3월 21, 2022 5:22:32 오후 org.apache.catalina.core.StandardContext listenerStart 심각: Context initialized 이벤트를 [org.springframework.web.context.ContextLoaderListener] 클래스의 인스턴스인 리스너에 전송하는 동안 예외 발생 org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/tx] Offending resource: ServletContext resource [/WEB-INF/spring/root-context.xml] at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70) at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:118) at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:110) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:301) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1432) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1419) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:172) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:142) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:94) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:126) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:614) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:514) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4763) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5232) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:727) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1177) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1925) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) 3월 21, 2022 5:22:32 오후 org.apache.catalina.core.StandardContext startInternal 심각: 하나 이상의 리스너들이 시작하지 못했습니다. 상세 내역은 적절한 컨테이너 로그 파일에서 찾을 수 있습니다. 3월 21, 2022 5:22:32 오후 org.apache.catalina.core.StandardContext startInternal 심각: 이전 오류들로 인해 컨텍스트 [/spring16_mvc13_mybatis]의 시작이 실패했습니다. 3월 21, 2022 5:22:32 오후 org.apache.catalina.core.ApplicationContext log 정보: Closing Spring root WebApplicationContext INFO : org.springframework.web.context.support.XmlWebApplicationContext - Closing Root WebApplicationContext: startup date [Mon Mar 21 17:22:26 KST 2022]; root of context hierarchy 3월 21, 2022 5:22:32 오후 org.apache.catalina.core.StandardContext listenerStop 심각: 클래스 [org.springframework.web.context.ContextLoaderListener]의 인스턴스인 리스너에게 contextDestroyed 이벤트를 전송하는 중 예외 발생 java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:164) at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1034) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1009) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:583) at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:116) at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4811) at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5467) at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:187) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:727) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1177) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1925) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
Port 8005 required by Tomcat v8.5 Server at localhost is already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).
간단한 코드 실행해보려 했는데, 바로 에러 발생
해결 방법
1. CMD(명령 프롬프트)창 관리자 권한으로 실행
Windows Key → CMD 검색 → 명령 프롬프트 앱 마우스로 우클릭 → 자세히 → 관리자 권한으로 실행
→ JRE: → Installed JREs... 버튼 클릭하여 설치한 jdk 버전 선택 → Finish 버튼 마우스로 클릭
4. Server 탭→ Tomcat v8.5 Server at localhost [Stopped, Republish] 마우스로 더블 클릭하여 실행
5. [Tomcat v8.5 Server at localhost] → [Server Locations] → Use Tomcat installation (takes control of Tomcat installation) 체크 → Deploy path: → Browse... 버튼 클릭하여 apache-tomcat-8.5.xx\webapps 폴더 선택 후 Ctrl + s로 설정 저장
package com.service;
import java.util.Arrays;
import java.util.List;
//타겟 (target object) ==> 핵심기능
public class DeptService {
public List<String> selectList(){
System.out.println("핵심기능:DeptService.selectList");
return Arrays.asList("AAA","BBB");
}
}
EmpService.java
package com.service;
//타겟 (target object) ==> 핵심기능
public class EmpService {
public void update() {
int num = 10/2;
System.out.println("핵심기능:EmpService.update");
}
}
PersonService.java
package com.service;
//타겟 (target object) ==> 핵심기능
public class PersonService {
public String delete() {
int num = 10/0;
System.out.println("핵심기능:PersonService.insert");
return "Hello";
}
}
UserService.java
package com.service;
//타겟 (target object) ==> 핵심기능
public class UserService {
//pointcut
public String list() {
return "UserService.list";
}
public String insert() {
System.out.println("핵심기능:UserService.insert");
return "UserService.insert";
}
public String insert2() {
return "UserService.insert2";
}
}
package com.service;
import java.util.Arrays;
import java.util.List;
import org.springframework.stereotype.Service;
//타켓(target object) ==> 핵심기능
@Service
public class DeptService {
public List<String> selectList(){
System.out.println("핵심기능:DeptService.selectList");
return Arrays.asList("AAA", "BBB");
}
}
EmpService.java
package com.service;
import org.springframework.stereotype.Service;
//타켓(target object) ==> 핵심기능
@Service
public class EmpService {
public void update() {
int num = 10/2;
System.out.println("핵심기능:EmpService.update");
}
}
PersonService.java
package com.service;
import org.springframework.stereotype.Service;
// 타겟 (target object) ==> 핵심기능
@Service
public class PersonService {
public String delete() {
int num = 10/2;
System.out.println("핵심기능:PersonSerivce.insert");
return "Hello";
}
}
UserService.java
package com.service;
import org.springframework.stereotype.Service;
// 타켓(target object) ==> 핵심기능
@Service
public class UserService {
// pointcut
public String list() {
return "UserService.list";
}
public String insert() {
return "UserService.insert";
}
public String insert2() {
return "UserService.insert2";
}
}
SpEL - Spring Expression Language Spring Expression Language는 보통 SpEL로 표기하며 구두로는 Spring EL이라고 지칭한다. SpEL은 보통 객체를 조회하고 조작하는 기능을 제공하여 Unified EL과 유사하지만 Method 호출, 문자열 템플릿 기능 등의 여러가지 추가 기능을 제공하는 표현식 언어이다. Spring 3.0부터 지원된다.
Spring SpEL
MainClass.java
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import com.dto.Person;
public class MainClass {
public static void main(String[] args) {
ApplicationContext ctx = new GenericXmlApplicationContext("classpath:com/config/user.xml");
Person p2 = ctx.getBean("p2", Person.class);
System.out.println(p2);
}
}
Person.java
package com.dto;
public class Person {
String username;
int age;
boolean isMarried;
double weight;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public boolean isMarried() {
return isMarried;
}
public void setMarried(boolean isMarried) {
this.isMarried = isMarried;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
@Override
public String toString() {
return "Person [username=" + username + ", age=" + age + ", isMarried=" + isMarried + ", weight=" + weight
+ "]";
}
}