简体   繁体   English

javax.naming.NameNotFoundException-jndiName

[英]javax.naming.NameNotFoundException - jndiName

I want to switch from jetty to tomcat. 我想从码头转到tomcat。 I get NameNotFoundException because tomcat not found jndiName that is in jetty-web.xml and used in applicationContext.xml. 我得到NameNotFoundException是因为tomcat在jetty-web.xml中找不到在applicationContext.xml中使用的jndiName。

part of my applicationContext.xml: 我的applicationContext.xml的一部分:

    <bean id="clarityDataSource" class="org.springframework.jndi.JndiObjectFactoryBean" depends-on="i18nFactoryProvider">
    <property name="jndiName" value="java:comp/env/jdbc/clarityDS"/>
    </bean>

part of jetty-web.xml 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>

I know that jetty-web.xml load after all files. 我知道jetty-web.xml会在所有文件之后加载。

anyone can help me? 有人可以帮助我吗?

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

I add resource to tomcat context.xml and solved problem. 我向tomcat context.xml添加资源并解决了问题。

Run java web apps in embedded containers with Maven, Jetty and Tomcat 使用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"
           />

But i like to use my context.xml in custom path, if it's possible 但是如果可能的话,我喜欢在自定义路径中使用我的context.xml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM