2010-03-04 45 views
1

我目前正在与jetty hightide vesion 7一起作为独立服务器。我有一个简单的web项目,其中有一些jsp和后备类,目前我正在将一个未爆炸的战争部署到JETTY_HOME/webapps目录。在码头热部署简单应用

目前,jetty很容易获得任何静态jsp/html更改。如果我理解正确,我可以配置我的应用程序,以便码头在不重新启动服务器的情况下接收任何类更改?目前,我有我的码头-web.xml中:

<?xml version="1.0" encoding="ISO-8859-1"?> 
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> 

<!-- 
    This is the jetty specific web application configuration file. When 
    starting a Web Application, the WEB-INF/web-jetty.xml file is looked 
    for and if found, treated as a 
    org.eclipse.jetty.server.server.xml.XmlConfiguration file and is 
    applied to the org.eclipse.jetty.servlet.WebApplicationContext objet 
--> 

<Configure class="org.eclipse.jetty.webapp.WebAppContext"> 
<Call class="org.eclipse.jetty.util.log.Log" name="debug"> 
    <Arg>executing jetty-web.xml</Arg> 
</Call> 
<Set name="contextPath">/SimpleDynamicProject</Set> 

</Configure> 

我还创建了一个SimpleDynamicProject.xml并把它放在JETTY_HOME /上下文。此文件包含:

<?xml version="1.0" encoding="ISO-8859-1"?> 
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> 

<!-- 
    This is the jetty specific web application configuration file. When 
    starting a Web Application, the WEB-INF/web-jetty.xml file is looked 
    for and if found, treated as a 
    org.eclipse.jetty.server.server.xml.XmlConfiguration file and is 
    applied to the org.eclipse.jetty.servlet.WebApplicationContext objet 
--> 

<Configure class="org.eclipse.jetty.webapp.WebAppContext"> 

<Set name="contextPath">/SimpleDynamicProject</Set> 
<Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/webapps/SimpleDynamicProject</Set> 
</Configure> 

我也不知道如何正确启动Jetty在我阅读的调试模式也是需要的。我曾尝试与启动服务器:

java -Xdebug -jar start.jar OPTIONS=Server,jsp 

java -Ddebug -jar start.jar OPTIONS=Server,jsp 

这是我第一次使用的码头,但到目前为止,我真的很喜欢它。

感谢您的帮助。

回答

0

如果你想使用码头Maven插件

<plugin> 
     <groupId>org.mortbay.jetty</groupId> 
     <artifactId>maven-jetty-plugin</artifactId> 
     <version>6.1.25</version> 
     <configuration> 
      <scanIntervalSeconds>10</scanIntervalSeconds> 
      <requestLog implementation="org.mortbay.jetty.NCSARequestLog"> 
       <!-- 
          This doesn't do anything for Jetty, but is a workaround for a 
          Maven bug that prevents the requestLog from being set. 
         --> 
       <append>true</append> 
      </requestLog> 
      <webApp>${basedir}/out/war/Spring2_5_6_war.war</webApp> 
     </configuration> 
    </plugin> 
+0

这实际上正是我们现在正在我们的团队中所做的。这几乎是所有需要的配置。另外,我们正在使用tapestry5,这种maven/jetty的组合非常适合。 – Casey 2010-09-07 13:54:33

5

您需要定义一个ContextDeployer具有非零扫描间隔:

<Call name="addLifeCycle"> 
    <Arg> 
    <New class="org.mortbay.jetty.deployer.ContextDeployer"> 
     <Set name="contexts"><Ref id="Contexts"/></Set> 
     <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contexts</Set> 
     <Set name="scanInterval">1</Set> 
    </New> 
    </Arg> 
</Call> 

关于调试,我猜你心目中什么是连接使用JPDA远程调试器。对于这一点,你需要设置-agentlib:jdwp选项:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 

配置您的IDE调试器到指定的端口上连接。

如果目标VM是5.0或更新的,-agentlib:jdwp是在其仍然虽然支持-Xdebug-Xrunjdwp选项是优选的。

+0

哦,所以我需要将它添加到我的项目的jetty.xml文件?例如,我试图将其配置在myapp.xml下的jetty服务器的上下文目录中。感谢您的调试信息! – Casey 2010-03-08 13:40:30

+0

@Casey是的,我认为是这样的(实际上,我总是使用Maven的Jetty,所以我更习惯于配置maven插件,但这里的逻辑也适用)。顺便说一句,承认一个好答案的常见方式是upvoting它;-) – 2010-03-08 14:12:53