Dev's/Web

[Dev's]톰캣7 war 배포 시, Unsupported major.minor version 52.0 에러

rookas89 2020. 12. 23. 14:11
728x90

드디어 완성한 사이드 프로젝트를 war로 변환해서

시놀로지의 톰캣7에 올렸더니 에러가 왕창 발생한다.

 

ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.apache.commons.dbcp2.BasicDataSource] for bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/spring/root-context.xml]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: org/apache/commons/dbcp2/BasicDataSource : Unsupported major.minor version 52.0 (unable to load class org.apache.commons.dbcp2.BasicDataSource)
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1265)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1331)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:897)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:566)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5528)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.UnsupportedClassVersionError: org/apache/commons/dbcp2/BasicDataSource : Unsupported major.minor version 52.0 (unable to load class org.apache.commons.dbcp2.BasicDataSource)
        at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2961)
        at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1210)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1690)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
        at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:417)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1283)
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1254)
        ... 18 more

 

처음엔 jdk 문제인가? 싶어서 빌드 버전을 이리저리 바꿔봤으니 소용이 없었고

에러메시지를 잘 읽어보니, org/apache/commons/dbcp2/BasicDataSource 이게 눈에 들어온다.

 

dbcp2가 있으면 웬지 1도 있을거 같았는데... 웬걸... 맞네??;;

 

	<!-- common-dbcp -->
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-dbcp2</artifactId>
			<version>2.7.0</version>
		</dependency>

pom.xml 에 저렇게 되어있던놈을

 

	<!-- common-dbcp -->
		<dependency>
	        <groupId>commons-dbcp</groupId>
	        <artifactId>commons-dbcp</artifactId>
	        <version>1.3</version>
		</dependency>

 

이렇게 바꿔보니, 정상적으로 동작하는걸 확인했다.

쩝... 나처럼 부득이하게 톰캣7을 꼭 써야하고, jdk버전이 낮은 환경에서 개발해야 하는 경우가 있다면

이 자료가 도움이 될 수 있을 것이다.

728x90