2009-08-18 85 views
3

當我使用貨物插件中的Maven處理對tomcat的熱部署時,如果.war工件當前不存在,maven將無法執行乾淨的任務。所以如果我運行mvn clean,那麼mvn clean package - 它會出錯。我能做些什麼來讓貨物忽略它?在貨物插件中使用Maven的問題

C:\work2\Fresh\fresh-ui>mvn clean 
[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building fresh-ui 
[INFO] task-segment: [clean] 
[INFO] ------------------------------------------------------------------------ 
[INFO] [cargo:deployer-undeploy {execution: clean-undeploy}] 
[INFO] [mcat5xRemoteDeployer] Undeploying [C:\work2\Fresh\fresh-ui\target\fresh. 
war] 
[INFO] [clean:clean {execution: default-clean}] 
[INFO] Deleting directory C:\work2\Fresh\fresh-ui\target 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESSFUL 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 5 seconds 
[INFO] Finished at: Tue Aug 18 09:49:16 PDT 2009 
[INFO] Final Memory: 9M/16M 
[INFO] ------------------------------------------------------------------------ 
C:\work2\Fresh\fresh-ui>mvn clean 
[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building fresh-ui 
[INFO] task-segment: [clean] 
[INFO] ------------------------------------------------------------------------ 
[INFO] [cargo:deployer-undeploy {execution: clean-undeploy}] 
[INFO] ------------------------------------------------------------------------ 
[ERROR] FATAL ERROR 
[INFO] ------------------------------------------------------------------------ 
[INFO] Failed to create deployable for the parameters (container [id = [tomcat5x 
]], deployable type [war]). 
C:\work2\Fresh\fresh-ui\target\fresh.war (The system cannot find the path specif 
ied) 
[INFO] ------------------------------------------------------------------------ 
[INFO] Trace 
org.codehaus.cargo.container.ContainerException: Failed to create deployable for 
the parameters (container [id = [tomcat5x]], deployable type [war]). 
     at org.codehaus.cargo.generic.spi.AbstractGenericHintFactory.createImple 
mentation(AbstractGenericHintFactory.java:157) 
     at org.codehaus.cargo.generic.spi.AbstractIntrospectionGenericHintFactor 
y.createImplementation(AbstractIntrospectionGenericHintFactory.java:86) 
     at org.codehaus.cargo.generic.deployable.DefaultDeployableFactory.create 
Deployable(DefaultDeployableFactory.java:163) 
     at org.codehaus.cargo.maven2.configuration.Deployable.createDeployable(D 
eployable.java:136) 
     at org.codehaus.cargo.maven2.AbstractDeployerMojo.performDeployerActionO 
nAllDeployables(AbstractDeployerMojo.java:99) 
     at org.codehaus.cargo.maven2.AbstractDeployerMojo.doExecute(AbstractDepl 
oyerMojo.java:47) 
     at org.codehaus.cargo.maven2.AbstractCargoMojo.execute(AbstractCargoMojo 
.java:255) 
     at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi 
nManager.java:483) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa 
ultLifecycleExecutor.java:678) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi 
fecycle(DefaultLifecycleExecutor.java:540) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau 
ltLifecycleExecutor.java:519) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan 
dleFailures(DefaultLifecycleExecutor.java:371) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen 
ts(DefaultLifecycleExecutor.java:332) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi 
fecycleExecutor.java:181) 
     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356) 
     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137) 
     at org.apache.maven.cli.MavenCli.main(MavenCli.java:362) 
     at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:4 
1) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. 
java:39) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces 
sorImpl.java:25) 
     at java.lang.reflect.Method.invoke(Method.java:597) 
     at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) 
     at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) 
     at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) 

     at org.codehaus.classworlds.Launcher.main(Launcher.java:375) 
Caused by: java.lang.reflect.InvocationTargetException 
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 

     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct 
orAccessorImpl.java:39) 
     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC 
onstructorAccessorImpl.java:27) 
     at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
     at org.codehaus.cargo.generic.deployable.DefaultDeployableFactory.create 
Instance(DefaultDeployableFactory.java:196) 
     at org.codehaus.cargo.generic.spi.AbstractGenericHintFactory.createImple 
mentation(AbstractGenericHintFactory.java:153) 
     ... 25 more 
Caused by: org.codehaus.cargo.container.ContainerException: Failed to parse Tomc 
at WAR file in [C:\work2\Fresh\fresh-ui\target\fresh.war] 
     at org.codehaus.cargo.container.tomcat.TomcatWAR.<init>(TomcatWAR.java:5 
5) 
     ... 31 more 
Caused by: org.codehaus.cargo.util.CargoException: Failed to find file [C:\work2 
\Fresh\fresh-ui\target\fresh.war] 
     at org.codehaus.cargo.util.DefaultFileHandler.getInputStream(DefaultFile 
Handler.java:351) 
     at org.codehaus.cargo.module.DefaultJarArchive.getContentAsStream(Defaul 
tJarArchive.java:231) 
     at org.codehaus.cargo.module.DefaultJarArchive.getResource(DefaultJarArc 
hive.java:154) 
     at org.codehaus.cargo.module.webapp.tomcat.TomcatWarArchive.parseTomcatC 
ontextXml(TomcatWarArchive.java:92) 
     at org.codehaus.cargo.module.webapp.tomcat.TomcatWarArchive.<init>(Tomca 
tWarArchive.java:61) 
     at org.codehaus.cargo.container.tomcat.TomcatWAR.<init>(TomcatWAR.java:5 
1) 
     ... 31 more 
Caused by: java.io.FileNotFoundException: C:\work2\Fresh\fresh-ui\target\fresh.w 
ar (The system cannot find the path specified) 
     at java.io.FileInputStream.open(Native Method) 
     at java.io.FileInputStream.<init>(FileInputStream.java:106) 
     at org.codehaus.cargo.util.DefaultFileHandler.getInputStream(DefaultFile 
Handler.java:347) 
     ... 36 more 
java.lang.reflect.InvocationTargetException 
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 

     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct 
orAccessorImpl.java:39) 
     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC 
onstructorAccessorImpl.java:27) 
     at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
     at org.codehaus.cargo.generic.deployable.DefaultDeployableFactory.create 
Instance(DefaultDeployableFactory.java:196) 
     at org.codehaus.cargo.generic.spi.AbstractGenericHintFactory.createImple 
mentation(AbstractGenericHintFactory.java:153) 
     at org.codehaus.cargo.generic.spi.AbstractIntrospectionGenericHintFactor 
y.createImplementation(AbstractIntrospectionGenericHintFactory.java:86) 
     at org.codehaus.cargo.generic.deployable.DefaultDeployableFactory.create 
Deployable(DefaultDeployableFactory.java:163) 
     at org.codehaus.cargo.maven2.configuration.Deployable.createDeployable(D 
eployable.java:136) 
     at org.codehaus.cargo.maven2.AbstractDeployerMojo.performDeployerActionO 
nAllDeployables(AbstractDeployerMojo.java:99) 
     at org.codehaus.cargo.maven2.AbstractDeployerMojo.doExecute(AbstractDepl 
oyerMojo.java:47) 
     at org.codehaus.cargo.maven2.AbstractCargoMojo.execute(AbstractCargoMojo 
.java:255) 
     at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi 
nManager.java:483) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa 
ultLifecycleExecutor.java:678) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi 
fecycle(DefaultLifecycleExecutor.java:540) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau 
ltLifecycleExecutor.java:519) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan 
dleFailures(DefaultLifecycleExecutor.java:371) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen 
ts(DefaultLifecycleExecutor.java:332) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi 
fecycleExecutor.java:181) 
     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356) 
     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137) 
     at org.apache.maven.cli.MavenCli.main(MavenCli.java:362) 
     at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:4 
1) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. 
java:39) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces 
sorImpl.java:25) 
     at java.lang.reflect.Method.invoke(Method.java:597) 
     at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) 
     at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) 
     at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) 

     at org.codehaus.classworlds.Launcher.main(Launcher.java:375) 
Caused by: org.codehaus.cargo.container.ContainerException: Failed to parse Tomc 
at WAR file in [C:\work2\Fresh\fresh-ui\target\fresh.war] 
     at org.codehaus.cargo.container.tomcat.TomcatWAR.<init>(TomcatWAR.java:5 
5) 
     ... 31 more 
Caused by: org.codehaus.cargo.util.CargoException: Failed to find file [C:\work2 
\Fresh\fresh-ui\target\fresh.war] 
     at org.codehaus.cargo.util.DefaultFileHandler.getInputStream(DefaultFile 
Handler.java:351) 
     at org.codehaus.cargo.module.DefaultJarArchive.getContentAsStream(Defaul 
tJarArchive.java:231) 
     at org.codehaus.cargo.module.DefaultJarArchive.getResource(DefaultJarArc 
hive.java:154) 
     at org.codehaus.cargo.module.webapp.tomcat.TomcatWarArchive.parseTomcatC 
ontextXml(TomcatWarArchive.java:92) 
     at org.codehaus.cargo.module.webapp.tomcat.TomcatWarArchive.<init>(Tomca 
tWarArchive.java:61) 
     at org.codehaus.cargo.container.tomcat.TomcatWAR.<init>(TomcatWAR.java:5 
1) 
     ... 31 more 
Caused by: java.io.FileNotFoundException: C:\work2\Fresh\fresh-ui\target\fresh.w 
ar (The system cannot find the path specified) 
     at java.io.FileInputStream.open(Native Method) 
     at java.io.FileInputStream.<init>(FileInputStream.java:106) 
     at org.codehaus.cargo.util.DefaultFileHandler.getInputStream(DefaultFile 
Handler.java:347) 
     ... 36 more 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 3 seconds 
[INFO] Finished at: Tue Aug 18 09:49:22 PDT 2009 
[INFO] Final Memory: 8M/16M 
[INFO] ------------------------------------------------------------------------ 
C:\work2\Fresh\fresh-ui> 
+1

這似乎是一個常見問題,最簡單的答案是:只運行一次。我會更深入地瞭解一下,看看是否有可以設置的配置,以避免在第二次電話中出現貨物故障。 – 2009-08-18 17:23:07

+0

此博客中有一些信息:http://betterlogic.com/roger/?p = 1714,但它似乎不是一個完整的答案 – 2009-08-18 17:24:30

回答

2

從我所看到的,你勢必deployer-undeploy的清潔週期的pre-clean階段。因此,在執行第一個clean時,戰爭被安全解除,然後target被刪除。執行第二次清理時,cargo:deployer-undeploy找不到target中的戰爭並失敗。

對我來說,Cargo不應該失敗,這可能是Cargo的maven 2插件或核心API中的一個錯誤,它應該適當地處理這種情況。我會在Cargo的issue tracker中打開一個問題。

正如Rich在評論中提到的,目前的解決方法是隻運行一次乾淨。