简体   繁体   English

eclipse / maven / sonatype war build在命令行工作但不在eclipse中工作

[英]eclipse/maven/sonatype war build works at the command line but not in eclipse

My (simple) war project builds fine using mvn:package at the command line, but fails to build in eclipse using maven via the sonatype plugin. 我的(简单)war项目在命令行使用mvn:package构建良好,但无法使用maven通过sonatype插件在eclipse中构建。 The error I'm getting is: 我得到的错误是:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1-alpha-1:war (default-war) on project shoploops_webapp: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.1-alpha-1:war failed: dependenciesInfo : dependenciesInfo
---- Debugging information ----
message             : dependenciesInfo : dependenciesInfo
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : dependenciesInfo : dependenciesInfo
class               : org.apache.maven.plugin.war.util.WebappStructure
required-type       : org.apache.maven.plugin.war.util.WebappStructure
path                : /webapp-structure/dependenciesInfo
line number         : 14

I really have two questions 1) How can I fix this error? 我真的有两个问题1)我该如何解决这个错误? 2) Why does mvn:package work fine at the command line, but not through the plugin? 2)为什么mvn:package在命令行工作正常,但不能通过插件工作? What is the difference between them in how they work, such that errors like this can occur? 它们在工作方式上有什么区别,这样会发生这样的错误?

Many thanks! 非常感谢!

Edit : the stack trace from running it in debug mode: 编辑 :在调试模式下运行它的堆栈跟踪:

Caused by: com.thoughtworks.xstream.converters.ConversionException: dependenciesInfo : dependenciesInfo
---- Debugging information ----
message             : dependenciesInfo : dependenciesInfo
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : dependenciesInfo : dependenciesInfo
class               : org.apache.maven.plugin.war.util.WebappStructure
required-type       : org.apache.maven.plugin.war.util.WebappStructure
path                : /webapp-structure/dependenciesInfo
line number         : 14
-------------------------------
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:63)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:117)
    at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.unmarshal(ReferenceByXPathMarshallingStrategy.java:29)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:846)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:833)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:781)
    at org.apache.maven.plugin.war.util.WebappStructureSerializer.fromXml(WebappStructureSerializer.java:48)
    at org.apache.maven.plugin.war.AbstractWarMojo.buildWebapp(AbstractWarMojo.java:346)
    at org.apache.maven.plugin.war.AbstractWarMojo.buildExplodedWebapp(AbstractWarMojo.java:317)
    at org.apache.maven.plugin.war.WarMojo.performPackaging(WarMojo.java:166)
    at org.apache.maven.plugin.war.WarMojo.execute(WarMojo.java:130)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
    ... 15 more
Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: dependenciesInfo : dependenciesInfo
    at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:49)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
    at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:76)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
    at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:60)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
    at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:76)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
    at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:34)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.determineType(AbstractReflectionConverter.java:296)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:178)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:125)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
    ... 28 more

Why does mvn:package work fine at the command line, but not through the plugin? 为什么mvn:package在命令行工作正常,而不是通过插件? What is the difference between them in how they work, such that errors like this can occur? 它们在工作方式上有什么区别,这样会发生这样的错误?

The short version is that m2eclipse does not use the same version that you use on the command line unless you told him to do so (and that would be my recommendation). 简短的版本是,m2eclipse的使用,除非你告诉他这样做(这将是我的建议),您在命令行中使用相同的版本。 If you wonder, m2eclipse uses embedded Maven 3 (Maven Embedder 3.0.0.200912160759). 如果你想知道,m2eclipse使用嵌入式Maven 3(Maven Embedder 3.0.0.200912160759)。

How can I fix this error? 我该如何解决这个错误?

Actually, the problem is logged in http://jira.codehaus.org/browse/MWAR-187 which provides several workarounds. 实际上,问题记录在http://jira.codehaus.org/browse/MWAR-187中 ,它提供了几种解决方法。

  • downgrade the maven-war-plugin to 2.1-alpha-1 将maven-war-plugin降级为2.1-alpha-1
  • deactivate the cache by modifying the maven-war-plugin configuration 通过修改maven-war-plugin配置来停用缓存

     <configuration> <useCache>false</useCache> </configuration> 

And I think that configuring M2Eclipse to not use Maven Embedder (but the version you use on the CLI) would also solve the problem and this is my suggestion. 我认为将M2Eclipse配置为不使用Maven Embedder(但您在CLI上使用的版本)也可以解决问题,这是我的建议。 You'll find this setting in Window > Preferences > Maven . 您可以在Window> Preferences> Maven中找到此设置。

I got this same problem but doing a mvn install . 我遇到了同样的问题,但做了mvn install Worked fine in command line but failed from Eclipse. 在命令行工作正常,但Eclipse失败了。

What actually happened was that apparently my webapp-cache.xml file was corrupted. 实际发生的事实是我的webapp-cache.xml文件显然已损坏。 I solved the problem running mvn clean install . 我解决了运行mvn clean install的问题。

You need to go to preferences->maven->installation and choose your external installation. 您需要转到preferences->maven->installation并选择外部安装。 I am using springsource tool suite. 我正在使用springource工具套件。 But the maven config path should be same in other eclipse variety. 但是maven配置路径在其他日食种类中应该是相同的。

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

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