【问题标题】:Jetty 9: No Spring WebApplicationInitializer types detected on classpathJetty 9:在类路径上未检测到 Spring WebApplicationInitializer 类型
【发布时间】:2014-08-28 22:35:31
【问题描述】:

我正在尝试从 jetty 7.6 切换到 jetty-9.2.1。我进行了所需的配置更改。但是在初始化码头服务器时,我不断收到 "No Spring WebApplicationInitializer types detected on classpath" 消息。

我的部署经理是:

新 class="org.eclipse.jetty.deploy.providers.WebAppProvider">

<Set name="monitoredDirName">
  <Property name="cometd.deploy.dir" default="/u/khandela/cometD/webapps_dev/" />
</Set>
<Set name="defaultsDescriptor">
  <Property name="jetty.home" default="."/>/etc/webdefault.xml
</Set>
<Set name="scanInterval">1</Set>
<Set name="extractWars">true</Set>
<Set name="contextXmlDir">
 <Property name="jetty.home" default="." />/contexts
</Set>

在新版本中删除了“contextXmlDir”。所以我也从配置中删除了。当我运行时,我不断收到上面显示的消息。如果是的话,我应该把它加回来吗?

在运行时我正在使用: --module=server,jsp,deploy,jmx,resources,websocket,ext,plus,annotations

以下是我运行服务器时收到的详细消息:

2014-07-08 14:07:42.634:INFO::main: Logging initialized @512ms
2014-07-08 14:07:43.253:INFO:oejs.Server:main: jetty-9.2.1.v20140609
2014-07-08 14:07:43.306:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:/u/khandela/cometD/logs_dev/webapps] at interval 1
2014-07-08 14:07:43.306:WARN:oejdp.ScanningAppProvider:main: Does not exist: file:/u/khandela/cometD/logs_dev/webapps
2014-07-08 14:07:43.450:INFO:oejs.AbstractNCSARequestLog:main: Opened /u/khandela/cometD/logs_dev/jetty-20140708.log
2014-07-08 14:07:43.468:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:/u/khandela/cometD/webapps_dev/] at interval 1
2014-07-08 14:07:46.945:INFO:cometd:main: No Spring WebApplicationInitializer types detected on classpath
2014-07-08 14:07:47.332:INFO:cometd:main: Initializing Spring root WebApplicationContext
2014-07-08 14:07:48.696:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@6fd02e5{/cometd,file:/tmp/jetty-0.0.0.0-8107-cometd.war-_cometd-any-404202732061519131.dir/webapp/,AVAILABLE}{/u/khandela/cometD/webapps_dev/cometd.war}
2014-07-08 14:07:49.183:INFO:oejs.ServerConnector:main: Started ServerConnector@180bc464{HTTP/1.1}{0.0.0.0:8107}
2014-07-08 14:07:49.184:INFO:oejs.Server:main: Started @7083ms

谢谢,

阿努杰

【问题讨论】:

  • 那条消息是个问题,因为?如果您的应用程序运行忽略它,它只是一条信息消息。
  • 信息消息不是问题,但为什么它说“在类路径上没有检测到 Spring WebApplicationInitializer 类型”,我的问题是我应该在哪里以及如何指定“contextXmlDir”?
  • 因为没有找到它们,因此它会通知您。 Servlet 3.0 有一个 ServletContainerInitializer,spring 有一个 SpringServletContainerInitializer 来寻找 WebApplicationInitializer 实例。没有发现该消息出现。请修改问题以反映您的实际问题,因为目前它具有误导性。
  • 感谢您的解释。但是如果我检查战争,我可以在“./WEB-INF/lib/spring-web-4.0.5.RELEASE.jar”中看到 WebApplicationInitializer。您能否也让我知道“contextXmlDir”,我应该如何在 jetty-9.2 中配置它
  • 那是接口,它没有找到该接口的任何实现。如何配置 contextXmlDIr 不知道,这也不是您最初提出的问题。也许为此创建一个新的。

标签: spring jetty jetty-9


【解决方案1】:

如果您在 jetty.xml 中配置 org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern 属性将起作用。您可以在 Jetty Documentation 上找到有关此参数的更多信息:这是一个上下文属性,可以在 org.eclipse.jetty.webapp.WebAppContext 上设置,以控制容器类路径的哪些部分应被处理以进行注释等操作。

<Call name="setAttribute">
  <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
  <Arg>.*/foo-[^/]*\.jar$|.*/bar-[^/]*\.jar$|.*/bin/.*|.*/classes/.*|.*/target/.</Arg>
</Call>

【讨论】:

    猜你喜欢
    • 2013-04-25
    • 2014-05-21
    • 2016-06-19
    • 2018-11-30
    • 2019-09-06
    • 2017-06-02
    • 1970-01-01
    • 2021-08-31
    相关资源
    最近更新 更多