Jetty注释超时原因

时间:2014-08-10 14:44:59

标签: maven spring-mvc annotations jetty maven-jetty-plugin

我想用maven jetty插件运行我的web应用程序。但是在启动一段时间后,它会出错:

[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
2014-08-10 17:39:45.840:INFO:oejs.Server:main: jetty-9.2.2.v20140723
2014-08-10 17:40:54.961:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.m.p.JettyWebAppContext@1e2c8{/asd,file:/C:/dev/project/hope/target/asd-1.0/,STARTING}{C:\dev\project\hope\target\asd-1.0.war}
java.lang.Exception: Timeout scanning annotations
    at org.eclipse.jetty.annotations.AnnotationConfiguration.scanForAnnotations(AnnotationConfiguration.java:570)
    at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:440)
    at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:471)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1329)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:497)
    at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:365)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)

我正在使用带有注释的spring mvc,我认为它存在问题。

当我尝试在eclipse jetty插件上运行它时,它会成功启动,但是使用maven插件时会出错。

有什么想法吗?

6 个答案:

答案 0 :(得分:39)

我有同样的错误并修复它,你应该在你的启动脚本(start.ini)中添加以下内容:

-Dorg.eclipse.jetty.annotations.maxWait=120

120是两分钟的注释扫描,如果您需要更高的值,只需将其设置为第一个。

答案 1 :(得分:5)

另一个(在我看来)方便的方法是使用像这样的jetty.xml设置这个属性:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure>
    <Call name="setProperty" class="java.lang.System">
        <Arg>org.eclipse.jetty.annotations.maxWait</Arg>
        <Arg>120</Arg>
    </Call>
</Configure>

这样你可以省略命令行args

答案 2 :(得分:4)

扫描所有相关的罐子是没用的,你可以使扫描模式更具限制性,只匹配某些罐子:

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.2.8.v20150217</version>
  <configuration>
    <webAppConfig>
      <contextPath>/</contextPath>
      <webInfIncludeJarPattern>.*/foo-[^/]*\.jar$|.*/classes/.*</webInfIncludeJarPattern>
    </webAppConfig>
  </configuration>
</plugin>

有关详细信息,请参阅webInfIncludeJarPattern doc: http://www.eclipse.org/jetty/documentation/9.4.x/jetty-maven-plugin.html#configuring-your-webapp

答案 3 :(得分:1)

答案 4 :(得分:0)

此消息表示扫描注释花费的时间超过其配置的超时时间,因此可以通过增加超时时间(Dorg.eclipse.jetty.annotations.maxWait = 120)或删除tmp / webapp-tmp来解决此问题目标,从而减少了扫描时间。

答案 5 :(得分:-2)

可以将属性(-Dorg.eclipse.jetty.annotations.maxWait = 120)添加到start.ini,以便它适用于您的应用程序库中的所有Web应用程序。

相关问题