2010年4月6日 星期二

jetty 7 with mysql and log4j

MySQL
1. Download mysql jdbc jar file into jetty-home/lib/jndi
2. Configure webapp's context xml in jetty-home/contexts
2.1 Add configuration like bellow
<New id="test1" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/test1</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
<Set name="Url">jdbc:mysql://localhost:3306/test1</Set>
<Set name="User">test1</Set>
<Set name="Password">test1</Set>
</New>
</Arg>
</New>
3. Configure web.xml of the webapp
3.1 Add configuration like bellow
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/test1</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

4. Use "java -jar start.jar OPTIONS=Server,jndi" to start jetty. Jetty will load all jar files in jetty-home/lib/jndi

Log4J
1. Download log4j jar file into jetty-home/lib/ext
2. Use "java-jar start.jar OPTIONS=Server,ext" to start jetty. Jetty will load all jar files in jetty-home/lib/ext

沒有留言: