Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1:war - Could not copy resource - eclipse

I have a multi-module project that I'm trying to import in my Ubuntu 12.04 LTS's Eclipse Juno. (I already have done it successfully on Windows 7).
My project has six modules, the first four modules are successfully imported from the SVN Repository and built with Maven 3.0.5, but when I try to build the fifth called core, i receive the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1:war (default-war) on project core: Could not copy resource [/opt/workspace/core/target\preassembly]: File /opt/workspace/core/target\preassembly/scripts/Mask.js does not exist -> [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/MojoExecutionException
As the error says, It looks like that Maven can't find the directory /opt/workspace/core/target\preassembly to copy the file /opt/workspace/core/target\preassembly/scripts/Mask.js.
But, this directory actually exists and the file Mask.js is in there. What looks strange to me is that backslash \ after target directory instead a common bar /. But I have no idea if this is a problem and how to solve it, I spent 2 days researching the Internet but unfortunately I've found nothing.
Here's my maven-war-plugin configuration section of parent project's pom.xml, where the backslashes appear
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<webResources>
<resource>
<directory>${project.build.directory}\preassembly</directory>
</resource>
</webResources>
</configuration>
</plugin>
I've also checked the owner of the directories on Ubuntu, and everything refers to the same owner that worked on the first four modules.
As I said above, the same version of eclipse, svn and maven works great on Windows.
Anyone ever had this problem? Thank you very much.

I was working on angular 8 and updated the code to angular 9 and then during build i got the same issue .For me clean build solved the issue.You can try clean build , hope that will help .

Related

Maven gives dependencies issues

I am using Eclipse 2020-06 (4.16.0) version.
In my application I have maven-compiler-plugin defined in my Pom.xml like below.
I also have the specific jars in /users/.m2/repository folder.
When I run the Maven on my project, I still get this error.
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project <>: Compilation failure: Compilation failure:
Also I see the below error:
[ERROR] error reading C:\Users\XXXXXXX.m2\repository\org\apache\httpcomponents\httpclient\4.5.6\httpclient-4.5.6.jar; ZipFile invalid LOC header (bad signature)
I thought httpclient jar file and maven-compiler-plugin got corrupted. I downloaded from internet and did mvn install. Still I see these errors. How can we resolve it.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
In your .m2/repository tree, remove the entire "4.5.6" directory. In your project directory, rerun "mvn -U" package (-U is probably overkill after deleting the directory, but it's a good habit to get into, to ensure that dependencies are redownloaded). Verify that it shows Maven redownloading the httpclient artifact. If you still see the same error, look at the contents of the downloaded "httpclient-4.5.6.jar" file. In this case, I expect it will be a text file, containing html output. If so, that means there is something wrong with your proxy settings in your settings.xml file.

How to fix Missing requirement for javax.imageio while building Eclipse-CDT using Maven?

I downloaded the eclipse cdt source package org.eclipse.cdt-CDT_9_8_1.tar.xz from https://git.eclipse.org/c/cdt/org.eclipse.cdt.git and using maven 3.6.1 i tried to build it with command mvn clean install. Some packages were downloaded from repos and at the end it exited with the below error message
I need to build cdt from source as i want some changes in CDT source code. I am not an expert in Maven, not sure what's going wrong. Please help to resolve the issue
[INFO] Resolving dependencies of MavenProject: org.eclipse.cdt:org.eclipse.cdt.build.gcc.core:1.0.1-SNAPSHOT # D:\Eclipse\Sources\CDT9.8.1_GIT\cdt-releng\org.eclipse.cdt\build\org.eclipse.cdt.build.gcc.core.polyglot.build.properties
[ERROR] Cannot resolve target definition:
[ERROR] Software being installed: com.sun.xml.bind 2.2.0.v201505121915
[ERROR] Missing requirement: com.sun.xml.bind 2.2.0.v201505121915 requires 'java.package; javax.imageio 0.0.0' but it could not be found
[ERROR] Failed to resolve target definition D:\Eclipse\Sources\CDT9.8.1_GIT\cdt-releng\org.eclipse.cdt\releng\org.eclipse.cdt.target\cdt.target: See log for details -> [Help 1]
[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] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MavenExecutionException
The issue here is, that some plugins do not define a RequiredExecutionEnvironment. If such a plugin depends on a JRE package the build fails with the given error.
In Tycho it is possible to define such an environment:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<!-- needed as some plugins do not set a execution environment they would fail to get jre packages (eg. javax.imageio) -->
<executionEnvironment>JavaSE-1.8</executionEnvironment>
</configuration>
</plugin>

Sonar `should be relative to project baseDir` error in travis

Some time between the 11th September and the 14th September, running sonar through our travis build started failing with an org.eclipse.dawnsci.targetplatform should be relative to project baseDir error:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project org.eclipse.scanning: Dir /home/travis/build/eclipse/org.eclipse.dawnsci/org.eclipse.dawnsci.targetplatform should be relative to project baseDir -> [Help 1]
Looking through the pom.xml the org.eclipse.dawnsci module does stand out as being different to all of the others:
<modules>
<module>org.eclipse.scanning.target.platform</module>
<module>../org.eclipse.dawnsci</module>
<module>org.eclipse.scanning.api</module>
...
</modules>
I have tried updating sonar-project.properties from
sonar.exclusions=**/*.xml,**/*.class
to each of the following:
sonar.exclusions=**/*.xml,**/*.class,../org.eclipse.dawnsci
sonar.exclusions=**/*.xml,**/*.class,org.eclipse.dawnsci*
sonar.exclusions=**/*.xml,**/*.class,org.eclipse.dawnsci**
but none of these changes helped.
After previous problems I have added --fail-never to the mvn -q sonar:sonar command in .travis.yml so this problem won't prevent pull requests being merged, but it would be nice to have sonar reports on our repo again.
Any suggestions about how I can fix our travis build would be appreciated?
We changed the way we validate project layout, and it leads to this error. A ticket was created to track this change, and we are currently discussing options (like updating the SonarQube Scanner for Maven). Feel free to follow it for updates, and sorry for the inconvenience.
For your specific case, one workaround is to create a build profile, and exclude module ../org.eclipse.dawnsci when running the SonarCloud analysis. Or move the module to be under the project basedir (and avoid using .. in module location).
As a side note, there is no point maintaining the file sonar-project.properties if you are using the Scanner for Maven (mvn sonar:sonar) since the Scanner for Maven will only read configuration from pom.xml.
As suggested by Julien H. - SonarSource Team adding a profile did solve this problem.
In the pom.xml I changed
<modules>
<module>org.eclipse.scanning.target.platform</module>
<module>../org.eclipse.dawnsci</module>
...
</modules>
to
<profiles>
<profile>
<id>externalModules</id>
<activation><activeByDefault>true</activeByDefault></activation>
<modules>
<module>../org.eclipse.dawnsci</module>
</modules>
</profile>
</profiles>
<modules>
<module>org.eclipse.scanning.target.platform</module>
...
</modules>
so that the module is included by default.
I then added -P !externalModules to my mvn sonar:sonar command in .travis.yml so that it was excluded when running sonar analysis.
I stumbled over the same problem and finally came to the conclusion that this has all been fixed in the latest sonar-maven-plugin 3.4. You can simply upgrade your dependency to this:
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.0.905</version>
</plugin>

Trouble with the sonar-packaging-maven-plugin after refactoring

I have some trouble developing a plugin for my company, later called as "myPlugin".
Background:
I was reading the book "SonarQube in Action" by the Manning company.
There was a little guide for developing a own plugin (they used the redmine plugin as example for developing). It told me to use the sonar-plugin-archetype to create the basic framework.
Situation before refactoring:
I wrote the plugin and it works fine. I encountered the problem when I've done some refactoring. Before the refactoring every package in the src folder in my tree (using ecplise) was called "main.java.org.sonar.plugins.myplugin" but the package decleration within each class was "org.sonar.plugins.myplugin". This were default settings created by using the sonar-plugin-archetype.
The settings within the pom.xml of the sonar-packaging-maven-plugin were the following once.
Pom-snippet before any changes were done:
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.9</version>
<extensions>true</extensions>
<configuration>
<pluginClass>org.sonar.plugins.myplugin.myPlugin</pluginClass>
</configuration>
</plugin>
So far everything worked fine. Now we come to my problem.
Situation after refactoring:
As my company has some naming conevtions for classes and packages i changed the package names in the tree to "com.mycompany.sonar.plugins.myplugin" and the package decleration within each class also to "com.mycompany.sonar.plugins.myplugin". Then i changed the classPath option for the sonar-packaging-maven-plugin to "com.mycompany.sonar.plugins.myplugin.myPlugin". All I've done so to say was changing "org." into "com.mycompany.".
Pom-snippet after changes were done:
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.9</version>
<extensions>true</extensions>
<configuration>
<pluginClass>com.mycompany.sonar.plugins.myplugin.myPlugin</pluginClass>
</configuration>
</plugin>
When i was running the "compile" command everything worked. Using "package" does not work, because the sonar-packaging-maven-plugin was not able to find the given class (see console output below). When i'm refoactoring everything again back to the beginning it works again.
[...]
[INFO] --- sonar-packaging-maven-plugin:1.9:sonar-plugin (default-sonar-plugin) # sonar-projectkeychecker-plugin ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.649 s
[INFO] Finished at: 2014-04-02T11:42:01+01:00
[INFO] Final Memory: 13M/67M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.sonar:sonar-packaging-maven-plugin:1.9:sonar-plugin (default-sonar-plugin) on project sonar-myplugin-plugin: Plugin class not found: 'com.mycompany.sonar.plugins.myplugin.myPlugin-> [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/MojoExecutionException
My Question: Why are my new names not working? Are there any inner convetions for the sonar-packaging-maven-plugin (like the packaging name has to beginn with "org.sonar" ot something like this)?
Thank you for reading this long text and your try to help me :)
pluginClass is the entry point of the plugin. Value must be an existing class. In your example I suppose that there's a typo, it should be com.mycompany.sonar.plugins.myplugin.MyPlugin (upper-case M).
Under <plugin> I was missing the <extensions>true</extensions> tag

An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException

I'm developing a Java EE web project. When I try to add a dependency, this error message appears. I use Eclipse Kepler.
An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException
Could you help me?
Thank you.
I solved mine by deleting the .settings folder and .project file in the project and then reimporting the project.
For me worked the answer I found on CodeRanch, by user Maneesh Godbole:
Close eclipse.
Navigate to your "workspace" folder
Ensure the setting on your OS to view hidden files is turned on
Identify and delete the .metadata directory
Restart eclipse
Import project
I've had the same problem in one of my modules.
Running "mvn eclipse:eclipse" in the console/cmd solved the problem for me.
In our instance of this problem, we had pom.xml files where the m2e-specific life cycle mapping configuration
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
...
did not have the <version>1.0.0</version> part. When doing a Maven -> Update Project..., this causes the reported NullPointerException without a stack trace. When using a fresh Import... -> Existing Maven Projects, the same exception occurred, but with a stack trace that led me to find the above.
(This is with m2e 1.6.1.20150625-2338 in Eclipse Luna Service Release 2 (4.4.2).)
In case it helps anyone, in addition to deleting .settings and .project, I had to delete .classpath and .factorypath before being able to import the project successfully into Eclipse.
org.eclipse.m2e.core.prefs file is in .settings folder. If you face the problem of
An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException
Delete the project from eclipse then by deleting the .settings folder & .project file in the project -> then re-import the project.
None of the above methods worked for me. This might also arise due to the presence of circular dependency in your eclipse workspace. So if there are any other errors present in any of the other projects in your workspace, try to fix those and then this issue will be gone. This is how i eliminated the error.
This helped me: Project menu -> Clean... -> clean all projects
Eclipse has an error log. There you will see the complete stack trace. In my case it seems to be caused by a bad jar file combined with the java.util.zip libs not throwing a proper exception, just a NullPointerException.
I'm using:
Eclipse Java EE IDE for Web Developers.
Version: Neon.3 Release (4.6.3)
Build id: 20170314-1500
The fix/trick for me was deleting my local repository in ~/.m2/repository in order to remove local dependencies and rebuilding my project in which fresh dependencies are pulled down.
Above solutions did not work for me as the issue with open JDK 13 version
https://github.com/spotify/dockerfile-maven/issues/163
So I degraded to open JDK8 and it works for me
I had the same problem. None of the solutions here worked. I had to completely reinstall eclipse and make a new workspace. Then it worked!
I had this same issue across multiple projects and multiple workspaces, none of the solutions I found online worked for me. I'm using STS and the only thing that worked was to go into my STS directory and add a "-clean" to the top of the STS.ini file. You can then start up your workspace and run maven clean without errors. (you can also remove the -clean tag from the ini file so it doesn't clean everytime you start it)
Hope this helps someone.
The root issue in my case was a file conflict in the .settings folder. So, deleting the .settings folder would have resolved the Maven error, but I wanted to keep some of my local configuration files. I resolved the conflict, then tried a Maven update again and it worked.
I had the same issue ... solution at the end !
here the eclipse log:
java.lang.NullPointerException
at com.google.appengine.eclipse.wtp.maven.GaeRuntimeManager.getGaeRuntime(GaeRuntimeManager.java:85)
at com.google.appengine.eclipse.wtp.maven.GaeRuntimeManager.ensureGaeRuntimeWithSdk(GaeRuntimeManager.java:55)
at com.google.appengine.eclipse.wtp.maven.GaeFacetManager.addGaeFacet(GaeFacetManager.java:59)
at com.google.appengine.eclipse.wtp.maven.GaeProjectConfigurator.configure(GaeProjectConfigurator.java:46)
... it comes from "appengine maven wtp plugin" that try to get the type of GAE runtime, but seems to be null here (... getRuntimeType() --> NPE):
see class com.google.appengine.eclipse.wtp.maven/GaeRuntimeManager.java
private static IRuntime getGaeRuntime(String sdkVersion) {
IRuntime[] runtimes = ServerCore.getRuntimes();
for (IRuntime runtime : runtimes) {
if (runtime != null && **runtime.getRuntimeType()**.equals(GAE_RUNTIME_TYPE)) {
So, if you check in eclipse, Google App Engine is visible , but when you select it you'll see that no SDK is associated ...
SOLUTION:
in red on the screenshot ;-)
I encountered this same symptom and none of the solutions above were helpful. I finally got a stack trace of the problem by importing the ear project again to eclipse, and was able to trace this down to the org.eclipse.m2e.wtp.MavenDeploymentDescriptorManagement which was trying to delete a directory in windows' temp directory called ".mavenDeploymentDescriptorManagement", which caused an irrational NullPointerException from the java.io.File.exists() method, particularly because the code already had successfully done the same thing in a previous method with the same variable, then called file.isFile() without problem.
Checking this out on the file system revealed that the file could only be accessed with administrator privileges. Apparently I had at some point launched eclipse from an administrator console by mistake.
In the end I just made hidden files visible in windows explorer and deleted the temporary file manually, which solved the problem.
Just another possible source of the problem!
I found out that in my case it was the following resource block that caused it:
<project>
<build>
<resources>
<resource>
<directory>${basedir}/../some-folder</directory>
<targetPath>outputFolder</targetPath>
</resource>
<resources>
</build>
</project>
It included a folder from the project folder (the eclipse project is a subfolder of the versioned project folder).
In my case, I could remove the error by removing the block and replacing it with a call to the Build helper Maven plugin:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>my-own-very-cool-id-for-this-step</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${basedir}/../some-folder</directory>
<targetPath>outputFolder</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I had to reinstall eclipse, delete .m2 folder and rebuild the jars.
deleting the local maven repository helped me
In my case, the problem was a conflict of derived dependencies that were been used by other dependencies, and some of those derived dependencies versions were not available, maybe because some deploy that i forgot to do because with workspace resolution everything worked, but when moving to other environment all broke suddenly.
And also I was working with version ranges
maven was giving me this error:
Could not resolve dependencies for project
MyProject:MyProject:jar:1.0.0: Could not resolve version conflict
among Dependency-A:1.0.1 -> Dependency-B:1.1.0 ->
Dependency-C:1.0.0, Dependency-X:1.0.1 -> Dependency-Y:1.1.0 -> Dependency-C:1.0.0, Dependency-I:1.0.1 -> Dependency-J:1.1.0 -> Dependency-C:1.0.0
I tried all above and nothing worked, so...
THE SOLUTION: Use LATEST as version in all dependencies, so maven don't need to resolve all dependencies in ranges, wich must be used
with care because if you miss to deploy one of the dependencies the
build will fail
Only I suggest you to use LATEST if you are working with your own dependencies, otherwise in some third party future version, you could find some compilation or runtime errors
Avoid deleting the .metadata folder as it cleans up all settings, run configurations.
Instead, rename the .metadata folder --> Restart eclipse --> Import project
deleting the local .settings folder helped me
solution step is delete following files in project folder
.settings
.project
.classpath
I solved this problem like this: Project -> Clean -> %YOURPROJECT%
Click Here for image