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

2010年4月2日 星期五

jetty 7 with eclipse

1. Download eclipse J2EE version.
2, Download jetty 7.
3. Create a dynamic web project .
3.1 New target machine.
3.2 Download additional server adapters.
3.3 Choose Jetty generic server adapter.
4. Edit plugin.xml of jetty in eclipse plugin directory. Replace mortbay with eclipse.
5. Edit jetty.serverdef in servers in eclipse jetty plugjn directory. Change Start.Main with jetty 7 version (org.eclipse.jetty.start.Main)
6. Edit template.xml in buildfiles in eclipse jetty plugjn directory. Replace mortbay with eclipse.
7. Edit build.xml in buildfiles in eclipse jetty plugjn directory. Replace mortbay with eclipse. Commet all <Set> of org.eclipse.jetty.webapp.WebAppContext.

ps. I test with Jetty 7, non-hightide version.