tomcat Oracle 数据库的上下文初始化失败

tomcat Context initialization failed with oracle database

我正在 Linux 环境中部署应用程序,我必须成功安装 tomcat 和 Oracle 数据库,然后生成我的表并得到一个 .war在 Windows 环境

中运行良好的文件(模块)

我部署在/tomcat/webapps下 并且我正确配置了我的服务器 xml

    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />

    <Resource   auth="Container" 
         driverClassName="oracle.jdbc.driver.OracleDriver"
  factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" 
  global="jdbc/vimsDs"    
  initialSize="10" maxActive="100" maxWait="10000" minIdle="10" 
  username="****"
  name="jdbc/vimsDs"    
  password="*****" 
  removeAbandoned="true" removeAbandonedTimeout="36000" 
  type="javax.sql.DataSource" 
  url="jdbc:oracle:thin:@localhost:1521:XE"/>

之后我从 tomcat 管理器应用程序启动应用程序 它对我说无法启动应用程序

FAILED - The application for the context /lounge path could not be started

它向我显示我的应用记录了这个错误

日志

2019-02-25 15:04:47.120 [http-bio-8080-exec-32] ERROR o.s.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applicationConfig': Initialization of bean failed; nested exception is 

.....

at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
 at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
 at Caused by: javax.naming.NameNotFoundException: Le Nom jdbc/vimsDs n'est pas lié à ce Contexte
at org.apache.naming.NamingContext.lookup(NamingContext.java:825) ~[catalina.jar:7.0.92]
at org.apache.naming.NamingContext.lookup(NamingContext.java:173) ~[catalina.jar:7.0.92]
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:156) ~[catalina.jar:7.0.92]
at javax.naming.InitialContext.lookup(InitialContext.java:417) ~[na:1.8.0_201]
at org.springframework.jndi.JndiTemplate.doInContext(JndiTemplate.java:155) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup.getDataSource(JndiDataSourceLookup.java:45) ~[spring-jdbc-4.3.6.RELEASE.jar:4.3.6.RELEASE]
... 143 common frames omitted

您需要将 JNDI 名称添加到 WAR 文件中的 context.xml

文件:/META-INF/context.xml

内容:

<?xml version="1.0" encoding="utf-8" ?>
<Context>
    <ResourceLink name="jdbc/vimsDs"
              global="jdbc/vimsDs"
              type="javax.sql.DataSource" />
</Context>

将 JNDI 添加到 context.xml 之后 我们还需要将 OracleJDBC.jar 添加到此文件 /tomcat/lib