gpt4 book ai didi

java - tomcat 上下文初始化与 oracle 数据库失败

转载 作者:太空宇宙 更新时间:2023-11-04 09:50:09 27 4
gpt4 key购买 nike

我正在 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 管理器应用程序启动该应用程序它对我说无法启动应用程序

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$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

最佳答案

您需要将 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>

关于java - tomcat 上下文初始化与 oracle 数据库失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54866987/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com