[英]javax.naming.NameNotFoundException - jndiName
我想從碼頭轉到tomcat。 我得到NameNotFoundException是因為tomcat在jetty-web.xml中找不到在applicationContext.xml中使用的jndiName。
我的applicationContext.xml的一部分:
<bean id="clarityDataSource" class="org.springframework.jndi.JndiObjectFactoryBean" depends-on="i18nFactoryProvider">
<property name="jndiName" value="java:comp/env/jdbc/clarityDS"/>
</bean>
jetty-web.xml的一部分
<New id="clarityds" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>java:comp/env/jdbc/clarityDS</Arg>
<Arg>
<New class="oracle.jdbc.pool.OracleDataSource">
<Set name="connectionCachingEnabled">true</Set>
<Set name="dataSourceName">clarityDS</Set>
<Set name="URL"><SystemProperty name="clarityDS.url"/></Set>
<Set name="user"><SystemProperty name="clarityDS.username"/></Set>
<Set name="password"><SystemProperty name="clarityDS.password"/></Set>
</New>
</Arg>
</New>
我知道jetty-web.xml會在所有文件之后加載。
有人可以幫助我嗎?
我向tomcat context.xml
添加資源並解決了問題。
使用Maven,Jetty和Tomcat在嵌入式容器中運行Java Web應用程序
<Resource
name="jdbc/clarityDS"
auth="Container"
type="javax.sql.DataSource"
driverClassName="clarity.clarityDS.driverClassName"
username="clarity.clarityDS.username"
password="clarity.clarityDS.password"
url="clarity.clarityDS.url"
/>
但是如果可能的話,我喜歡在自定義路徑中使用我的context.xml
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.