我想从jetty切换到tomcat。我得到NameNotFoundException,因为tomcat找不到jetty-web.xml中的jndiName并在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>
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。
谁能帮帮我?答案 0 :(得分:0)
我将资源添加到tomcat context.xml
并解决了问题。
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"
/>
但我喜欢在自定义路径中使用我的context.xml,如果可能的话