我正在Linux环境中部署应用程序,必须成功安装tomcat和Oracle数据库,之后生成表并获得一个在Windows环境下可以正常工作的.war文件(模块)
我将其部署在/ 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 Manager应用程序启动该应用程序 它对我说无法启动应用程序
失败-上下文/休息室路径的应用程序无法启动
它向我显示我的应用程序记录了此错误
日志
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$1.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
答案 0 :(得分:0)
您需要将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>
答案 1 :(得分:0)
在将JNDI添加到context.xml之后 另外,我们需要将OracleJDBC.jar添加到此文件/ tomcat / lib