jetty jndi配置

 

pom.xmljava

<plugin>
		    <groupId>org.mortbay.jetty</groupId>
		    <artifactId>maven-jetty-plugin</artifactId>
		    <version>6.1.26</version>
		    <configuration>
	            <encoding>UTF-8</encoding> 
	    		<webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml> 
	    		<jettyEnvXml>src/main/resources/jetty.xml</jettyEnvXml>
	    		<!-- <scanIntervalSeconds>10</scanIntervalSeconds>   -->
		    </configuration>
		</plugin>

jetty.xmlweb

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.mortbay.jetty.webapp.WebAppContext">
	<New id="dbsource" class="org.mortbay.jetty.plus.naming.Resource">
		<Arg>java:comp/env/bossjdbc</Arg>
		<Arg>
			<New class="org.apache.commons.dbcp.BasicDataSource">
				<Set name="driverClassName">oracle.jdbc.driver.OracleDriver</Set>  
                <Set name="url">jdbc:oracle:thin:@ip:1521:datasourcename</Set>  
                <Set name="username">name</Set>  
                <Set name="password">pwd</Set>  
			</New>
		</Arg>
	</New>
</Configure>

datasource配置spring

<bean id="dataSource"  class="org.springframework.jndi.JndiObjectFactoryBean"  destroy-method="close">
  		<property name="jndiName">
   			<value>java:comp/env/bossjdbc</value>
  		</property> 
   </bean>

 

jetty 6.+中的jetty.xml 名字为bossjdbc,datasrouce的jndiName值为java:comp/env/bossjdbc时会报错apache

javax.naming.NameNotFoundExceptionoracle

索性在jetty.xml 名字写全称为java:comp/env/bossjdbcapp