简体   繁体   中英

javax.naming.NameNotFoundException - jndiName

I want to switch from jetty to tomcat. I get NameNotFoundException because tomcat not found jndiName that is in jetty-web.xml and used in applicationContext.xml.

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

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

anyone can help me?

  • jetty-web.xml deployed in WEB-INF
  • applicationContext.xmk deployed in WEB-INF/classes/spring

I add resource to tomcat context.xml and solved problem.

Run java web apps in embedded containers with Maven, Jetty and Tomcat

       <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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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