geonwoo
20
2019-02-28 22:59:45 작성 2019-02-28 23:04:34 수정됨
3
1757

eclipse gradle project tomcat 8.5 server ( run on server 시 발생하는 오류) 어떻게 해결해야 할까요?


eclipse 에서 tomcat 8.5 server를 사용하고  build tool은 gradle을 사용하고 있습니다.

소스트리에서 가져온 project 인데 라이브러리 추가하고 톰켓 추가해서 프로젝트에는 에러 없는 것을 확인했고

clean 이나 eclipse를 껐다가 켜보는 등... 여러가지 방법을 해봐도 서버가 실행이 안됩니다....

우선 소스 코드를 콘솔에 찍히는 것을 보여드리겠습니다. 

2월 28, 2019 10:22:52 오후 org.apache.tomcat.util.digester.SetPropertiesRule begin
경고: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:backupProject' did not find a matching property.
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: Server version:        Apache Tomcat/8.5.31
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: Server built:          Apr 27 2018 20:24:25 UTC
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: Server number:         8.5.31.0
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: OS Name:               Windows 10
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: OS Version:            10.0
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: Architecture:          amd64
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: Java Home:             C:\Program Files\Java\jre1.8.0_181
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: JVM Version:           1.8.0_181-b13
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: JVM Vendor:            Oracle Corporation
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: CATALINA_BASE:         F:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: CATALINA_HOME:         F:\tomcat\apache-tomcat-8.5.37
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: Command line argument: -Dcatalina.base=F:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: Command line argument: -Dcatalina.home=F:\tomcat\apache-tomcat-8.5.37
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: Command line argument: -Dwtp.deploy=F:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: Command line argument: -Djava.endorsed.dirs=F:\tomcat\apache-tomcat-8.5.37\endorsed
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.VersionLoggerListener log
정보: Command line argument: -Dfile.encoding=MS949
2월 28, 2019 10:22:52 오후 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
정보: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_181\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_181/bin/server;C:/Program Files/Java/jre1.8.0_181/bin;C:/Program Files/Java/jre1.8.0_181/lib/amd64;C:\oraclexe\app\oracle\product\11.2.0\server\bin;;D:\app\건우\product\11.2.0\dbhome_1\bin;D:\app\건우\product\11.2.0\dbhome_2\bin;D:\app\건우\product\11.2.0\dbhome_3\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Brackets\command;C:\Program Files\Java\jdk1.8.0_144\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\ePapyrus\PapyrusNtas;C:\Program Files (x86)\ePapyrus\PapyrusNtas\Addins;"C:\Program Files\Java\jdk1.8.0_144\bin;C:\Users\건우\AppData\Local\Microsoft\WindowsApps";C:\Users\건우\AppData\Roaming\npm;C:\Users\건우\AppData\Local\atom\bin;C:\Users\건우\Desktop\건우;;.]
2월 28, 2019 10:22:52 오후 org.apache.coyote.AbstractProtocol init
정보: Initializing ProtocolHandler ["http-nio-8050"]
2월 28, 2019 10:22:52 오후 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
정보: Using a shared selector for servlet write/read
2월 28, 2019 10:22:52 오후 org.apache.coyote.AbstractProtocol init
정보: Initializing ProtocolHandler ["ajp-nio-8009"]
2월 28, 2019 10:22:52 오후 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
정보: Using a shared selector for servlet write/read
2월 28, 2019 10:22:52 오후 org.apache.catalina.startup.Catalina load
정보: Initialization processed in 799 ms
2월 28, 2019 10:22:52 오후 org.apache.catalina.core.StandardService startInternal
정보: Starting service [Catalina]
2월 28, 2019 10:22:52 오후 org.apache.catalina.core.StandardEngine startInternal
정보: Starting Servlet Engine: Apache Tomcat/8.5.31
2월 28, 2019 10:23:00 오후 org.apache.jasper.servlet.TldScanner scanJars
정보: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2월 28, 2019 10:23:00 오후 org.apache.catalina.core.ApplicationContext log
정보: No Spring WebApplicationInitializer types detected on classpath
2월 28, 2019 10:23:07 오후 org.apache.jasper.servlet.TldScanner scanJars
정보: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2월 28, 2019 10:23:07 오후 org.apache.catalina.core.ApplicationContext log
정보: No Spring WebApplicationInitializer types detected on classpath
2월 28, 2019 10:23:07 오후 org.apache.catalina.core.ApplicationContext log
정보: Initializing Spring root WebApplicationContext
2월 28, 2019 10:23:07 오후 org.springframework.web.context.ContextLoader initWebApplicationContext
정보: Root WebApplicationContext: initialization started
2월 28, 2019 10:23:07 오후 org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
정보: Refreshing Root WebApplicationContext: startup date [Thu Feb 28 22:23:07 KST 2019]; root of context hierarchy
2월 28, 2019 10:23:08 오후 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
정보: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/root-context.xml]
2월 28, 2019 10:23:08 오후 org.springframework.web.context.support.XmlWebApplicationContext refresh
경고: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbDataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [db] is not bound in this Context. Unable to find [db].
2월 28, 2019 10:23:08 오후 org.springframework.web.context.ContextLoader initWebApplicationContext
심각: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbDataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [db] is not bound in this Context. Unable to find [db].
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4792)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: javax.naming.NameNotFoundException: Name [db] is not bound in this Context. Unable to find [db].
	at org.apache.naming.NamingContext.lookup(NamingContext.java:816)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:173)
	at org.apache.naming.SelectorContext.lookup(SelectorContext.java:163)
	at javax.naming.InitialContext.lookup(Unknown Source)
	at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
	at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
	at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
	at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
	at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
	at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:106)
	at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:231)
	at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:217)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
	... 21 more

2월 28, 2019 10:23:08 오후 org.apache.catalina.core.StandardContext listenerStart
심각: Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbDataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [db] is not bound in this Context. Unable to find [db].
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4792)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: javax.naming.NameNotFoundException: Name [db] is not bound in this Context. Unable to find [db].
	at org.apache.naming.NamingContext.lookup(NamingContext.java:816)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:173)
	at org.apache.naming.SelectorContext.lookup(SelectorContext.java:163)
	at javax.naming.InitialContext.lookup(Unknown Source)
	at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
	at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
	at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
	at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
	at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
	at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:106)
	at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:231)
	at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:217)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
	... 21 more

2월 28, 2019 10:23:08 오후 org.apache.catalina.core.StandardContext startInternal
심각: One or more listeners failed to start. Full details will be found in the appropriate container log file
2월 28, 2019 10:23:08 오후 org.apache.catalina.core.StandardContext startInternal
심각: Context [/backupProject] startup failed due to previous errors
2월 28, 2019 10:23:08 오후 org.apache.catalina.core.ApplicationContext log
정보: Closing Spring root WebApplicationContext
2월 28, 2019 10:23:08 오후 org.apache.coyote.AbstractProtocol start
정보: Starting ProtocolHandler ["http-nio-8050"]
2월 28, 2019 10:23:08 오후 org.apache.coyote.AbstractProtocol start
정보: Starting ProtocolHandler ["ajp-nio-8009"]
2월 28, 2019 10:23:08 오후 org.apache.catalina.startup.Catalina start
정보: Server startup in 15689 ms

오류를 보면 /WEB-INF/spring/root-context.xml에 문제가 있나 싶어서 root-context.xml 코드들도 올려보면


<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:jee="http://www.springframework.org/schema/jee"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
  
<jee:jndi-lookup id="dbDataSource"
   jndi-name="db"
   expected-type="javax.sql.DataSource" />
  
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
        p:dataSource-ref="dbDataSource"
        p:mapperLocations="classpath:mybatis/mapper/*_Map.xml"
        p:configLocation="classpath:mybatis/mybatis-config.xml"
        />
    <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
    	<constructor-arg index="0" ref="sqlSessionFactory" />
    </bean>
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
        p:dataSource-ref="dbDataSource" />
  
</beans>


요런식으로 구성되어있습니다. 그리고 마지막으로 server.xml 파일입니다.

db정보가 있는 Resources는 제외하고 보여드리겠습니다.


<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
  <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>


  <Service name="Catalina">

    <Connector connectionTimeout="20000" port="8050" protocol="HTTP/1.1" redirectPort="8443"/>
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
    <Engine defaultHost="localhost" name="Catalina">

      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log" suffix=".txt"/>
       
      
      <Context docBase="backupProject" path="/backupProject" reloadable="true" source="org.eclipse.jst.jee.server:backupProject"/>
      </Host>
    </Engine>
  </Service>
</Server>



어떤 문제가 있는걸까요? 도와주세요 !! ㅜㅜ 오류코드 길어서 보기힘드실까바 이미지로 간단하게 올려드립니다. 



0
0
  • 답변 3

  • abilists.com
    1k
    2019-03-01 08:22:45

    Eclipse내에서 Jetty를 추천합니다.

    0
  • antop
    917
    2019-03-01 10:51:11

    1. 

    대충 구글링 해보니까... <Context> 에서 <ResourceLink> 추가해주게 되어 있긴한데...

    https://heowc.tistory.com/27


    2.

    톰켓에서 리소스 설정하고 스프링에서 찾을 때 리소스명이 맞는지 확인해보세요

    톰켓에서 "db" 로 했다고 스프링에서 "db"가 아닐 수도 있습니다. "j2ee:resource:db"(예를 든거임) 처럼 규칙이 있을 수도 겁니다.


    3. 스프링에서 <jee:jndi-lookup> 에서 resource-ref 옵션을 한번 적용해 보는게....


    4. 전례...?

    https://okky.kr/article/243518


    0
  • geonwoo
    20
    2019-03-14 18:55:46

    감사합니다 해결되었어요!

    0
  • 로그인을 하시면 답변을 등록할 수 있습니다.