【问题标题】:Jetty Maven Plugin is ignoring custom webdefault.xmlJetty Maven 插件忽略自定义 webdefault.xml
【发布时间】:2011-06-26 15:48:25
【问题描述】:

我正在尝试通过在 webdefault.xml 中将 useFileMappedBuffer 设置为 false 的技术来绕过 common issue of Jetty locking static files on Windows。不幸的是,每次 Jetty 都没有获取我自定义的 webdefault.xml。

我正在使用 Apache Maven 3.0.2。我试过使用maven-jetty-plugin (v6.1.26)jetty-maven-plugin (v8.0.0.M2) 但没有区别。在运行 Jetty 之前,我也尝试过运行 clean 和重建。

我每次都验证了我的 webdefault.xml 是从与插件相同的版本中获取的并且具有正确的设置,即仅将此设置从 true 更改为 false:

...
<init-param>
  <param-name>useFileMappedBuffer</param-name>
  <param-value>false</param-value>
</init-param>
...

这是我的 pom.xml Jetty 插件部分的样子:

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <configuration>
        <contextPath>/</contextPath>
        <webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml>
    </configuration>
</plugin>

我也尝试过更改文件的路径:

<webDefaultXml>${basedir}/src/main/resources/webdefault.xml</webDefaultXml>

Everywhere I've seen this exact solution 听起来它对其他人有用(尽管我找到了one instance where someone had my issue)。码头的启动在输出中有这个:

> mvn jetty:run
...
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
...

这进一步让我觉得它没有被应用。输出中的所有其他路径都是正确的。

我在 Jetty 运行时看到的最直接的问题是,每当我使用 IntelliJ IDEA 10 编辑静态文件(JavaScript、CSS 等)时,我都会收到以下错误消息:

Cannot save file:
D:\...\... (The requested operation cannot be performed on a file with a user-mapped section open)

在我停止 Jetty 之后,它保存得很好。每次都会发生这种情况。

有什么想法我可能做错了吗?提前致谢。

【问题讨论】:

  • @JohnS 感谢您的帮助。我能够找到另一个文档,该文档显示插件 v8 的配置已更改。
  • 哦,很高兴你找到了答案!有一天我也会需要它。 :)
  • 我仍然对我在 v6 上做错了什么感到困惑,但至少现在我没有被阻止 :) 不得不杀死 Jetty 只是为了保存是很痛苦的。

标签: windows jetty maven-plugin maven-3 maven-jetty-plugin


【解决方案1】:

我为较新的 Jetty 插件 jetty-maven-plugin (v8.0.0.M2) 找到了一个完全不同的文档,看起来配置名称已更改:

http://wiki.eclipse.org/Jetty/Reference/webdefault.xml#Using_the_Jetty_Maven_Plugin

<project>
    ...
    <plugins>
        <plugin>
            ...
            <artifactId>jetty-maven-plugin</artifactId>
            <configuration>
                <webAppConfig>
                  ...
                  <defaultsDescriptor>/my/path/to/webdefault.xml</defaultsDescriptor>
                </webAppConfig>
            </configuration>
        </plugin>
        ...
    </plugins>
    ...
</project>

这现在似乎适用于较新的插件。我仍然不确定为什么 v6 插件没有选择自定义配置。

【讨论】:

  • 同意,这帮助很大。这个问题巩固了我与 Jetty 的爱恨情仇。 :)
  • 这也适用于我使用 Jetty 插件版本 6.1.26。令人失望的是,他们的文档如此 unclear/plain wrong 关于如何做到这一点。
  • @zhaoyou 在 Jetty 9 中,配置键已从“webAppConfig”更改为“webApp”。目前文档中有错误,但我打开了一个拉取请求:github.com/jetty-project/jetty-documentation/pull/73
【解决方案2】:

我发现与 maven-jetty-plugin 6.1.24 一起使用的唯一解决方案是: http://false.ekta.is/2010/12/jettyrun-maven-plugin-file-locking-on-windows-a-better-way/

【讨论】:

    【解决方案3】:

    Jetty 文档概述了三种方法(从 Jetty 9 开始):

    https://www.eclipse.org/jetty/documentation/current/troubleshooting-locked-files-on-windows.html

    我在Maven中成功使用了init-param方法:

            <!-- Running an embedded server for testing/development -->
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.4.9.v20180320</version>
    
                <configuration>
                    <webApp>
                        <_initParams>
                            <org.eclipse.jetty.servlet.Default.useFileMappedBuffer>false</org.eclipse.jetty.servlet.Default.useFileMappedBuffer>
                        </_initParams>
                    </webApp>
                </configuration>
    
            </plugin>
    

    【讨论】:

      猜你喜欢
      • 2013-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-19
      • 1970-01-01
      • 2013-07-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多