Hot deployment failure with Maven jetty plugin on Windows

huangapple go评论124阅读模式
英文:

Hot deployment failure with Maven jetty plugin on Windows

问题

我已经配置了Jetty Maven插件来运行我的编译后的war文件。

这是我的pom.xml文件中相关的部分:

<plugin>
	<groupId>org.eclipse.jetty</groupId>
	<artifactId>jetty-maven-plugin</artifactId>
	<version>9.4.50.v20221201</version>
	<configuration>
	  <war>${jway.webapps.dir}/myapp.war</war>
	  <scanIntervalSeconds>2</scanIntervalSeconds>
	</configuration>
</plugin>

如果我执行mvn jetty:run-war,我的war文件会被构建,然后Jetty会按预期提供应用程序。

我已经配置了scanIntervalSeconds以允许热部署。然而,如果我使用mvn install重新构建,重新部署时出现以下错误:

java.lang.IllegalStateException: Failed to delete temp dir F:\...\myproject\target\tmp
    at org.eclipse.jetty.webapp.WebInfConfiguration.configureTempDirectory (WebInfConfiguration.java:532)
    at org.eclipse.jetty.webapp.WebInfConfiguration.resolveTempDirectory (WebInfConfiguration.java:424)
    at org.eclipse.jetty.webapp.WebInfConfiguration.preConfigure (WebInfConfiguration.java:140)
    at org.eclipse.jetty.webapp.WebAppContext.preConfigure (WebAppContext.java:488)
    at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:523)
    at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart (JettyWebAppContext.java:397)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:73)
    at org.eclipse.jetty.maven.plugin.JettyRunWarMojo.restartWebApp (JettyRunWarMojo.java:113)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo$1.filesChanged (AbstractJettyMojo.java:472)
    at org.eclipse.jetty.util.Scanner.reportBulkChanges (Scanner.java:848)
    at org.eclipse.jetty.util.Scanner.reportDifferences (Scanner.java:765)
    at org.eclipse.jetty.util.Scanner.scan (Scanner.java:641)
    at org.eclipse.jetty.util.Scanner$1.run (Scanner.java:558)
    at java.util.TimerThread.mainLoop (Timer.java:555)
    at java.util.TimerThread.run (Timer.java:505)

似乎Jetty想要删除文件,但Windows锁定了文件。在插件文档中,我没有找到任何看起来有帮助的配置。此外,我在Google上也没有找到任何信息。是否有办法解决这个问题?

我不知道是否相关,但我没有使用jetty:run目标,因为我的war文件是使用第三方工具构建的,而且我没有标准的目录结构。

英文:

I have configured the Jetty Maven plugin to run my compiled war.

Here is the relevant part of my pom.xml.

&lt;plugin&gt;
	&lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
	&lt;artifactId&gt;jetty-maven-plugin&lt;/artifactId&gt;
	&lt;version&gt;9.4.50.v20221201&lt;/version&gt;
	&lt;configuration&gt;
	  &lt;war&gt;${jway.webapps.dir}/myapp.war&lt;/war&gt;
	  &lt;scanIntervalSeconds&gt;2&lt;/scanIntervalSeconds&gt;
	&lt;/configuration&gt;
&lt;/plugin&gt;

If I execute mvn jetty:run-war, my war is build and Jetty serves the app as expected.

I have configured scanIntervalSeconds to allow hot redeploy.
However, if I rebuild using mvn install, I get the following error during redeployment:

java.lang.IllegalStateException: Failed to delete temp dir F:\...\myproject\target\tmp
    at org.eclipse.jetty.webapp.WebInfConfiguration.configureTempDirectory (WebInfConfiguration.java:532)
    at org.eclipse.jetty.webapp.WebInfConfiguration.resolveTempDirectory (WebInfConfiguration.java:424)
    at org.eclipse.jetty.webapp.WebInfConfiguration.preConfigure (WebInfConfiguration.java:140)
    at org.eclipse.jetty.webapp.WebAppContext.preConfigure (WebAppContext.java:488)
    at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:523)
    at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart (JettyWebAppContext.java:397)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:73)
    at org.eclipse.jetty.maven.plugin.JettyRunWarMojo.restartWebApp (JettyRunWarMojo.java:113)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo$1.filesChanged (AbstractJettyMojo.java:472)
    at org.eclipse.jetty.util.Scanner.reportBulkChanges (Scanner.java:848)
    at org.eclipse.jetty.util.Scanner.reportDifferences (Scanner.java:765)
    at org.eclipse.jetty.util.Scanner.scan (Scanner.java:641)
    at org.eclipse.jetty.util.Scanner$1.run (Scanner.java:558)
    at java.util.TimerThread.mainLoop (Timer.java:555)
    at java.util.TimerThread.run (Timer.java:505)

It seems that Jetty wants to delete the file, but Windows locks the file. In the plugin documentation, I have not found any configuration which seems to be helpful. Furthermore I have nothing found on Google. Is there any way to solve this issue?

I don't know if its relevant, but I do not use the jetty:run goal, because my war is build using a third party tool and I do not have a standard directory structure.

答案1

得分: 0

以下是已翻译的内容:

The jetty documentation contains a section about Troubleshooting Locked Files on Windows.

So I updated my plugin config according to the documentation:

&lt;plugin&gt;
  &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
  &lt;artifactId&gt;jetty-maven-plugin&lt;/artifactId&gt;
  &lt;version&gt;9.4.50.v20221201&lt;/version&gt;
  &lt;configuration&gt;
    &lt;war&gt;${jway.webapps.dir}/myapp.war&lt;/war&gt;
    &lt;scanIntervalSeconds&gt;2&lt;/scanIntervalSeconds&gt;
    &lt;webApp&gt;
  	&lt;_initParams&gt;
        &lt;org.eclipse.jetty.servlet.Default.useFileMappedBuffer&gt;false&lt;/org.eclipse.jetty.servlet.Default.useFileMappedBuffer&gt;
  	&lt;/_initParams&gt;
    &lt;/webApp&gt;
  &lt;/configuration&gt;
&lt;/plugin&gt;      
英文:

The jetty documentation contains a section about Troubleshooting Locked Files on Windows.

So I updated my plugin config according to the documentation:

&lt;plugin&gt;
  &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
  &lt;artifactId&gt;jetty-maven-plugin&lt;/artifactId&gt;
  &lt;version&gt;9.4.50.v20221201&lt;/version&gt;
  &lt;configuration&gt;
    &lt;war&gt;${jway.webapps.dir}/myapp.war&lt;/war&gt;
    &lt;scanIntervalSeconds&gt;2&lt;/scanIntervalSeconds&gt;
    &lt;webApp&gt;
  	&lt;_initParams&gt;
        &lt;org.eclipse.jetty.servlet.Default.useFileMappedBuffer&gt;false&lt;/org.eclipse.jetty.servlet.Default.useFileMappedBuffer&gt;
  	&lt;/_initParams&gt;
    &lt;/webApp&gt;
  &lt;/configuration&gt;
&lt;/plugin&gt;      

huangapple
  • 本文由 发表于 2023年2月8日 19:28:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/75385136.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定