jetty 转帖
来源:互联网 发布:php bootstrap 框架 编辑:程序博客网 时间:2024/06/10 03:41
jetty7试用笔记
前几天在tomcat启动时,遇到了“startup failed due to previous errors”的问题,在tomcat中只显示该错误信息,并未指明是哪里引起的错误,找了半天也没有找到问题所在,因此试用了一下jetty7,配置好后启动,终于从其异常信息中找到问题所在:spring配置文件中quartz定时任务的表达式格式写错了,导致异常。
言归正传,记录一下jetty7的试用过程以备后用。
jetty7下载地址:http://dist.codehaus.org/jetty/jetty-hightide-7.0.1/jetty-hightide-7.0.1.v20091125.zip
解压后,配置位于其根目录下的/etc/jetty.xml,因为现在jetty已归于eclipse旗下,因此其jetty7中jetty.xml配置时涉及的一些类的类名也做了改动,部署我的项目时添加如下配置即可:
- <Set name="handler">
- <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
- <Set name="handlers">
- <Array type="org.eclipse.jetty.server.Handler">
- <Item>
- <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
- </Item>
- <Item>
- <New class="org.eclipse.jetty.webapp.WebAppContext">
- <Set name="contextPath">/myapp</Set>
- <Set name="resourceBase">E:/myapp/dist</Set>
- <Call name="addServlet">
- <Arg>org.mortbay.jetty.servlet.DefaultServlet</Arg>
- <Arg>/</Arg>
- </Call>
- </New>
- </Item>
- </Array>
- </Set>
- </New>
- </Set>
关于jetty.xml的详细说明可参考下面的链接:
http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax
http://wiki.eclipse.org/Jetty/Reference/jetty.xml
关于jetty的启动:
1、修改jetty根目录下的start.ini,添加以下内容:
- -Xmx512m
- -Dcom.sun.management.jmxremote
- OPTIONS=Server,jmx,plus,jta,jdbc,annotations,jsp,resources
- etc/jetty-jmx.xml
- etc/jetty.xml
- etc/jetty-ssl.xml
2、将以下文字保存为start.bat并置于jetty根目录下,直接双击start.bat即可启动
@echo off
java -jar start.jar