简体   繁体   English

Maven Jetty插件使用错误的资源文件URL

[英]Maven jetty plugin using wrong resource file URL

I am running a project within a vagrant box setup over my eclipse workspace. 我正在Eclipse工作区上的无聊的盒子安装程序中运行一个项目。 I am working on setting up a new maven project but I am having problems with the plugin using windows paths instead of the vagrant path. 我正在建立一个新的Maven项目,但是使用Windows路径而不是无业游民的路径来解决插件问题。 My windows workspace is setup in C:\\Dev, so when I 'vagrant up', my entire workspace is available within my VM. 我的Windows工作区是在C:\\ Dev中设置的,所以当我“无所事事”时,我的整个工作区都可以在我的VM中使用。 In other words, /vagrant in the VM contains the contents of C:\\Dev. 换句话说,VM中的/ vagrant包含C:\\ Dev的内容。

When I execute mvn jetty:run, everything starts up fine and all paths use the vagrant versions (/vagrant/mvn_project/target...). 当我执行mvn jetty:run时,一切正常启动,并且所有路径都使用无业游民的版本(/ vagrant / mvn_project / target ...)。 However, once the plugin starts scanning the project for changes, it throws the following error: 但是,一旦插件开始扫描项目中的更改,它将引发以下错误:

2014-02-26 01:18:53.756:WARN:oejw.WebAppContext:Scanner-0: Failed startup of context o.e.j.m.p.JettyWebAppContext@591f46d8{/,[file:/vagrant/mvn_project/web, file:/vagrant/mvn_project/target/webapps/ROOT/],STARTING}{/ROOT/]}
javax.servlet.UnavailableException: Malformed URL 'file://C:\\Dev\\mvn_project/target/webapps/ROOT/WEB-INF/dtd/web-app_2_3.dtd' : For input string: "\\Dev\\mvn_project"
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:402)
    at javax.servlet.GenericServlet.init(GenericServlet.java:244)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:561)
    at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:351)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:840)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:300)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1347)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:745)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
    at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:282)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.restartWebApp(JettyRunMojo.java:532)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo$1.filesChanged(JettyRunMojo.java:485)
    at org.eclipse.jetty.util.Scanner.reportBulkChanges(Scanner.java:681)
    at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:539)
    at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
    at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)

Is this a bug with the plugin or is there a configuration setting I can use to set this value? 这是插件的错误,还是可以用来设置此值的配置设置?

Edit: A little more context... It seems that the problem has something to do with filtered resources. 编辑:更多上下文...似乎问题与筛选的资源有关。

     <resources>
        <resource>
            <directory>${project.basedir}/src/main/filtered-resources</directory>
            <filtering>true</filtering>
            <targetPath>${project.basedir}/target/webapps/ROOT</targetPath>
        </resource>
    </resources>

Changing ${project.basedir} to /vagrant/mvn_project seems to fix the problem, but clearly this is just a workaround and not a solution (won't work in CI for example). 将$ {project.basedir}更改为/ vagrant / mvn_project似乎可以解决此问题,但是显然,这只是解决方法,而不是解决方案(例如,在CI中不起作用)。

UPDATE: It turns out, the blame is on Eclipse. 更新:事实证明,责任归咎于Eclipse。 Eclipse is occasionally building the project and when it does so, ${project.basedir} refers to C:\\Dev\\mvn_project instead of /vagrant/mvn_project. Eclipse偶尔会构建项目,并且这样做时,$ {project.basedir}指向C:\\ Dev \\ mvn_project而不是/ vagrant / mvn_project。 Is there a way to override ${project.basedir} without hard coding? 有没有一种方法可以重写$ {project.basedir}而不进行硬编码?

Simple answer: disable builds in eclipse. 简单的答案:禁用Eclipse中的版本。 Uncheck Project -> Build Automatically. 取消选中项目->自动构建。 Always run builds from within vagrant (mvn compile). 始终从无业游民(mvn编译)内部运行构建。 JSP hot changes still work automatically. JSP热更改仍会自动工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM