I occasionally receive this error when I build my project with
>mvn --version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 15:51:28+0200)
Maven home: ...\apache-maven-3.0.5
Java version: 1.6.0_45, vendor: Sun Microsystems Inc.
Java home: ...
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
and the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources
(default-resources) on project project-name: Cannot create resource output directory:
path\to\project\code\project-name\target\classes -> [Help 1]
Note: this happens sometimes, and it is not related to the code. It can happen in one of two consecutive builds - one after the other, against exactly the same source code.
Does anyone have any idea how to avoid it completely? It tends to interrupt quite a time-consuming build :-/
On Windows, there reasons for being unable to create a folder are:
Some other process is deleting this folder at the same time
You don't have permissions to access this folder
The folder is on a network share
Network shares are notoriously unreliable on Windows. Don't use them for any automated tasks. Always build projects with all files residing on a local hard disk.
If you use Maven and Eclipse to build at the same time, you should configure them to use different target folders. See https://stackoverflow.com/a/54366009/34088
Your POM should look like this:
<project>
...
<build>
<outputDirectory>${basedir}/${target.dir}/classes</outputDirectory>
<testOutputDirectory>${basedir}/${target.dir}/test-classes</testOutputDirectory>
</build>
<properties>
<target.dir>target</target.dir>
</properties>
<profiles>
<profile>
<id>eclipse-folders</id>
<properties>
<target.dir>target-eclipse</target.dir>
</properties>
</profile>
</profiles>
...
All that's left is to enable the profile eclipse-folders in the IDE.
Disable the automatic build of your IDE (Eclipse or IntellJ IDEA or whatever). It will conflict with the Maven build.
I experience this issue every time I run the command while I have the output folder or the parent folder opened in Windows Explorer.
If I move one level above the parent, the build ends successfully.
For me the reason for this was only being in said folder with my git bash while building. Ensure that you don't happen to have the said folder open in any other program.
I had the exact same issue when trying to run the First Cup tutorial.
I fixed it by simply closing NetBeans and running it as administrator (via right click).
In my case the parent directory inside which maven was trying to create a directory was root, so I did a sudo chown -R : /path/to/directory to change permissions before rerunning the mvn command.
In my case, I opened the jar in 7zip and I opened the target folder. I run my application and received this error. After closing 7zip, the application run fine and build successfully.
You can use the following in pom.xml
<build>
<directory>${project.basedir}/target1</directory>
</build>
My issue was resolved when I gave mvn clean command from windows coammandprompt
Related
I'm trying to build dbeaver and get the following error when running mvn package:
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: org.jkiss.dbeaver.slf4j 1.0.0.qualifier
[ERROR] Missing requirement: org.jkiss.dbeaver.slf4j 1.0.0.qualifier requires 'bundle org.slf4j.api 0.0.0' but it could not be found
I'm running on Windows 10 and using apache-maven-3.6.1. The strange thing is that when I try the same steps on Linux it builds without problem.
Update
Possible cause is maven 3.6.1 https://www.eclipse.org/lists/tycho-user/msg08177.html
Original post
The problem here, I presume, is that https://dbeaver.io/eclipse-repo/ p2 site is missing slf4j bundle and Tycho (?) cannot resolve the requirement. I still do not know how to make standalone maven build work, but here is an ugly workaround on how to build Windows binary with Eclipse (and embedded maven).
You can use p2-maven-plugin to build that missing bundle yourself. Instead of setting up a brand new project, you can temporarily modify product\localRepository\pom.xml to have a single artifact like
...
<artifacts>
<artifact><id>org.slf4j:slf4j-api:1.7.26</id></artifact>
</artifacts>
...
Now build that (product\localRepository\) project and start jetty
mvn p2:site
start mvn jetty:start
Now you can add this interim update site (http://localhost:8080/site/) to your Eclipse installation (Help -> Install New Software) and install slf4j. You should already be able to run DBeaver from within Eclipse.
To build a binary, add this interim repo into main pom.xml file, e.g. right after local-contrib one.
<repository>
<id>more</id>
<url>http://localhost:8080/site/</url>
<layout>p2</layout>
</repository>
Then go to Run Configurations -> Maven Build -> dbeaver, enter package goal and tick Skip Tests, click Run and go have some coffee.
As you can see Eclipse uses some sort of embedded maven runtime, so I guess it resolves things differently.
Note that if you are updating your local git repo, you might need to update your Eclipse project big time. I was unable to do it with right clicking on the project -> Configure -> Configure and Detect Nested Projects :( But deleting Eclipse project and nested projects (without deleting underlying files) and re-importing Maven project did the trick for me.
There is also an open issue for this https://github.com/dbeaver/dbeaver/issues/6115 .
I have a multimodule maven project. I do a mvn clean install of one of its examples which downloads and installs some dependencies.
if I do a $ file WhateverClass.class in certain jars from my WEB-INF/lib downloaded and compiled by Maven I keep getting
WhateverClass.class: compiled Java class data, version 51.0
which means that class has been compiled with Java 7.
I get this no matter how many times I compile that module by itself first! Why?
I have also checked the .class files from the modules themselves, after I see how the target folder has just been generated.
Along the project, some of the POM.xml specify a
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
but there are none specifying a higher java version.
My java version is:
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10)
OpenJDK Client VM (build 20.0-b11, mixed mode, sharing)
and javac version:
javac 1.6.0_23
EDIT
Here is my effective-pom
When you have problems like that, try to isolate the problem. The first step is to follow the path of the JAR backwards: Where did you find the class? Where did that JAR come from? If it came from a WAR, where did that come from? Do this until you find the computer on which the .class file is compiled. Check the JAR and the .class files in the target/classes/ folder.
At each step, run file on WhateverClass.class and go one step further when you see Java 7.
When you have find the build computer, you can use the following options to debug the build process:
mvn -v shows you the version of Maven and Java.
mvn help:effective-pom shows the resolved POM (i.e. after including every parent POM, resolving all properties, you name it). Which target option is active?
Run mvn with -X to get debug output. This can help to see which options Maven passes to forked processes.
I use the cargo maven plugin to donwload jboss as a dist and deploy our ear.
The JBoss we use is 7.1.0
My problem is, that we need an additional module in JBoss.
How can I copy a module to the JBoss in the target directory?
I tried it with this config:
<configuration>
<type>standalone</type>
<files>
<file>
<file>${project.basedir}/modules/springframework</file>
<todir>../../installs/jboss-as-dist-7.1.1.Final/jboss-as-7.1.1.Final/modules</todir>
</file>
</files>
</configuration>
But this gives me this error:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.2.1:start (start-container) on project gevomanagementservice_test_integration: Execution start-container of goal org.codehaus.cargo:cargo-maven2-plugin:1.2.1:start failed: Failed to copy source file [C:\blabla/modules/springframework] to [C:\blabla\target\cargo\configurations\jboss71x/../../installs/jboss-as-dist-7.1.1.Final/jboss-as-7.1.1.Final/modules/springframework]: C:\blabla\modules\springframework (The system cannot find the file specified) -> [Help 1]
It looks like I can only copy files with this config. Is there a possiblity to copy whole directories?
I came across this problem as well. But I only need to copy a handful of files so that's not an issue for me. I haven't actually tried below solution myself but in theory it may work.
Assuming you want to deploy your artifact by cargo and run integration test. I think you may choose to bind your cargo:install goal to, say, package phrase. Then have another plugin, i.e. maven-antrun-plugin to do the folder copying task, in package phrase as well. Then in pre-integration-test phrase, you can bind cargo:start (or deploy. See cargo reference) to start your jboss instance. The maven life cycle will look like:
clean
package
cargo:install (installs JBoss)
antrun (copy files over to the installed JBoss)
pre-integration-test
cargo:start (Note the document says this goal WON'T call cargo:install but reuse the same logic. I am not sure if this will erase your antrun effect. To be safe you may want to try cargo:deploy)
integration-test
post-integration-test
cargo:stop
I am trying to install a maven project at work and getting the following error. A bit of googling shows other people with the mojo problem, but none with the specific maven-war-plug and MavenFilteringException.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project genericIntegrationServer: Executio
n default-war of goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war failed: Unable to load the mojo 'war' in the plugin 'org.apache.maven.plugin
s:maven-war-plugin:2.1.1'. A required class is missing: org/apache/maven/shared/filtering/MavenFilteringException
Apache Maven 3.0.3 (r1075438; 2011-02-28 17:31:09+0000)
Maven home: C:\dev\apache-maven-3.0.3\bin..
Java version: 1.6.0_19, vendor: Sun Microsystems Inc.
Java home: c:\dev\jdk\1.6\1.6.0_19\jre
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
I had same issue. However, after running {Maven->Update Project} resolved the issue.
When I had this problem, it seemed to be a problem with my Maven install.
Uninstalling the M2Eclipse plugin and deleting the .m2 folder on my drive, then reinstalling M2Eclipse seemed to fix it.
I just ran into this problem or something very similar:
Unable to load the mojo 'resources'
I had just renamed some view files and had two path related errors in STS / Eclipse which I fixed but after fixing them a red X appeared next to the war line in the POM file.
"Project -> Clean" didn't help.
"Maven -> Update Project" did the trick though and cleared the error message.
I fixed this problem by doing a maven update and force Update of Snapshots/Releases
maven > update Maven Project > force Update of Snapshots/Releases
Yes, force update of Snapshots/Releases works for me. And I think it's an easy way to fix this problem.
I had the same issue and was able to resolve this error in Eclipse by doing an Maven->Update Project and checking the 'Force Update of Snapshots/Releases' check box. Without checking 'Force Update of Snapshots/Releases' though I continued to get the same errors.
The problem is solved by adding a plugin
<build>
<finalName>some_name</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
</plugins>
</pluginManagement>
I experienced a related problem (and ended up at this question after googling).
When building from Eclipse using the Maven plugin (Run As... -> Maven install), it was failing with the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.4.1:resources (default-resources) on project [project-name]: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.4.1:resources failed: Unable to load the mojo 'resources' in the plugin 'org.apache.maven.plugins:maven-resources-plugin:2.4.1'. A required class is missing: org/apache/maven/shared/filtering/MavenFilteringException
(also seen in this coderanch post)
Building from the command line worked fine, and I noticed that in that case it was using maven-resources-plugin version 2.4.3 and not 2.4.1.
In the end I fixed this by uninstalling and then reinstalling the M2Eclipse plugin (ver. 0.12.1) like Kevin suggested. (It seemed to work without deleting the .m2 folder)
I'm thinking the corruption might have happened when I exited Eclipse while it was in the middle of "Updating Indexes...".
I had a similar problem so I deleted only the folder maven folder at ~/.m2/repository/org/apache/maven and worked for me.
All maven libraries was downloaded and the error with MavenFilteringException stopped happened.
Just close and reopen the project
for me it solved the problem adding
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
as I use
<packaging>war</packaging>
I resolved this issue running clean install.
Navigate to the project root directory in terminal and run mvn clean install.
Then refresh the eclipse project. That's it.
I simply resolved this issue by deleting the repository folder in .m2, then running mvn clean install. In my case, the downloading of dependencies was aborted due to my machine shutting down, so I think one of the plugins were corrupted. Hope this helps someone.
For me, my maven was outdated in the bundle. I was using netbeans. So I first found where my maven was installed by using mvn -version and then copying the location. Then, on MACOS, I went to Netbeans --> Preferences --> Java and then Maven to finally set the maven Home to where maven is installed!
My issue got resolved by doing
Project (right click) -> Maven -> Update Project..
I use maven 3.0.3 and have tried to generate pom for third-party jar like this:
mvn install:install-file -Dfile=cobra.jar -DgroupId=com.cobra
-DartifactId=cobra -Dversion=0.98.4 -Dpackaging=jar -DgeneratePom=true
According to link below it should generate proper pom.xml and install artifact in the repo.
http://maven.apache.org/plugins/maven-install-plugin/examples/generic-pom-generation.html
Meanwhile, it returns such a error:
[ERROR] The goal you specified requires a project to execute but there
is no POM in this directory (D:\cobra-0.98.4\lib). Please verify you
invoked Maven from the correct directory. -> [Help 1]
Why is it asking for pom.xml while it should generate pom.xml?
This is an old question, but was a serious PITA for me for a few minutes, so I thought I'd share:
I just ran into this problem, and I believe that the issue is probably platform-dependent. The real tip-off was that the solution from Cyril's answer wasn't working as expected: despite my specification of -DgroupId=com.xyz and -DartifactId=whatever on the command-line and the corresponding entry in the POM file, the jar was installed in the local repo under com/whatever.
This led me to experiment with quoting command-line arguments, and the eventual correct result from formatting the command-line like this (after deleting the POM file):
mvn install:install-file "-Dfile=cobra.jar" "-DgroupId=com.cobra" "-DartifactId=cobra" "-Dversion=0.98.4" "-Dpackaging=jar" "-DgeneratePom=true"
Some of the quoting is doubtless redundant, but better safe than sorry, right? I happen to be running Vista on this computer, and would not be surprised if this problem were specific to this OS version...by the way, this was with Maven v3.0.4.
Are you sure that you are executing the install-file goal? I checked your command and it works for me, but when I place a blank install :install-file (maybe you have this typo) the install goal would be used which needs a pom.xml.
Try to use the -X parameter to get more debug information:
-X,--debug Produce execution debug output
My system
Maven
c:\>mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: C:\progs\apache-maven-3.0.3
Java version: 1.6.0_21, vendor: Sun Microsystems Inc.
Java home: c:\Program Files (x86)\Java\jdk1.6.0_21\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
Install Plugin
c:\>mvn -Dplugin=install help:describe
Name: Maven Install Plugin
Description: Copies the project artifacts to the user's local repository.
Group Id: org.apache.maven.plugins
Artifact Id: maven-install-plugin
Version: 2.3.1
Goal Prefix: install
This plugin has 3 goals:
install:help
Description: Display help information on maven-install-plugin.
Call
mvn install:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details.
install:install
Description: Installs the project's main artifact in the local repository.
install:install-file
Description: Installs a file in the local repository.
For more information, run 'mvn help:describe [...] -Ddetail'
I found a bypass. You need to create a simple pom.xml like this :
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cobra</groupId>
<artifactId>cobra</artifactId>
<version>0.98.4</version>
</project>
It's not perfect but it's worked for me. If you find a better way to do that, I'm interested.
My config :
$mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: /usr/local/maven
Java version: 1.6.0_20, vendor: Sun Microsystems Inc.
Java home: /usr/local/jdk1.6.0_20/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-25-generic-pae", arch: "i386", family: "unix"
$mvn -Dplugin=install help:describe
...
Name: Maven Install Plugin
Description: Copies the project artifacts to the user's local repository.
Group Id: org.apache.maven.plugins
Artifact Id: maven-install-plugin
Version: 2.3.1
Goal Prefix: install
...
Try to run it on cmd.exe or execute cmd command before the mvn command.
Using maven version 3.6.3, this worked for me to generate pom file in my chosen directory:
C:<MyChosenDir> mvn archetype:generate "-DgroupId=com.mycompany.app" "-DartifactId=my-app" "-DarchetypeArtifactId=maven-archetype-quickstart" "-DarchetypeVersion=1.4" "-DinteractiveMode=false"
just go under your project directory where you can find your pom.xml file then execute the same command ! it works for me ;)
If you are having trouble with the command line version of Maven, you might want to try the M2E plugin for eclipse. It is far more user friendly for people without very much experience with Maven.
It worked for me when I changed Powershell to Cygwin. Powershell is somehow parsing the command line argument incorrectly.
I had that error when I was using maven in Windows, what worked for me was opening the cmd and not the PowerShell.
Apparently certain errors appear when you don't do it with the cmd.
I hope it works.
If you are getting this error during jenkins pipeline setup , Then the error is we are placing git repository without .git in jenkins git url blank .Generally we put website url of git repo but we need to place clone url of git repo.Insert .git (cloned url) to website url , Simply insert git clone url.