Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javax.naming.NameNotFoundException-jndiName_Java_Tomcat_Jetty_Applicationcontext - Fatal编程技术网

javax.naming.NameNotFoundException-jndiName

javax.naming.NameNotFoundException-jndiName,java,tomcat,jetty,applicationcontext,Java,Tomcat,Jetty,Applicationcontext,我想从jetty换成tomcat。我得到了NameNotFoundException,因为tomcat没有在jetty-web.xml中找到jndiName,该jndiName在applicationContext.xml中使用 my applicationContext.xml的一部分: <bean id="clarityDataSource" class="org.springframework.jndi.JndiObjectFactoryBean" depends-on="i

我想从jetty换成tomcat。我得到了NameNotFoundException,因为tomcat没有在jetty-web.xml中找到jndiName,该jndiName在applicationContext.xml中使用

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

java:comp/env/jdbc/clarityDS
真的
克拉提兹
我知道jetty-web.xml会加载所有文件

有人能帮我吗

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

我向tomcat
context.xml添加了资源,并解决了这个问题


但如果可能的话,我喜欢在自定义路径中使用context.xml

       <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"
           />