简体   繁体   English

执行 org.apache.maven.plugins:maven-war-plugin:2.1.1:war 时缺少必需的类

[英]A required class was missing while executing org.apache.maven.plugins:maven-war-plugin:2.1.1:war

Here is my clean install -x result:这是我的全新安装 -x 结果:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building test Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test ---
[INFO] Deleting C:\Users\utopcu\workspace\test\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ test ---
[WARNING] Using platform encoding (Cp1254 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ test ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ test ---
[WARNING] Using platform encoding (Cp1254 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\utopcu\workspace\test\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ test ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ test ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ test ---
[WARNING] Error injecting: org.apache.maven.plugin.war.WarMojo
java.lang.NoClassDefFoundError: org/apache/maven/shared/filtering/MavenFilteringException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2483)
    at java.lang.Class.getDeclaredConstructors(Class.java:1891)
    at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:245)
    at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:99)
    at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:653)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:863)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:790)
    at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:278)
    at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:210)
    at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:986)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1019)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:982)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1032)
    at org.eclipse.sisu.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:44)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:55)
    at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
    at org.eclipse.sisu.plexus.lifecycles.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:134)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:109)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:47)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:997)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1047)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:993)
    at com.google.inject.Scopes$1$1.get(Scopes.java:59)
    at org.eclipse.sisu.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:82)
    at org.eclipse.sisu.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:52)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:259)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:251)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:459)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:97)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:318)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:414)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:357)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: java.lang.ClassNotFoundException: org.apache.maven.shared.filtering.MavenFilteringException
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
    ... 55 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.342s
[INFO] Finished at: Mon Aug 26 14:09:27 EEST 2013
[INFO] Final Memory: 11M/105M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project test: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war failed: A required class was missing while executing org.apache.maven.plugins:maven-war-plugin:2.1.1:war: org/apache/maven/shared/filtering/MavenFilteringException
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-war-plugin:2.1.1
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/utopcu/.m2/repository/org/apache/maven/plugins/maven-war-plugin/2.1.1/maven-war-plugin-2.1.1.jar
[ERROR] urls[1] = file:/C:/Users/utopcu/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.6/maven-reporting-api-2.0.6.jar
[ERROR] urls[2] = file:/C:/Users/utopcu/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.jar
[ERROR] urls[3] = file:/C:/Users/utopcu/.m2/repository/commons-cli/commons-cli/1.0/commons-cli-1.0.jar
[ERROR] urls[4] = file:/C:/Users/utopcu/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar
[ERROR] urls[5] = file:/C:/Users/utopcu/.m2/repository/org/apache/maven/maven-archiver/2.4.1/maven-archiver-2.4.1.jar
[ERROR] urls[6] = file:/C:/Users/utopcu/.m2/repository/org/codehaus/plexus/plexus-archiver/1.2/plexus-archiver-1.2.jar
[ERROR] urls[7] = file:/C:/Users/utopcu/.m2/repository/org/codehaus/plexus/plexus-io/1.0.1/plexus-io-1.0.1.jar
[ERROR] urls[8] = file:/C:/Users/utopcu/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.13/plexus-interpolation-1.13.jar
[ERROR] urls[9] = file:/C:/Users/utopcu/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[10] = file:/C:/Users/utopcu/.m2/repository/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar
[ERROR] urls[11] = file:/C:/Users/utopcu/.m2/repository/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar
[ERROR] urls[12] = file:/C:/Users/utopcu/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.5/plexus-utils-2.0.5.jar
[ERROR] urls[13] = file:/C:/Users/utopcu/.m2/repository/org/apache/maven/shared/maven-filtering/1.0-beta-2/maven-filtering-1.0-beta-2.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------: org.apache.maven.shared.filtering.MavenFilteringException
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

And here is my pom.xml:这是我的 pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>trest</groupId>
    <artifactId>test</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>test Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
            </plugin>
        </plugins>
    </build>
</project>

I tried to delete repositories and install again.我试图删除存储库并重新安装。 I got this error always.我总是收到这个错误。 It looks like I need help.看起来我需要帮助。 I think my mojo plugin is broken but i re installed it several times.我认为我的 mojo 插件坏了,但我重新安装了几次。 Any suggestions?有什么建议么?

Does the class org.apache.maven.shared.filtering.MavenFilteringException exist in file:/C:/Users/utopcu/.m2/repository/org/apache/maven/shared/maven-filtering/1.0-beta-2/maven-filtering-1.0-beta-2.jar ?文件中是否存在类org.apache.maven.shared.filtering.MavenFilteringException file:/C:/Users/utopcu/.m2/repository/org/apache/maven/shared/maven-filtering/1.0-beta-2/maven-filtering-1.0-beta-2.jar

The error message suggests that it doesn't.错误消息表明它没有。 Maybe the JAR was corrupted somehow.也许 JAR 不知何故损坏了。

I'm also wondering where the version 1.0-beta-2 comes from;我也想知道1.0-beta-2版本是从哪里来的; I have 1.0 on my disk.我的磁盘上有1.0 Try version 2.3 of the WAR plugin.尝试 WAR 插件的2.3版。

Try to delete the maven folder at ~/.m2/repository/org/apache/maven and build your project again to force the maven libraries be downloaded.尝试删除~/.m2/repository/org/apache/maven 中的 maven 文件夹并再次构建您的项目以强制下载 maven 库。 This worked for me the last time I faced this java.lang.NoClassDefFoundError: org/apache/maven/shared/filtering/MavenFilteringException.上次我遇到这个 java.lang.NoClassDefFoundError: org/apache/maven/shared/filtering/MavenFilteringException 时,这对我有用。

This should fix the error这应该修复错误

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-resources-plugin</artifactId>
     <version>2.7</version>
     <dependencies>
         <dependency>
             <groupId>org.apache.maven.shared</groupId>
             <artifactId>maven-filtering</artifactId>
             <version>1.3</version>
          </dependency>
      </dependencies>
</plugin>

Faced the same issue and resolved by upgrading my Maven from 3.0.4 to 3.1.1.遇到同样的问题并通过将我的 Maven 从 3.0.4 升级到 3.1.1 来解决。 Please try with v3.1.1 or any higher version if available如果可用,请尝试使用 v3.1.1 或任何更高版本

You should add maven-resources-plugin in your pom.xml file.您应该在pom.xml文件中添加maven-resources-plugin Deleting ~/.m2/repository does not work always.删除~/.m2/repository并不总是有效。

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.4</version>
            </plugin>
        </plugins>

Now build your project again.现在再次构建您的项目。 It should be successful!应该会成功!

this happened to me too after adding the version tag, that was missing, to the maven-war-plugin (not sure what version was using by default, i changed to the latest, 2.6 in my case).在将缺少的版本标记添加到 maven-war-plugin 后,这也发生在我身上(不确定默认情况下使用的是哪个版本,我更改为最新版本,在我的情况下为 2.6)。 I had to wipe .m2/repository to have the build succeed again.我必须擦除 .m2/repository 才能再次成功构建。

I tried first to clean the maven-filtering folder (in the repo) but then instead of a MavenFilterException i was getting an ArchiverException.我首先尝试清理 maven-filtering 文件夹(在 repo 中),但随后我收到了 ArchiverException 而不是 MavenFilterException。 So i concluded the local repository was corrupted (for a version upgrade?) and i deleted everything.所以我得出结论本地存储库已损坏(用于版本升级?)并且我删除了所有内容。

That fixed it for me.那为我修好了。 Just clean your local repo.只需清理您的本地仓库。

Make sure your Java version matches the project's Java version requirement.确保您的 Java 版本符合项目的 Java 版本要求。 This could be an another cause for such kinds of issues.这可能是此类问题的另一个原因。

My solution below is for cases when default maven repositories are not accessible (eg due to firewalls).我下面的解决方案适用于无法访问默认 maven 存储库的情况(例如,由于防火墙)。

In case the default repository is not accessible appropriate local <pluginRepository> has to be specified in the settings.xml.如果默认存储库不可访问,则必须在 settings.xml 中指定适当的本地<pluginRepository> If it's the same as your local artifact repository it still needs to be added to the <pluginRepositories> section for plugin jars to be found.如果它与您的本地工件存储库相同,则仍需要将其添加到<pluginRepositories>部分以找到插件 jar。 Regular <repositories> section is not used to fetch plugin jars.常规<repositories>部分不用于获取插件 jar。

In my case, however, the issue was caused by the fact that there were multiple plugin repositories defined in that section.但是,就我而言,问题是由于该部分定义了多个插件存储库这一事实引起的。

The first repository in the list did not contain the required maven-filtering jar.列表中的第一个存储库不包含所需的 maven 过滤 jar。

I had to change the order of <pluginRepository> definitions to ensure the first one contains maven-filtering.我不得不更改<pluginRepository>定义的顺序以确保第一个包含 maven-filtering。

Changing of repository definitions typically requires to clean ~/.m2/repository and start fresh.更改存储库定义通常需要清理 ~/.m2/repository 并重新开始。

In my case the situation was this: I had an offline server on which I had to perform the build.就我而言,情况是这样的:我有一个离线服务器,我必须在它上面执行构建。 For that I had compiled everything locally first and then transferred repository folder to the offline server.为此,我首先在本地编译了所有内容,然后将存储库文件夹传输到离线服务器。

Problem - build works locally but not on the server, even thou they both have same maven version, same repository folder, same JDK.问题 - 构建在本地运行但不在服务器上运行,即使它们都具有相同的 maven 版本、相同的存储库文件夹、相同的 JDK。

Cause: on my local machine I had additional custom "" entry in settings.xml.原因:在我的本地机器上,我在 settings.xml 中有额外的自定义“”条目。 When I added same to the settings.xml on the server then my issues disappeared.当我将相同的内容添加到服务器上的 settings.xml 时,我的问题就消失了。

暂无
暂无

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

相关问题 缺少org.apache.maven.plugins:maven-war-plugin:jar:3.0的POM,没有可用的依赖项信息 - The POM for org.apache.maven.plugins:maven-war-plugin:jar:3.0 is missing, no dependency information available 无法计算构建计划:插件 org.apache.maven.plugins:maven-war-plugin:2.2 - Could not calculate build plan: Plugin org.apache.maven.plugins:maven-war-plugin:2.2 A required class was missing while executing org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar - A required class was missing while executing org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar DevOps - Maven: org.apache.maven.lifecycle.LifecycleExecutionException: 无法执行目标 org.apache.maven.plugins:maven-war-plugin:2.6:war - DevOps - Maven: org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.6:war 无法在项目 hapi-fhir-jpaserver-starter 上执行目标 org.apache.maven.plugins:maven-war-plugin:3.2.3:war (default-war) - Failed to execute goal org.apache.maven.plugins:maven-war-plugin:3.2.3:war (default-war) on project hapi-fhir-jpaserver-starter 执行org.apache.maven.plugins时缺少必需的类:maven-surefire-plugin:2.14.1:test:org / junit / runner / notification / RunListener - A required class was missing while executing org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test: org/junit/runner/notification/RunListener 警告 org.apache.maven.plugins:maven-deploy-plugin 的“build.plugins.plugin.version”丢失 - WARNING 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-deploy-plugin is missing org.apache.maven.plugins:maven-surefire-plugin 的“build.plugins.plugin.version”丢失 - 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing 加载属性文件时出错(插件:maven-war-plugin:2.4:war:default-war:package) - Error loading property file (plugins:maven-war-plugin:2.4:war:default-war:package) org.apache.maven.plugins:即使在Eclipse中有Maven插件,maven-compiler-plugin也丢失了 - org.apache.maven.plugins:maven-compiler-plugin is missing even there is a maven plug in in eclipse
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM