簡體   English   中英

javax.naming.NameNotFoundException-jndiName

[英]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會在所有文件之后加載。

有人可以幫助我嗎?

  • 部署在WEB-INF中的jetty-web.xml
  • 在WEB-INF / classes / spring中部署的applicationContext.xmk

我向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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM