eclipse/maven/sonatype war 构建可以在命令行运行,但不能在 eclipse 中运行

发布于 2024-09-01 11:21:28 字数 5049 浏览 6 评论 0原文

我的(简单的)war 项目在命令行中使用 mvn:package 构建得很好,但无法通过 sonatype 插件使用 maven 在 eclipse 中构建。 我得到的错误是:

[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

我真的有两个问题 1)如何修复这个错误? 2)为什么 mvn:package 在命令行下工作正常,但不能通过插件工作?它们的工作方式有什么区别,以至于会发生这样的错误?

非常感谢!

编辑:在调试模式下运行的堆栈跟踪:

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

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.
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?
2) Why does mvn:package work fine at the command line, but not through the plugin? 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

驱逐舰岛风号 2024-09-08 11:21:28

为什么mvn:package在命令行中可以正常工作,但不能通过插件工作?它们的工作方式有何不同,以至于会出现这样的错误?

简而言之,m2eclipse 不会使用您在命令行上使用的相同版本,除非您告诉他这样做(这是我的建议)。如果您想知道,m2eclipse 使用嵌入式 Maven 3 (Maven Embedder 3.0.0.200912160759)。

如何修复此错误?

实际上,问题记录在 http://jira.codehaus.org/browse/MWAR-187 它提供了几种解决方法。

  • 将 maven-war-plugin 降级到 2.1-alpha-1
  • 通过修改 maven-war-plugin 配置停用缓存

    <前><代码><配置>;

我认为将 M2Eclipse 配置为不使用 Maven Embedder (但您在 CLI 上使用的版本)也可以解决问题,这是我的建议。您可以在窗口>中找到此设置。首选项> Maven。

Why does mvn:package work fine at the command line, but not through the plugin? 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). If you wonder, m2eclipse uses embedded 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.

  • downgrade the maven-war-plugin to 2.1-alpha-1
  • deactivate the cache by modifying the maven-war-plugin configuration

    <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. You'll find this setting in Window > Preferences > Maven.

属性 2024-09-08 11:21:28

我遇到了同样的问题,但执行了mvn install。在命令行中工作正常,但在 Eclipse 中失败。

实际发生的情况是,显然我的 webapp-cache.xml 文件已损坏。我解决了运行mvn clean install的问题。

I got this same problem but doing a mvn install. Worked fine in command line but failed from Eclipse.

What actually happened was that apparently my webapp-cache.xml file was corrupted. I solved the problem running mvn clean install.

习ぎ惯性依靠 2024-09-08 11:21:28

您需要进入 preferences->maven->installation 并选择外部安装。我正在使用 springsource 工具套件。但是maven配置路径在其他eclipse版本中应该是相同的。

You need to go to preferences->maven->installation and choose your external installation. I am using springsource tool suite. But the maven config path should be same in other eclipse variety.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文